public function doParseOnDirectories(&$xml, &$media_url, &$plugin_cookies)
 {
     hd_print(__METHOD__);
     $items = array();
     foreach ($xml->Directory as $c) {
         // hd_print('media_url->key =' . $media_url->key . ' c->attributes()->key = ' . (string)$c->attributes()->key );
         if (!HD::starts_with((string) $c->attributes()->key, '/')) {
             // hd_print((string)$c->attributes()->key . ' não começa com /');
             $key = $media_url->key . '/' . (string) $c->attributes()->key;
         } else {
             // hd_print((string)$c->attributes()->key . ' começa com /');
             $key = (string) $c->attributes()->key;
         }
         $title = (string) $c->attributes()->title;
         $summary = (string) $c->attributes()->summary;
         $url = $this->base_url . $key;
         $cache_file_name = "channel_{$title}.jpg";
         $settings = (string) $c->attributes()->settings;
         $search = (string) $c->attributes()->search;
         $prompt = (string) $c->attributes()->prompt;
         $art = $c->attributes()->art ? (string) $c->attributes()->art : (string) $xml->attributes()->art;
         hd_print('art= ' . $art);
         $type = !$settings ? TYPE_DIRECTORY : TYPE_CONF;
         $type = !$search ? $type : TYPE_SEARCH;
         $parameters = array('key' => $key, 'type' => $type, 'params' => $art ? array('art' => $this->base_url . $art) : null);
         $items[] = array(PluginRegularFolderItem::media_url => $this->getNextScreen($parameters), PluginRegularFolderItem::caption => $title, PluginRegularFolderItem::view_item_params => array(ViewItemParams::icon_path => $this->getThumbURL($c), ViewItemParams::item_detailed_icon_path => $this->getThumbURL($c)));
     }
     return $items;
 }
Example #2
1
 private function open_popup_for_filter($current_url, $key)
 {
     $key = (string) $media_url->category_id;
     $doc = HD::http_get_document($current_url . '/' . $key);
     $pop_up_items = array();
     $xml = simplexml_load_string($doc);
     foreach ($xml->Directory as $c) {
         $key = (string) $c->attributes()->key;
         $prompt = (string) $c->attributes()->prompt;
         if ($key != 'all' && $key != 'folder' && !$prompt) {
             $pop_up_items[] = array(GuiMenuItemDef::caption => (string) $c->attributes()->title, GuiMenuItemDef::action => ActionFactory::open_folder($this->get_right_media_url($media_url, $key), $key));
         }
     }
     $action = ActionFactory::show_popup_menu($pop_up_items);
 }
