コード例 #1
0
ファイル: SpecialAddVideo.php プロジェクト: Tjorriemorrie/app
 /**
  * Actually inserts the Video into the DB if validation passes
  *
  * @param $data Array
  * @return bool
  */
 public function submit(array $data)
 {
     list($url, $provider) = $this->getUrlAndProvider($data['Video']);
     $this->video->addVideo($url, $provider, false, $data['Watch']);
     $this->getOutput()->redirect($this->video->getTitle()->getFullURL());
     return true;
 }
コード例 #2
0
 /**
  * Do something exciting on successful processing of the form.  This might be to show
  * a confirmation message (watch, rollback, etc) or to redirect somewhere else (edit,
  * protect, etc).
  */
 public function onSuccess()
 {
     $out = $this->getOutput();
     $out->setPageTitle(wfMsgHtml('actioncomplete'));
     $out->setRobotPolicy('noindex,nofollow');
     $out->addHTML(wfMsg('video-revert-success'));
     $descTitle = $this->video->getTitle();
     $out->returnToMain(null, $descTitle->getPrefixedText());
 }
コード例 #3
0
ファイル: index.php プロジェクト: PlexHaxx/PlexUSM
         $CurrentVideo->setActiveSubtitle(0);
         $ArrayVideos[] = $CurrentVideo;
     }
 } else {
     /**
      * Movies can have subtitles, search for them.
      */
     foreach ($xmlsub2 as $xmlrowsub2) {
         $CurrentMediaPart = $xmlrowsub2->MediaItem->MediaPart;
         $CurrentVideo = new Video($xmlrowsub2->attributes()->id, $xmlrowsub2->attributes()->title);
         USMLog("debug", "[" . __FILE__ . " Line:" . __LINE__ . "] Found Movie: '" . $xmlrowsub2->attributes()->title . "'");
         /**
          * Check if we have a searchstring, and if so, check if the current title matches it.
          */
         if (strlen($Searchstring) > 3) {
             if (stripos($CurrentVideo->getTitle(), $Searchstring) === false) {
                 continue;
             }
         }
         $ActiveSubtitleXML = FetchXML($xmlrowsub['key']);
         foreach ($ActiveSubtitleXML as $ActiveSubtitle) {
             $Streams = $ActiveSubtitle->Media->Part->Stream;
             foreach ($Streams as $ActiveSubtitle) {
                 if ($ActiveSubtitle->attributes()->streamType == 3 and isset($ActiveSubtitle->attributes()->selected)) {
                     $CurrentVideo->setActiveSubtitle($ActiveSubtitle->attributes()->id);
                 }
             }
         }
         $CurrentVideo->setLibraryID($CurrentLibraryID);
         $CurrentVideo->setType($xmlrowsub['type']);
         $CurrentVideo->setEpisodeIndex(0);
コード例 #4
0
ファイル: functions.php プロジェクト: PlexHaxx/PlexUSM
/**
 * This functions lists all episodes for the provided show and season.
 */
function get_show_episodes($ShowKey, $SeasonIndex = false, $ShowRatingKey = "", $SearchString = false)
{
    global $Server, $ArrayVideos, $PathToPlexMediaFolder, $SearchSubtitleProviderFiles;
    $MatchedEpisodes = false;
    $xmlsub = FetchXML($ShowKey);
    foreach ($xmlsub as $xmlrowsub) {
        $AddVideo = true;
        $Episode = $xmlrowsub->attributes();
        USMLog("debug", "[" . __FILE__ . " Line:" . __LINE__ . "] Found episode: '" . $Episode->title . "'");
        $CurrentVideo = new Video($Episode->ratingKey, $Episode->title);
        $CurrentVideo->setType("movie");
        $CurrentVideo->setEpisodeIndex($Episode->index);
        if ($SearchString !== false) {
            if (stripos($CurrentVideo->getTitle(), $SearchString) === false) {
                continue;
            }
            $MatchedEpisodes = true;
        }
        /**
         * Get some information about the season. Title, index(number) and RatingKey.
         * A object can be provided if we are searching, but otherwise it's not provided.
         */
        if ($SeasonIndex !== false) {
            $CurrentVideo->setSeasonIndex($SeasonIndex->index);
            $CurrentVideo->setTitleShow($ShowRatingKey->getTitle());
            $CurrentVideo->setTitleSeason($SeasonIndex->title);
            $CurrentVideo->setRatingKey($ShowRatingKey->getRatingKey());
        } else {
            $Season_XML = FetchXML($Episode->parentKey);
            foreach ($Season_XML as $Season) {
                if ((int) $Season->attributes()->ratingKey == (int) $Episode->parentRatingKey) {
                    $CurrentVideo->setSeasonIndex($Season->attributes()->index);
                    $CurrentVideo->setTitleSeason($Season->attributes()->title);
                    $CurrentVideo->setSeasonKey($Season->attributes()->key);
                    $CurrentVideo->setRatingKey($Season->attributes()->ratingKey);
                    $CurrentVideo->setTitleShow($Season->attributes()->parentTitle);
                    $CurrentVideo->setShowKey($Season->attributes()->parentKey);
                }
            }
        }
        /**
         * Figure out what subtitle is selected in plex.
         */
        $ActiveSubtitleXML = FetchXML($Episode->key);
        foreach ($ActiveSubtitleXML as $ActiveSubtitle) {
            $Streams = $ActiveSubtitle->Media->Part->Stream;
            foreach ($Streams as $ActiveSubtitle) {
                if ($ActiveSubtitle->attributes()->streamType == 3 and isset($ActiveSubtitle->attributes()->selected)) {
                    $CurrentVideo->setActiveSubtitle($ActiveSubtitle->attributes()->id);
                }
            }
        }
        /**
         * Fetch subtitles for  the current episode
         */
        $xmlsub3 = FetchXML($Episode->key . '/tree');
        foreach ($xmlsub3 as $xmlrowsub3) {
            $CurrentMediaPart = $xmlrowsub3->MetadataItem->MetadataItem->MediaItem->MediaPart;
            $CurrentVideo->setPath($CurrentMediaPart->attributes()->file);
            $CurrentVideo->setHash($CurrentMediaPart->attributes()->hash);
            foreach ($CurrentMediaPart->MediaStream as $Subtitle) {
                if ($Subtitle->attributes()->type == 3) {
                    // Filter out VOBSUB by checking that there is a url connected to the subtitle.
                    $Language = "-";
                    if (strlen($Subtitle->attributes()->language) > 0) {
                        $Language = $Subtitle->attributes()->language;
                    }
                    /**
                     * If url is set, it's a external subtitle. (agent or local).
                     * Else it's a integrated one.
                     */
                    if (isset($Subtitle->attributes()->url)) {
                        $LocalSubtitle = false;
                        $Folder = SepFilename(preg_replace("/\\\\/i", "/", $Subtitle->attributes()->url));
                        if (strpos($Folder[0], "media://") !== false) {
                            $Folder[0] = $PathToPlexMediaFolder . substr($Folder[0], 8);
                        } else {
                            $LocalSubtitle = true;
                        }
                        if ($_SESSION['Option_HideLocal']['set'] === false) {
                            $CurrentVideo->setNewSubtitle(new Subtitle($Subtitle->attributes()->id, $Folder[1], $Language, $Folder[0] . $Folder[1], $Subtitle->attributes()->codec, $LocalSubtitle));
                            USMLog("debug", "[" . __FILE__ . " Line:" . __LINE__ . "] Found subtitle: '" . $Folder[0] . $Folder[1] . "'");
                        } else {
                            if ($LocalSubtitle === false) {
                                $CurrentVideo->setNewSubtitle(new Subtitle($Subtitle->attributes()->id, $Folder[1], $Language, $Folder[0] . $Folder[1], $Subtitle->attributes()->codec, $LocalSubtitle));
                                USMLog("debug", "[" . __FILE__ . " Line:" . __LINE__ . "] Found subtitle: '" . $Folder[0] . $Folder[1] . "'");
                            }
                        }
                    } else {
                        if ($_SESSION['Option_HideIntegrated']['set'] === false) {
                            $CurrentVideo->setNewSubtitle(new Subtitle($Subtitle->attributes()->id, "Integrated subtitle", $Language, false, $Subtitle->attributes()->codec, $LocalSubtitle));
                        }
                    }
                }
            }
        }
        CheckForDuplicates($CurrentVideo);
        if ($_SESSION['Option_MultipleSubtitlesOnly']['set'] === true) {
            $AddVideo = false;
            foreach ($CurrentVideo->getSubtitles() as $SubtitleLanguageArray) {
                if (count($SubtitleLanguageArray) < 2) {
                    /* Current language has less than 2 subtitles */
                    foreach ($SubtitleLanguageArray as $Subtitle) {
                        $Subtitle->setHideSubtitle(true);
                    }
                } else {
                    $AddVideo = true;
                }
            }
        }
        if ($_SESSION['Option_HideEmpty']['set'] === true and count($CurrentVideo->getSubtitles()) < 1) {
            $AddVideo = false;
        }
        if ($AddVideo) {
            $ArrayVideos[] = $CurrentVideo;
        }
    }
    if ($SearchString !== false) {
        return $MatchedEpisodes;
    }
}