protected function getTrackUrlsFromUrl($url, &$plugin_cookies)
 {
     $xml = HD::getAndParseXmlFromUrl($url);
     $musics = array();
     foreach ($xml->Directory as $dir) {
         $url = $this->base_url . $dir->attributes()->key;
         $musics = array_merge($musics, $this->getTrackUrlsFromUrl($url, $plugin_cookies));
     }
     foreach ($xml->Track as $track) {
         $title = $track->attributes()->title;
         if (!$title || $title == "") {
             $title = basename($track->Media->Part->attributes()->file);
         }
         $fileName = $this->base_url . $track->Media->Part->attributes()->key;
         if ($plugin_cookies->connectionMethod == NFS_CONNECTION_TYPE || $plugin_cookies->connectionMethod == SMB_CONNECTION_TYPE) {
             foreach ($plugin_cookies as $key => $value) {
                 if (strstr($track->Media->Part->attributes()->file, $key) !== false) {
                     $fileName = str_replace($key, $value, $track->Media->Part->attributes()->file);
                 }
             }
         }
         $musics = array_merge($musics, array("{$title}" => $fileName));
     }
     return $musics;
 }
 public function downLoadSubtitleFromPlex(&$user_input, &$plugin_cookies, $video_url, $languageCode = 'por')
 {
     $media_url = MediaURL::decode($user_input->selected_media_url);
     $base_url = EmplexerConfig::getInstance()->getPlexBaseUrl($plugin_cookies, $this);
     $url = $base_url . $media_url->detail_info_key;
     $xml = HD::getAndParseXmlFromUrl($url);
     $subtitleFileName = str_replace(array(".mkv", ".avi", ".mp4"), '.srt', HD::nfsUrlToSystemPath($video_url));
     foreach ($xml->Video->Media->Part->Stream as $stream) {
         //is subtitle?
         //is languageCode == $languageCode?
         //Subtititle dosen't exists local?
         if ($stream->attributes()->streamType == "3" && $stream->attributes()->languageCode == $languageCode && !file_exists($subtitleFileName)) {
             //download the subtitle
             hd_print(__METHOD__ . ' não existe legenda local e existe no plex a legenda com o código: ' . $languageCode . ' vou baixar e colocar com o nome ' . $subtitleFileName);
             $subtitleUrl = $base_url . $stream->attributes()->key;
             $subData = HD::http_get_document($subtitleUrl);
             file_put_contents($subtitleFileName, $subData);
         }
     }
 }
 public function getAllAvailableChannels(&$plugin_cookies, $handler)
 {
     hd_print(__METHOD__);
     $url = EmplexerConfig::getInstance()->getPlexBaseUrl($plugin_cookies, $handler);
     hd_print("BASE_URL={$url}");
     $xml = HD::getAndParseXmlFromUrl($url);
     hd_print(print_r($xml, true));
     // $validChannels = array('video', 'music', 'photos');
     $validChannels = EmplexerConfig::getInstance()->getValidChannelsNames();
     $items = array();
     foreach ($xml as $d) {
         $key = (string) $d->attributes()->key;
         if (in_array($key, $validChannels)) {
             $channelName = ucwords("{$key} Channels");
             $items[] = array(PluginRegularFolderItem::media_url => EmplexerBaseChannel::get_media_url_str($key), PluginRegularFolderItem::caption => $channelName, PluginRegularFolderItem::view_item_params => array(ViewItemParams::icon_path => 'plugin_file://icons/sudoku.png'));
         }
     }
     hd_print(__METHOD__ . ':' . print_r($items, true));
     return $items;
 }
 public static function show_subtitle_config_modal($modalTitle, &$plugin_cookies, $post_action = null)
 {
     $defs = array();
     $languageCodes = array("aa" => "Afar", "ab" => "Abkhazian", "ae" => "Avestan", "af" => "Afrikaans", "ak" => "Akan", "am" => "Amharic", "an" => "Aragonese", "ar" => "Arabic", "as" => "Assamese", "av" => "Avaric", "ay" => "Aymara", "az" => "Azerbaijani", "ba" => "Bashkir", "be" => "Belarusian", "bg" => "Bulgarian", "bh" => "Bihari", "bi" => "Bislama", "bm" => "Bambara", "bn" => "Bengali", "bo" => "Tibetan", "br" => "Breton", "bs" => "Bosnian", "ca" => "Catalan", "ce" => "Chechen", "ch" => "Chamorro", "co" => "Corsican", "cr" => "Cree", "cs" => "Czech", "cu" => "Church Slavic", "cv" => "Chuvash", "cy" => "Welsh", "da" => "Danish", "de" => "German", "dv" => "Divehi", "dz" => "Dzongkha", "ee" => "Ewe", "el" => "Greek", "en" => "English", "eo" => "Esperanto", "es" => "Spanish", "et" => "Estonian", "eu" => "Basque", "fa" => "Persian", "ff" => "Fulah", "fi" => "Finnish", "fj" => "Fijian", "fo" => "Faroese", "fr" => "French", "fy" => "Western Frisian", "ga" => "Irish", "gd" => "Scottish Gaelic", "gl" => "Galician", "gn" => "Guarani", "gu" => "Gujarati", "gv" => "Manx", "ha" => "Hausa", "he" => "Hebrew", "hi" => "Hindi", "ho" => "Hiri Motu", "hr" => "Croatian", "ht" => "Haitian", "hu" => "Hungarian", "hy" => "Armenian", "hz" => "Herero", "ia" => "Interlingua (International Auxiliary Language Association)", "id" => "Indonesian", "ie" => "Interlingue", "ig" => "Igbo", "ii" => "Sichuan Yi", "ik" => "Inupiaq", "io" => "Ido", "is" => "Icelandic", "it" => "Italian", "iu" => "Inuktitut", "ja" => "Japanese", "jv" => "Javanese", "ka" => "Georgian", "kg" => "Kongo", "ki" => "Kikuyu", "kj" => "Kwanyama", "kk" => "Kazakh", "kl" => "Kalaallisut", "km" => "Khmer", "kn" => "Kannada", "ko" => "Korean", "kr" => "Kanuri", "ks" => "Kashmiri", "ku" => "Kurdish", "kv" => "Komi", "kw" => "Cornish", "ky" => "Kirghiz", "la" => "Latin", "lb" => "Luxembourgish", "lg" => "Ganda", "li" => "Limburgish", "ln" => "Lingala", "lo" => "Lao", "lt" => "Lithuanian", "lu" => "Luba-Katanga", "lv" => "Latvian", "mg" => "Malagasy", "mh" => "Marshallese", "mi" => "Maori", "mk" => "Macedonian", "ml" => "Malayalam", "mn" => "Mongolian", "mr" => "Marathi", "ms" => "Malay", "mt" => "Maltese", "my" => "Burmese", "na" => "Nauru", "nb" => "Norwegian Bokmal", "nd" => "North Ndebele", "ne" => "Nepali", "ng" => "Ndonga", "nl" => "Dutch", "nn" => "Norwegian Nynorsk", "no" => "Norwegian", "nr" => "South Ndebele", "nv" => "Navajo", "ny" => "Chichewa", "oc" => "Occitan", "oj" => "Ojibwa", "om" => "Oromo", "or" => "Oriya", "os" => "Ossetian", "pa" => "Panjabi", "pi" => "Pali", "pl" => "Polish", "ps" => "Pashto", "pt" => "Portuguese", "qu" => "Quechua", "rm" => "Raeto-Romance", "rn" => "Kirundi", "ro" => "Romanian", "ru" => "Russian", "rw" => "Kinyarwanda", "sa" => "Sanskrit", "sc" => "Sardinian", "sd" => "Sindhi", "se" => "Northern Sami", "sg" => "Sango", "si" => "Sinhala", "sk" => "Slovak", "sl" => "Slovenian", "sm" => "Samoan", "sn" => "Shona", "so" => "Somali", "sq" => "Albanian", "sr" => "Serbian", "ss" => "Swati", "st" => "Southern Sotho", "su" => "Sundanese", "sv" => "Swedish", "sw" => "Swahili", "ta" => "Tamil", "te" => "Telugu", "tg" => "Tajik", "th" => "Thai", "ti" => "Tigrinya", "tk" => "Turkmen", "tl" => "Tagalog", "tn" => "Tswana", "to" => "Tonga", "tr" => "Turkish", "ts" => "Tsonga", "tt" => "Tatar", "tw" => "Twi", "ty" => "Tahitian", "ug" => "Uighur", "uk" => "Ukrainian", "ur" => "Urdu", "uz" => "Uzbek", "ve" => "Venda", "vi" => "Vietnamese", "vo" => "Volapuk", "wa" => "Walloon", "wo" => "Wolof", "xh" => "Xhosa", "yi" => "Yiddish", "yo" => "Yoruba", "za" => "Zhuang", "zh" => "Chinese", "zu" => "Zulu");
     ControlFactory::add_combobox($defs, null, null, $name = 'preferredLanguage', $title = 'Preferred language', $initial_value = $value, $value_caption_pairs = $languageCodes, $width = 500, $need_confirm = false, $need_apply = false);
     $plexLocation = 'http://' . $plugin_cookies->plexIp . ':' . $plugin_cookies->plexPort . '/library/sections';
     $xml = HD::getAndParseXmlFromUrl($plexLocation);
     // hd_print(__METHOD__ . ';' . print_r($xml, true));
     foreach ($xml->Directory as $directory) {
         foreach ($directory->Location as $location) {
             //se já existir a chave e o valor for nfs usa a chave que já existe se não pega o valor do plex
             if ($plugin_cookies->{$location->attributes()->path} && strpos($plugin_cookies->{$location->attributes()->path}, 'nfs://') !== false) {
                 $value = $plugin_cookies->{$location->attributes()->path};
             } else {
                 $value = 'nfs://' . $plugin_cookies->plexIp . ':' . (string) $location->attributes()->path;
             }
             ControlFactory::add_text_field($defs, null, null, $name = (string) $location->attributes()->path, $title = (string) $location->attributes()->path, $initial_value = $value, $numeric = false, $password = false, $has_osk = false, $always_active = 0, $width = 500);
         }
     }
     ControlFactory::add_custom_close_dialog_and_apply_buffon($defs, 'saveAdvanceNfs', 'save', 200, $post_action);
     return ActionFactory::show_dialog($modalTitle, $defs);
 }
 public static function get_vod_info($toPlay)
 {
     // hd_print(__METHOD__);
     hd_print(__METHOD__ . ':' . print_r($toPlay, true));
     $url = $toPlay->url;
     if ($toPlay->indirect) {
         $xml = HD::getAndParseXmlFromUrl(str_replace('http://mp4://', 'http://', $toPlay->url));
         // $doc = HD::http_get_document( );
         // $xml = HD::parse_xml_document($doc);
         $url = $xml->Video->Media->Part->attributes()->key;
         $toPlay->url = $toPlay->container == 'mp4' ? str_replace('http://', 'http://mp4://', $url) : $url;
     } else {
         $toPlay->url = $toPlay->container == 'mp4' ? str_replace('http://', 'http://mp4://', $url) : $url;
     }
     // $params['selected_media_url'] = $toPlay->selected_media_url;
     $series_array = array();
     $series_array[] = array(PluginVodSeriesInfo::name => $toPlay->title, PluginVodSeriesInfo::playback_url => $toPlay->url, PluginVodSeriesInfo::playback_url_is_stream_url => true);
     $toBeReturned = array(PluginVodInfo::id => 1, PluginVodInfo::series => $series_array, PluginVodInfo::name => $toPlay->title, PluginVodInfo::description => $toPlay->summary, PluginVodInfo::poster_url => $toPlay->thumb, PluginVodInfo::initial_series_ndx => 0, PluginVodInfo::buffering_ms => 6000, PluginVodInfo::advert_mode => false);
     hd_print(__METHOD__ . ':' . print_r($toBeReturned, true));
     return $toBeReturned;
 }