Example #3
0
 public function showPopUpMenu($url)
 {
     hd_print(__METHOD__);
     $doc = HD::http_get_document($url);
     // hd_print(print_r($doc,true));
     $pop_up_items = array();
     $xml = simplexml_load_string($doc);
     // hd_print(print_r($xml, true));
     $pop_up_items = array();
     foreach ($xml->Directory as $c) {
         $key = (string) $c->attributes()->key;
         $prompt = (string) $c->attributes()->prompt;
         hd_print("key==={$key}");
         if ($key != 'all' && $key != 'folder' && !$prompt) {
             $pop_up_items[] = array(GuiMenuItemDef::caption => (string) $c->attributes()->title);
         }
     }
     $chucks = array_chunk($pop_up_items, $this->maxSize);
     $result = array();
     $a = $this->addNextToChunk($chucks, $chucks[0], 0);
     hd_print('a ==== ' . print_r($a, true));
     $result[] = $chucks[0];
     $result[] = array(GuiMenuItemDef::is_separator => true);
     $result[] = array(GuiMenuItemDef::caption => $this->nextText, GuiMenuItemDef::action => ActionFactory::show_popup_menu($this->addNextToChunk($chucks, $chucks[0], 0)));
     $action = ActionFactory::show_popup_menu($chucks[1]);
     // hd_print(print_r($action, true));
     // hd_print(print_r($chucks, true));
     hd_print('result = ' . print_r($result, true));
     return $action;
 }
 public function get_all_folder_items(MediaURL $media_url, &$plugin_cookies)
 {
     // hd_print(__METHOD__);
     //hd_print(__METHOD__ . ':' . print_r($media_url, true));
     $doc = HD::http_get_document(EmplexerConfig::getInstance()->getPlexBaseUrl($plugin_cookies, $this) . '/library/sections/' . $media_url->category_id . '/' . $media_url->filter_name);
     $xml = simplexml_load_string($doc);
     $items = array();
     $cache_keys = array();
     foreach ($xml->Directory as $c) {
         $thumb = (string) $c->attributes()->thumb;
         $url = EmplexerConfig::getInstance()->getPlexBaseUrl($plugin_cookies, $this) . '/photo/:/transcode?width=' . THUMB_WIDTH . '&height=' . THUMB_HEIGHT . '&url=' . EmplexerConfig::getInstance()->getPlexBaseUrl($plugin_cookies, $this) . $thumb;
         // $urlb = EmplexerConfig::getInstance()->getPlexBaseUrl($plugin_cookies, $this) . (string)$c->attributes()->thumb;
         // hd_print(__METHOD__ . ':EmplexerConfig::getInstance()->useCache= ' . EmplexerConfig::getInstance()->useCache .  ' tipo = '  . gettype(EmplexerConfig::getInstance()->useCache));
         // if (EmplexerConfig::getInstance()->useCache === 'false'){
         // 	hd_print('Entrou.... ' );
         // 	$url = EmplexerConfig::getInstance()->getPlexBaseUrl($plugin_cookies, $this). $thumb;
         // }
         $bgImage = EmplexerConfig::getInstance()->getPlexBaseUrl($plugin_cookies, $this) . $c->attributes()->art;
         $caption = (string) $c->attributes()->ratingKey . '.jpg';
         if ($thumb) {
             EmplexerArchive::getInstance()->setFileToArchive($caption, $url);
         }
         $items[] = array(PluginRegularFolderItem::media_url => $this->get_right_media_url($media_url, $c), PluginRegularFolderItem::caption => (string) $c->attributes()->title, PluginRegularFolderItem::view_item_params => array(ViewItemParams::icon_path => EmplexerArchive::getInstance()->getFileFromArchive($caption, $url), ViewItemParams::item_detailed_icon_path => EmplexerArchive::getInstance()->getFileFromArchive($caption, $url), ViewItemParams::icon_keep_aspect_ratio => false));
     }
     // hd_print(__METHOD__ .':'. print_r($items, true));
     return $items;
 }
Example #5
0
 public static function get_mac_addr()
 {
     static $mac_addr = null;
     if (is_null($mac_addr)) {
         $mac_addr = str_replace(':', '-', HD::get_mac_addr());
         hd_print("API: macaddr '{$mac_addr}'");
     }
     return $mac_addr;
 }
 private function get_sel_item_update_action(&$user_input, &$plugin_cookies)
 {
     $parent_media_url = MediaURL::decode($user_input->parent_media_url);
     $sel_ndx = $user_input->sel_ndx;
     $group = $this->tv->get_group($parent_media_url->group_id);
     $channels = $group->get_channels($plugin_cookies);
     $items[] = $this->get_regular_folder_item($group, $channels->get_by_ndx($sel_ndx), $plugin_cookies);
     $range = HD::create_regular_folder_range($items, $sel_ndx, $channels->size());
     return ActionFactory::update_regular_folder($range, false);
 }
Example #7
0
 public function get_folder_range(MediaURL $media_url, $from_ndx, &$plugin_cookies)
 {
     $movie_range = $this->get_short_movie_range($media_url, $from_ndx, $plugin_cookies);
     $total = intval($movie_range->total);
     if ($total <= 0) {
         return HD::create_regular_folder_range(array());
     }
     $items = array();
     foreach ($movie_range->short_movies as $movie) {
         $items[] = array(PluginRegularFolderItem::media_url => VodMovieScreen::get_media_url_str($movie->id), PluginRegularFolderItem::caption => $movie->name, PluginRegularFolderItem::view_item_params => array(ViewItemParams::icon_path => $movie->poster_url));
         $this->vod->set_cached_short_movie(new ShortMovie($movie->id, $movie->name, $movie->poster_url));
     }
     return HD::create_regular_folder_range($items, $movie_range->from_ndx, $total);
 }
 private function get_update_action($sel_increment, &$user_input, &$plugin_cookies)
 {
     $parent_media_url = MediaURL::decode($user_input->parent_media_url);
     $num_favorites = count($this->tv->get_fav_channel_ids($plugin_cookies));
     $sel_ndx = $user_input->sel_ndx + $sel_increment;
     if ($sel_ndx < 0) {
         $sel_ndx = 0;
     }
     if ($sel_ndx >= $num_favorites) {
         $sel_ndx = $num_favorites - 1;
     }
     $range = HD::create_regular_folder_range($this->get_all_folder_items($parent_media_url, $plugin_cookies));
     return ActionFactory::update_regular_folder($range, true, $sel_ndx);
 }
 public function get_all_folder_items(MediaURL $media_url, &$plugin_cookies)
 {
     hd_print(__METHOD__);
     //hd_print(__METHOD__ . ':' . print_r($media_url, true));
     $doc = HD::http_get_document(EmplexerConfig::getInstance()->getPlexBaseUrl($plugin_cookies, $this) . '/library/sections/' . $media_url->category_id . '/' . $media_url->filter_name);
     $xml = simplexml_load_string($doc);
     $items = array();
     $cache_keys = array();
     foreach ($xml->Directory as $c) {
         $items[] = array(PluginRegularFolderItem::media_url => $this->get_right_media_url($media_url, $c), PluginRegularFolderItem::caption => (string) $c->attributes()->title, PluginRegularFolderItem::view_item_params => array());
     }
     hd_print(__METHOD__ . ':' . print_r($items, true));
     return $items;
 }
 public function get_all_folder_items(MediaURL $media_url, &$plugin_cookies)
 {
     // hd_print(__METHOD__);
     // hd_print (__METHOD__ . ':' . print_r($media_url, true));
     if (!isset($media_url->filter_name)) {
         $doc = HD::http_get_document(EmplexerConfig::getInstance()->getPlexBaseUrl($plugin_cookies, $this) . $media_url->key);
     } else {
         $doc = HD::http_get_document(EmplexerConfig::getInstance()->getPlexBaseUrl($plugin_cookies, $this) . '/library/sections/' . $media_url->key . '/' . ${$media_url}->filter_name);
     }
     // $doc = HD::http_get_document(EmplexerConfig::getInstance()->getPlexBaseUrl($plugin_cookies, $this) . $media_url->key );
     $xml = simplexml_load_string($doc);
     $items = array();
     /*
     
     	TODO adicionar backgound com o art vindo do plex
     $bg = array(
     	ViewParams::background_order =>'before_all',
     	ViewParams::background_path  => $bgImage
     );
     
     $viewParams = PluginRegularFolderItem::view_params;
     array_push($view_params, $bg );
     PluginRegularFolderItem::view_params => $viewParams;
     */
     foreach ($xml->Directory as $c) {
         // hd_print(__METHOD__);
         // hd_print(__METHOD__ . ':' .  print_r($xml, true));
         $thumb = (string) $c->attributes()->thumb ? (string) $c->attributes()->thumb : (string) $xml->attributes()->thumb;
         $url = EmplexerConfig::getInstance()->getPlexBaseUrl($plugin_cookies, $this) . '/photo/:/transcode?width=' . THUMB_WIDTH . '&height=' . THUMB_HEIGHT . '&url=' . EmplexerConfig::getInstance()->getPlexBaseUrl($plugin_cookies, $this) . $thumb;
         if (EmplexerConfig::getInstance()->useCache === 'false') {
             $url = EmplexerConfig::getInstance()->getPlexBaseUrl($plugin_cookies, $this) . $thumb;
         }
         // $url =  EmplexerConfig::getInstance()->getPlexBaseUrl($plugin_cookies, $this) .'/photo/:/transcode?width=150&height=222&url=' . EmplexerConfig::getInstance()->getPlexBaseUrl($plugin_cookies, $this) . (string)$c->attributes()->thumb;
         $urlb = EmplexerConfig::getInstance()->getPlexBaseUrl($plugin_cookies, $this) . (string) $c->attributes()->thumb;
         $bgImage = EmplexerConfig::getInstance()->getPlexBaseUrl($plugin_cookies, $this) . $c->attributes()->art;
         $ratingKey = $c->attributes()->ratingKey ? (string) $c->attributes()->ratingKey : (string) $xml->attributes()->key;
         $caption = $ratingKey . '.jpg';
         if ($thumb) {
             EmplexerArchive::getInstance()->setFileToArchive($caption, $url);
         }
         $remainingEpisodes = (int) $c->attributes()->leafCount - (int) $c->attributes()->viewedLeafCount;
         $items[] = array(ViewParams::background_order => 'before_all', ViewParams::background_path => $bgImage, PluginRegularFolderItem::media_url => EmplexerVideoList::get_media_url_str((string) $c->attributes()->key), PluginRegularFolderItem::caption => (string) $c->attributes()->title . ' (' . (string) $remainingEpisodes . ')', PluginRegularFolderItem::view_item_params => array(ViewItemParams::icon_path => EmplexerArchive::getInstance()->getFileFromArchive($caption, $url), ViewItemParams::item_detailed_icon_path => EmplexerArchive::getInstance()->getFileFromArchive($caption, $url), ViewItemParams::item_caption_wrap_enabled => false));
     }
     // hd_print(print_r($items, true));
     return $items;
 }
 public function handle_user_input(&$user_input, &$plugin_cookies)
 {
     hd_print(__METHOD__);
     hd_print(__METHOD__ . ":" . print_r($user_input, true));
     if ($user_input->control_id == 'pop_up') {
         $media_url = MediaURL::decode($user_input->selected_media_url);
         $key = (string) $media_url->category_id;
         // hd_print("key = $key");
         if ($key) {
             $url = EmplexerConfig::getInstance()->getPlexBaseUrl($plugin_cookies, $this) . '/library/sections/' . $key;
             /*$popUp = new EmplexerPopUp(4);
             		$action = $popUp->showPopUpMenu($url);*/
             $doc = HD::http_get_document(EmplexerConfig::getInstance()->getPlexBaseUrl($plugin_cookies, $this) . '/library/sections/' . $key);
             $pop_up_items = array();
             $xml = simplexml_load_string($doc);
             $defaultFilter = 'all';
             if ($media_url->type == 'show') {
                 $defaultFilter = isset($plugin_cookies->defaultShowFilter) ? $plugin_cookies->defaultShowFilter : 'all';
             }
             if ($media_url->type == 'movie') {
                 $defaultFilter = isset($plugin_cookies->defaultMovieFilter) ? $plugin_cookies->defaultMovieFilter : 'all';
             }
             foreach ($xml->Directory as $c) {
                 $key = (string) $c->attributes()->key;
                 $prompt = (string) $c->attributes()->prompt;
                 $is_secondary = (string) $c->attributes()->secondary;
                 if ($key != $defaultFilter && $key != 'folder' && !$prompt) {
                     // if ($key != 'all' ){
                     $pop_up_items[] = array(GuiMenuItemDef::caption => (string) $c->attributes()->title, GuiMenuItemDef::action => ActionFactory::open_folder($this->get_right_media_url_for_pop_up($media_url, $key, $is_secondary != null), $key));
                 }
             }
             hd_print(__METHOD__ . ' pop_up_items:' . print_r($pop_up_items, true));
             $action = ActionFactory::show_popup_menu($pop_up_items);
             // hd_print(__METHOD__ . ': ' . print_r($action, true));
             return $action;
         } else {
             return null;
         }
     }
     if ($user_input->control_id == 'savePref') {
         hd_print(__METHOD__ . ':' . print_r($user_input, true));
         hd_print(__METHOD__ . ':' . print_r($plugin_cookies, true));
         EmplexerSetupScreen::savePreferences($user_input, $plugin_cookies);
     }
 }
 public static function get_archive($id, $url_prefix)
 {
     $archive = ArchiveCache::get_archive_by_id($id);
     if (!is_null($archive)) {
         return $archive;
     }
     $version_url = $url_prefix . '/versions.txt';
     try {
         $doc = HD::http_get_document($version_url);
     } catch (Exception $e) {
         $doc = null;
     }
     $version_by_name = array();
     $total_size = 0;
     if (is_null($doc)) {
         hd_print("Failed to fetch archive versions.txt from {$version_url}.");
     } else {
         $tok = strtok($doc, "\n");
         while ($tok !== false) {
             $pos = strrpos($tok, ' ');
             if ($pos === false) {
                 hd_print("Invalid line in versions.txt for archive '{$id}'.");
                 continue;
             }
             $name = trim(substr($tok, 0, $pos));
             $version = trim(substr($tok, $pos + 1));
             $version_by_name[$name] = $version;
             $tok = strtok("\n");
         }
         hd_print("Archive {$id}: " . count($version_by_name) . " files.");
         $size_url = $url_prefix . '/size.txt';
         $doc = HD::http_get_document($size_url);
         if (is_null($doc)) {
             hd_print("Failed to fetch archive size.txt from {$size_url}.");
             $version_by_name = array();
         } else {
             $total_size = intval($doc);
             hd_print("Archive {$id}: size = {$total_size}");
         }
     }
     $archive = new DefaultArchive($id, $url_prefix, $version_by_name, $total_size);
     ArchiveCache::set_archive($archive);
     return $archive;
 }
 public function downloadToCache($fileName, $fileUrl)
 {
     if (EmplexerConfig::getInstance()->hasPersistFs) {
         hd_print(__METHOD__);
         // fwrite($this->fileDescriptor, "c|$fileName|$fileUrl");
         $file_path = "/persistfs/plugins_archive/emplexer/emplexer_default_archive/{$fileName}";
         // $file_path = "/D/emplexer/emplexer_default_archive/$fileName";
         if (!file_exists($file_path)) {
             //$this->open();
             // exec("echo 'c|$fileName|$fileUrl' > /tmp/emplexer.fifo");
             //fwrite($this->fileDescriptor, "c|$fileName|$fileUrl\n");
             //hd_print(__METHOD__ . " Escrevi com c|$fileName|$fileUrl" );
             $opts = array(CURLOPT_BINARYTRANSFER => true, CURLOPT_HEADER => false);
             $doc = HD::http_get_document($fileUrl, $opts);
             $file = fopen($file_path, 'x');
             fwrite($file, $doc);
             fclose($file);
             unset($doc);
             $doc = null;
         }
     }
 }