Beispiel #6
-1
 public function get_vod_info(MediaURL $media_url, &$plugin_cookies)
 {
     HD::print_backtrace();
     $movie = $this->get_cached_movie($media_url->movie_id);
     hd_print(__METHOD__ . ' teste:' . print_r($movie, true));
     $m = HD::getAndParseXmlFromUrl($this->base_url . $media_url->movie_id);
     $viewOffset = $m->Video->attributes()->viewOffset ? (string) $m->Video->attributes()->viewOffset : 0;
     // $params['selected_media_url'] = $toPlay->selected_media_url;
     $series_array = array();
     $series_array[] = array(PluginVodSeriesInfo::name => $movie->name_original . "\n" . $movie->name, PluginVodSeriesInfo::playback_url => $movie->series_list[0]->playback_url, PluginVodSeriesInfo::playback_url_is_stream_url => true);
     $toBeReturned = array(PluginVodInfo::id => 1, PluginVodInfo::series => $movie->series_list, PluginVodInfo::name => $movie->name_original, PluginVodInfo::description => $movie->description, PluginVodInfo::poster_url => $movie->poster_url, PluginVodInfo::initial_series_ndx => 0, PluginVodInfo::buffering_ms => 6000, PluginVodInfo::initial_position_ms => $viewOffset, PluginVodInfo::advert_mode => false, PluginVodInfo::timer => array(GuiTimerDef::delay_ms => 5000));
     // hd_print(__METHOD__ . ':'  . print_r($toBeReturned, true));
     return $toBeReturned;
 }