Example #14
0
 /**
  * 运行HD框架产品 
  */
 public static function run()
 {
     if (self::$is_run) {
         return;
     }
     self::$is_run = true;
     self::$compile = defined("COMPILE") ? COMPILE : true;
     self::Definition();
     //配置系统常量
     self::$boot = PATH_TEMP . '/boot.php';
     //核心编译文件
     if (self::$compile && is_file(self::$boot)) {
         require self::$boot;
         //如果编译文件存在加载核心编译文件boot.php
         application::run();
         //运行应用目录下的项目
         return;
     }
     self::compileCoreFile();
     //编译生成核心文件boot.php
     application::run();
     //运行应用目录下的项目
 }
 private function do_get_control_defs(&$plugin_cookies)
 {
     $defs = array();
     $user_name = isset($plugin_cookies->user_name) ? $plugin_cookies->user_name : '';
     $logged_in = $this->session->is_logged_in();
     hd_print('Packet name: ' . ($logged_in ? $this->session->get_account()->packet_name : 'unset'));
     if ($user_name === '') {
         $login_str = 'unset';
     } else {
         if (!$logged_in || !isset($this->session->get_account()->packet_name)) {
             $login_str = $user_name;
         } else {
             $login_str = $user_name . ' (' . $this->session->get_account()->packet_name . ')';
         }
     }
     hd_print('Packet expire: ' . ($logged_in ? $this->session->get_account()->packet_expire : 'unset'));
     if (!$logged_in || !isset($this->session->get_account()->packet_expire) || $this->session->get_account()->packet_expire <= 0) {
         $expires_str = 'not available';
     } else {
         $tm = $this->session->get_account()->packet_expire;
         $expires_str = HD::format_date_time_date($tm) . ', ' . HD::format_date_time_time($tm);
     }
     $this->add_label($defs, 'Subscription:', $login_str);
     $this->add_label($defs, 'Expires:', $expires_str);
     $this->add_button($defs, 'edit_subscription', null, 'Edit Subscription...', 0);
     $settings = $this->session->get_settings();
     $stream_server_caption = 'not available';
     $bitrate_caption = 'not available';
     $http_caching_caption = 'not available';
     $timeshift_caption = 'not available';
     if (isset($settings)) {
         $stream_server = $settings->stream_server->value;
         foreach ($settings->stream_server->list as $pair) {
             if ($pair->ip === $stream_server) {
                 $stream_server_caption = $pair->descr;
                 break;
             }
         }
         $bitrate = $settings->bitrate->value;
         $bitrate_caption = $bitrate;
         $http_caching = $settings->http_caching->value;
         $http_caching_caption = $this->get_http_caching_caption($http_caching);
         $timeshift = $settings->timeshift->value;
         $timeshift_caption = $timeshift;
     }
     if ($logged_in) {
         $this->add_button($defs, 'edit_pcode', 'Code for protected channels:', 'Edit...', 0);
         $stream_server_ops = array();
         foreach ($settings->stream_server->list as $pair) {
             $stream_server_ops[$pair->ip] = $pair->descr;
         }
         $this->add_combobox($defs, 'stream_server', 'Streaming server:', $stream_server, $stream_server_ops, 0, true);
         $bitrate_ops = array();
         foreach ($settings->bitrate->list as $v) {
             $bitrate_ops[$v] = $v;
         }
         $this->add_combobox($defs, 'bitrate', 'Bitrate:', $bitrate, $bitrate_ops, 0, true);
         $http_caching_ops = array();
         foreach ($settings->http_caching->{'0'} as $v) {
             $http_caching_ops[$v] = $this->get_http_caching_caption($v);
         }
         $this->add_combobox($defs, 'http_caching', 'Buffering period:', $http_caching, $http_caching_ops, 0, true);
         $timeshift_ops = array();
         foreach ($settings->timeshift->list as $v) {
             $timeshift_ops[$v] = $v;
         }
         $this->add_combobox($defs, 'timeshift', 'Time shift (hours):', $timeshift, $timeshift_ops, 0, true);
     } else {
         $this->add_label($defs, 'Code for protected channels:', 'not available');
         $this->add_label($defs, 'Streaming server:', $stream_server_caption);
         $this->add_label($defs, 'Bitrate:', $bitrate_caption);
         $this->add_label($defs, 'Buffering period:', $http_caching_caption);
         $this->add_label($defs, 'Time shift (hours):', $timeshift_caption);
     }
     if (isset($plugin_cookies->show_in_main_screen)) {
         $show_in_main_screen = $plugin_cookies->show_in_main_screen;
     } else {
         $show_in_main_screen = 'auto';
     }
     $show_ops = array();
     $show_ops['auto'] = 'Auto';
     $show_ops['yes'] = 'Yes';
     $show_ops['no'] = 'No';
     $this->add_combobox($defs, 'show_in_main_screen', 'Show in main screen:', $show_in_main_screen, $show_ops, 0, true);
     return $defs;
 }
Example #16
0
 public function get($key)
 {
     return HD::get_map_element($this->map, $key);
 }
 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);
         }
     }
 }
Example #18
0
 public static function get_epg($media_id, $limit, $start, $stop)
 {
     hd_print("API: method 'get_epg'");
     return HD::make_json_rpc_request('get_epg', array('media_id' => $media_id, 'limit' => $limit, 'start' => SWRNApi::format_timestamp($start), 'stop' => SWRNApi::format_timestamp($stop)));
 }
 private function fetch_document($url)
 {
     $doc = HD::http_get_document($url, $this->http_opts);
     // assert($doc != null).
     return $doc;
 }
Example #20
0
 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);
 }
 /**
  * make the platlist and save on plugin/www
  */
 protected function makePlayList($musics)
 {
     hd_print(__METHOD__ . ':' . print_r($musics, true));
     $file = '/tmp/www/plugins/emplexer/emplexer_playlist.m3u';
     $m3u = fopen($file, 'w');
     fwrite($m3u, "#EXTM3U\n");
     $count = 0;
     foreach ($musics as $key => $value) {
         $count++;
         fwrite($m3u, "#EXTINF:{$count}, {$key}\n");
         fwrite($m3u, "{$value}\n");
     }
     fclose($m3u);
     $playlistUrl = "http://127.0.0.1/plugins/emplexer/emplexer_playlist.m3u";
     //logo a playlist só pra efeito de posterior debug
     hd_print(__METHOD__ . (print HD::http_get_document($playlistUrl, true)));
     return $playlistUrl;
 }
 public function get_folder_range(MediaURL $media_url, $from_ndx, &$plugin_cookies)
 {
     return HD::create_regular_folder_range($this->get_all_folder_items($media_url, &$plugin_cookies));
 }
Example #23
0
 public static function getAndParseXmlFromUrl($url)
 {
     $time_start = microtime(true);
     $get_start = microtime(true);
     $doc = HD::http_get_document($url);
     $get_end = microtime(true);
     $parse_start = microtime(true);
     $xml = HD::parse_xml_document($doc);
     $parse_end = microtime(true);
     $time_end = microtime(true);
     $time = $time_end - $time_start;
     $get_time = $get_end - $get_start;
     $parse_time = $parse_end - $parse_start;
     hd_print(__METHOD__ . ':' . " xml obtained in {$get_time} seconds and parsed in {$parse_time} seconds total ={$time}");
     return $xml;
 }
 public function handle_user_input(&$user_input, &$plugin_cookies)
 {
     if (!isset($user_input->control_id)) {
         if ($plugin_cookies->require_restart) {
             ZTVDaemonController::restart($plugin_cookies->use_proxy == 'yes' ? array('-y' => $plugin_cookies->proxy_ip . ':' . $plugin_cookies->proxy_port) : array());
             $plugin_cookies->require_restart = false;
         }
         if (!ZTVTerminal::login()) {
             return ActionFactory::show_dialog('Введите регистрационные данные', $this->do_registration_form_defs($plugin_cookies), true);
         }
         $result = $this->load_profiles();
         if ($result) {
             if ($this->profile->require_password) {
                 return ActionFactory::show_dialog('Введите пароль профиля ' . $this->profile->title, $this->do_profile_form_defs($plugin_cookies, false), true);
             }
             return ActionFactory::open_folder();
         }
         return;
     } else {
         if ($user_input->action_type == 'confirm' || $user_input->action_type == 'apply') {
             switch ($user_input->control_id) {
                 case 'use_proxy':
                     $plugin_cookies->use_proxy = $user_input->use_proxy;
                     $plugin_cookies->proxy_ip = isset($plugin_cookies->proxy_ip) ? $plugin_cookies->proxy_ip : '192.168.0.1';
                     $plugin_cookies->proxy_port = isset($plugin_cookies->proxy_port) ? $plugin_cookies->proxy_port : '8080';
                     $plugin_cookies->require_restart = true;
                     break;
                 case 'proxy_ip':
                     $plugin_cookies->proxy_ip = $user_input->proxy_ip;
                     $plugin_cookies->require_restart = true;
                     break;
                 case 'proxy_port':
                     $plugin_cookies->proxy_port = $user_input->proxy_port;
                     $plugin_cookies->require_restart = true;
                     break;
                 case 'daemon_start_button':
                     ZTVDaemonController::start($plugin_cookies->use_proxy == 'yes' ? array('-y' => $plugin_cookies->proxy_ip . ':' . $plugin_cookies->proxy_port) : array());
                     break;
                 case 'daemon_restart_button':
                     ZTVDaemonController::restart($plugin_cookies->use_proxy == 'yes' ? array('-y' => $plugin_cookies->proxy_ip . ':' . $plugin_cookies->proxy_port) : array());
                     break;
                 case 'daemon_stop_button':
                     ZTVDaemonController::stop();
                     break;
                 case 'register_button':
                     return ActionFactory::show_dialog('Введите регистрационные данные', $this->do_registration_form_defs($plugin_cookies), true);
                     break;
                 case 'register_terminal':
                     if (is_null($user_input->username) || trim($user_input->username) === '') {
                         return ActionFactory::show_error(false, 'Ошибка', array('Идентификатор не может быть пустым.'));
                     } else {
                         if (is_null($user_input->password) || trim($user_input->password) === '') {
                             return ActionFactory::show_error(false, 'Ошибка', array('PIN-код не может быть пустым.'));
                         }
                     }
                     if (!ZTVTerminal::register($user_input->username, $user_input->password)) {
                         return ActionFactory::show_error(false, 'Ошибка', array('Неверный идентификатор или PIN-код.'));
                     }
                     $plugin_cookies->username = $user_input->username;
                     $plugin_cookies->password = $user_input->password;
                     if ($user_input->selected_media_url == 'setup') {
                         return ActionFactory::close_dialog_and_run(ActionFactory::show_title_dialog('Вход выполнен.'));
                     }
                     return ActionFactory::close_dialog_and_run(ActionFactory::open_folder());
                     break;
                 case 'deregister_terminal':
                     if (ZTVTerminal::deregister() && $user_input->selected_media_url == 'setup') {
                         return ActionFactory::close_dialog_and_run(ActionFactory::show_title_dialog('Выход выполнен.'));
                     }
                     return ActionFactory::show_error(false, 'Ошибка', array('Не удалось выполненить выход.'));
                     break;
                 case 'register_cancel':
                     if (ZTVTerminal::login() && $user_input->selected_media_url != 'setup') {
                         return ActionFactory::close_dialog_and_run(ActionFactory::open_folder());
                     }
                     return ActionFactory::reset_controls($this->do_registration_form_defs($plugin_cookies));
                     break;
                 case 'profile':
                     $this->profile = $this->profiles[$user_input->profile];
                     if ($this->profile->require_password) {
                         return ActionFactory::show_dialog('Введите пароль профиля ' . $this->profile->title, $this->do_profile_form_defs($plugin_cookies, $this->profile->require_password && !$this->profile->password), true);
                     }
                     if ($this->tv->set_profile($this->profile->id)) {
                         return ActionFactory::show_title_dialog('Профиль успешно установлен');
                     }
                     break;
                 case 'set_profile_password':
                     if (!$user_input->profile_password) {
                         return ActionFactory::show_error(false, 'Ошибка', array('Пароль не задан.'));
                     }
                     if ($user_input->profile_password != $user_input->profile_password_repeat) {
                         return ActionFactory::show_error(false, 'Ошибка', array('Введенные пароли не совпадают.'));
                     }
                     $result = $this->tv->api_call(array(HD::make_json_rpc_request('set_terminal_params', array('macaddr' => HD::get_mac_addr_dashed(), 'profile_id' => $this->profile->id)), HD::make_json_rpc_request('update_profile', array('macaddr' => HD::get_mac_addr_dashed(), 'profile_id' => $this->profile->id, 'profile_password' => $user_input->profile_password))));
                     if (count($result) == 2 && $result[0]->result && $result[1]->result) {
                         return ActionFactory::close_dialog_and_run(ActionFactory::show_title_dialog('Профиль успешно установлен'));
                     }
                     return;
                     break;
                 case 'verify_profile_password':
                     if ($user_input->profile_password != $this->profile->password) {
                         return ActionFactory::show_error(false, 'Ошибка', array('Неверный пароль.'));
                     }
                     if ($user_input->selected_media_url != 'setup') {
                         return ActionFactory::close_dialog_and_run(ActionFactory::open_folder());
                     }
                     $result = $this->tv->set_profile($this->profile->id);
                     if ($result) {
                         return ActionFactory::close_dialog_and_run(ActionFactory::show_title_dialog('Профиль успешно установлен'));
                     }
                     return;
                     break;
                 case 'profile_cancel':
                     $result = $this->tv->set_profile(1);
                     if (!$result) {
                         return;
                     }
                     if ($user_input->selected_media_url != 'setup') {
                         return ActionFactory::close_dialog_and_run(ActionFactory::open_folder());
                     }
                     $this->profile = $this->profiles[1];
                     return ActionFactory::close_dialog_and_run(ActionFactory::show_title_dialog('Установлен профиль по умолчанию(' . $this->profile->title . ')'));
                     break;
             }
         }
     }
     return ActionFactory::reset_controls($this->do_get_control_defs($plugin_cookies));
 }
Example #25
0
 public static function update_profile(stdClass $profile, $profile_password)
 {
     hd_print("API: method 'update_profile'");
     return HD::make_json_rpc_request('update_profile', array('macaddr' => ZTVApi::get_mac_addr(), 'profile_id' => $profile->id, 'profile_password' => $profile_password));
 }
Example #26
0
<?php

define('APP_GROUP', 'web');
define('COMPILE', FALSE);
include './hdphp/hdphp.php';
HD::run();
Example #27
0
 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;
 }
Example #28
-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;
 }