public function handle_user_input(&$user_input, &$plugin_cookies)
 {
     hd_print('Vod favorites: handle_user_input:');
     foreach ($user_input as $key => $value) {
         hd_print("  {$key} => {$value}");
     }
     if ($user_input->control_id == 'popup_menu') {
         if (!isset($user_input->selected_media_url)) {
             return null;
         }
         $media_url = MediaURL::decode($user_input->selected_media_url);
         $movie_id = $media_url->movie_id;
         $is_favorite = $this->vod->is_favorite_movie_id($movie_id);
         $add_favorite_action = UserInputHandlerRegistry::create_action($this, 'add_favorite');
         $caption = 'Add to My Movies';
         $menu_items[] = array(GuiMenuItemDef::caption => $caption, GuiMenuItemDef::action => $add_favorite_action);
         return ActionFactory::show_popup_menu($menu_items);
     } else {
         if ($user_input->control_id == 'add_favorite') {
             if (!isset($user_input->selected_media_url)) {
                 return null;
             }
             $media_url = MediaURL::decode($user_input->selected_media_url);
             $movie_id = $media_url->movie_id;
             $is_favorite = $this->vod->is_favorite_movie_id($movie_id);
             if ($is_favorite) {
                 return ActionFactory::show_title_dialog('Movie already resides in My Movies');
             } else {
                 $this->vod->add_favorite_movie($movie_id, $plugin_cookies);
                 return ActionFactory::show_title_dialog('Movie has been added to My Movies');
             }
         }
     }
     return null;
 }
 public function handle_user_input(&$user_input, &$plugin_cookies)
 {
     hd_print('Vod search: handle_user_input:');
     foreach ($user_input as $key => $value) {
         hd_print("  {$key} => {$value}");
     }
     if ($user_input->action_type === 'apply') {
         $control_id = $user_input->control_id;
         if ($control_id === 'pattern') {
             $pattern = $user_input->pattern;
             $plugin_cookies->vod_search_pattern = $pattern;
             hd_print("Vod search: applying pattern '{$pattern}'");
             $defs = $this->do_get_control_defs($plugin_cookies);
             return ActionFactory::reset_controls($defs, ActionFactory::open_folder($this->vod->get_search_media_url_str($pattern), $pattern));
         }
     } else {
         if ($user_input->action_type === 'confirm') {
             $control_id = $user_input->control_id;
             $new_value = $user_input->{$control_id};
             if ($control_id === 'pattern') {
                 $pattern = $user_input->pattern;
                 if (preg_match('/^\\s*$/', $pattern)) {
                     return ActionFactory::show_error(false, 'Pattern should not be empty');
                 }
             }
         }
     }
     return null;
 }
Ejemplo n.º 3
0
 public function set_default($key, $value)
 {
     if (!isset($this->data[$key])) {
         hd_print("Warning: no value for key '{$key}'. Using default: '{$value}'");
         $this->data[$key] = $value;
     }
 }
 public function handle_user_input(&$user_input, &$plugin_cookies)
 {
     hd_print('Entry handler: handle_user_input:');
     foreach ($user_input as $key => $value) {
         hd_print("  {$key} => {$value}");
     }
     if (!isset($user_input->entry_id)) {
         return null;
     }
     $add_params = array('entry_id' => $user_input->entry_id);
     if ($user_input->entry_id === 'setup' || $user_input->entry_id === 'tv') {
         $res = $this->session->apply_subscription($plugin_cookies, $user_input);
         if ($res !== false) {
             if (!isset($res['action'])) {
                 return ActionFactory::close_dialog_and_run(ActionFactory::open_folder());
             }
             return $res['need_close_dialog'] ? ActionFactory::close_dialog_and_run($res['action']) : $res['action'];
         } else {
             if ($this->session->is_logged_in()) {
                 return ActionFactory::open_folder();
             }
             if (!isset($plugin_cookies->user_name) || $plugin_cookies->user_name === '') {
                 return $this->session->do_get_edit_subscription_action($plugin_cookies, $this, $add_params);
             }
             return ActionFactory::open_folder();
         }
     }
     return null;
 }
Ejemplo n.º 5
0
function hd_error_handler($error_type, $message, $file, $line)
{
    static $map = array(E_ERROR => 'E_ERROR', E_WARNING => 'E_WARNING', E_PARSE => 'E_PARSE', E_NOTICE => 'E_NOTICE', E_CORE_ERROR => 'E_CORE_ERROR', E_CORE_WARNING => 'E_CORE_WARNING', E_COMPILE_ERROR => 'E_COMPILE_ERROR', E_COMPILE_WARNING => 'E_COMPILE_WARNING', E_USER_ERROR => 'E_USER_ERROR', E_USER_WARNING => 'E_USER_WARNING', E_USER_NOTICE => 'E_USER_NOTICE', E_STRICT => 'E_STRICT', E_RECOVERABLE_ERROR => 'E_RECOVERABLE_ERROR', E_DEPRECATED => 'E_DEPRECATED', E_USER_DEPRECATED => 'E_USER_DEPRECATED');
    if (isset($map[$error_type])) {
        hd_print("[{$file}:{$line}] [{$map[$error_type]}] {$message}");
    }
}
 protected function call_plugin_impl($call_ctx)
 {
     static $plugin;
     if (is_null($plugin)) {
         try {
             hd_print('Instantiating plugin...');
             $plugin = $this->create_plugin();
             hd_print('Plugin instance created.');
         } catch (Exception $e) {
             hd_print('Error: can not instantiate plugin (' . $e->getMessage() . ')');
             return array(PluginOutputData::has_data => false, PluginOutputData::plugin_cookies => $call_ctx->plugin_cookies, PluginOutputData::is_error => true, PluginOutputData::error_action => ActionFactory::show_error(true, T::t('title_application_error'), array(T::t('msg_plugin_init_failed'))));
         }
     }
     $out_data = null;
     try {
         $out_data = $this->invoke_operation($plugin, $call_ctx);
     } catch (DuneException $e) {
         hd_print("Error: DuneException caught: " . $e->getMessage());
         return array(PluginOutputData::has_data => false, PluginOutputData::plugin_cookies => $call_ctx->plugin_cookies, PluginOutputData::is_error => true, PluginOutputData::error_action => $e->get_error_action());
     } catch (Exception $e) {
         hd_print("Error: Exception caught: " . $e->getMessage());
         return array(PluginOutputData::has_data => false, PluginOutputData::plugin_cookies => $call_ctx->plugin_cookies, PluginOutputData::is_error => true, PluginOutputData::error_action => ActionFactory::show_error(true, T::t('title_application_error'), array(T::t('msg_unhandled_plugin_error'))));
     }
     $plugin_output_data = array(PluginOutputData::has_data => !is_null($out_data), PluginOutputData::plugin_cookies => $call_ctx->plugin_cookies, PluginOutputData::is_error => false, PluginOutputData::error_action => null);
     if ($plugin_output_data[PluginOutputData::has_data]) {
         $plugin_output_data[PluginOutputData::data_type] = $this->get_out_type_code($call_ctx->op_type_code);
         $plugin_output_data[PluginOutputData::data] = $out_data;
     }
     return $plugin_output_data;
 }
 protected function call_plugin_impl($call_ctx)
 {
     static $plugin;
     if (is_null($plugin)) {
         try {
             hd_print('Instantiating plugin...');
             $plugin = $this->create_plugin();
             hd_print('Plugin instance created.');
         } catch (Exception $e) {
             hd_print('Error: can not instantiate plugin (' . $e->getMessage() . ')');
             return array(PluginOutputData::has_data => false, PluginOutputData::plugin_cookies => $call_ctx->plugin_cookies, PluginOutputData::is_error => true, PluginOutputData::error_action => ActionFactory::show_error(true, 'System error', array('Can not create PHP plugin instance.', 'Call the PHP plugin vendor.')));
         }
     }
     // assert($plugin);
     $out_data = null;
     try {
         $out_data = $this->invoke_operation($plugin, $call_ctx);
     } catch (DuneException $e) {
         hd_print("Error: DuneException caught: " . $e->getMessage());
         return array(PluginOutputData::has_data => false, PluginOutputData::plugin_cookies => $call_ctx->plugin_cookies, PluginOutputData::is_error => true, PluginOutputData::error_action => $e->get_error_action());
     } catch (Exception $e) {
         hd_print("Error: Exception caught: " . $e->getMessage());
         return array(PluginOutputData::has_data => false, PluginOutputData::plugin_cookies => $call_ctx->plugin_cookies, PluginOutputData::is_error => true, PluginOutputData::error_action => ActionFactory::show_error(true, 'System error', array('Unhandled PHP plugin error.', 'Call the PHP plugin vendor.')));
     }
     // Note: change_tv_favorites() may return NULL even if it's completed
     // successfully.
     $plugin_output_data = array(PluginOutputData::has_data => !is_null($out_data), PluginOutputData::plugin_cookies => $call_ctx->plugin_cookies, PluginOutputData::is_error => false, PluginOutputData::error_action => null);
     if ($plugin_output_data[PluginOutputData::has_data]) {
         $plugin_output_data[PluginOutputData::data_type] = $this->get_out_type_code($call_ctx->op_type_code);
         $plugin_output_data[PluginOutputData::data] = $out_data;
     }
     return $plugin_output_data;
 }
Ejemplo n.º 8
0
 protected function get_screen_by_id($screen_id)
 {
     if (isset($this->screens[$screen_id])) {
         return $this->screens[$screen_id];
     }
     hd_print("Error: no screen with id '{$screen_id}' found.");
     throw new Exception('Screen not found');
 }
Ejemplo n.º 9
0
 public function handle_user_input(&$user_input, &$plugin_cookies)
 {
     // hd_print(__METHOD__);
     hd_print(print_r($user_input, true));
     $media_url = MediaURL::decode($user_input->selected_media_url);
     if ($user_input->control_id == 'pop_up') {
     }
 }
 public function __set($name, $value)
 {
     $this->{$name} = $value;
     hd_print("{$name}={$name} value=" . is_array($value) ? print_r($value, true) : $value);
     if ($name == "folder_views") {
         hd_print("folder_view");
         $this->set_default_folder_view_index_attr_name();
     }
 }
Ejemplo n.º 11
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;
 }
Ejemplo n.º 12
0
 public function getDetailedInfo(SimpleXMLElement &$node)
 {
     hd_print(__METHOD__);
     $info = (string) $node->attributes()->title;
     // 'Serie:' . (string)$c->attributes()->grandparentTitle . ' || ' .
     // 'Episode Name :' . (string)$c->attributes()->title. ' || ' .
     // 'EP:'  . 'S'.(string)$c->attributes()->parentIndex . 'E'. (string)$c->attributes()->index . '||' .
     // 'summary:'. str_replace('"', '' , (string)$c->attributes()->summary);
     return $info;
 }
 private static function run($op, $args = array())
 {
     $cmd = dirname(__FILE__) . self::ARESCAM_CTL . ' ' . $op;
     foreach ($args as $name => $value) {
         $value = escapeshellarg($value);
         $cmd .= " {$name} {$value}";
     }
     $out = system($cmd, $rc);
     hd_print("DAEMON: cmd '{$cmd}'; rc {$rc}; output '{$out}'");
     return (object) array('output' => $out, 'rc' => $rc);
 }
Ejemplo n.º 14
0
 public function get_out_type_code($op_code)
 {
     static $map = null;
     if (is_null($map)) {
         $map = array(PLUGIN_OP_GET_FOLDER_VIEW => PLUGIN_OUT_DATA_PLUGIN_FOLDER_VIEW, PLUGIN_OP_GET_NEXT_FOLDER_VIEW => PLUGIN_OUT_DATA_PLUGIN_FOLDER_VIEW, PLUGIN_OP_GET_REGULAR_FOLDER_ITEMS => PLUGIN_OUT_DATA_PLUGIN_REGULAR_FOLDER_RANGE, PLUGIN_OP_HANDLE_USER_INPUT => PLUGIN_OUT_DATA_GUI_ACTION, PLUGIN_OP_GET_TV_INFO => PLUGIN_OUT_DATA_PLUGIN_TV_INFO, PLUGIN_OP_GET_DAY_EPG => PLUGIN_OUT_DATA_PLUGIN_TV_EPG_PROGRAM_LIST, PLUGIN_OP_GET_TV_PLAYBACK_URL => PLUGIN_OUT_DATA_URL, PLUGIN_OP_GET_TV_STREAM_URL => PLUGIN_OUT_DATA_URL, PLUGIN_OP_GET_VOD_INFO => PLUGIN_OUT_DATA_PLUGIN_VOD_INFO, PLUGIN_OP_GET_VOD_STREAM_URL => PLUGIN_OUT_DATA_URL, PLUGIN_OP_CHANGE_TV_FAVORITES => PLUGIN_OUT_DATA_GUI_ACTION);
     }
     if (!isset($map[$op_code])) {
         hd_print("Error: get_out_type_code(): unknown operation code: '{$op_code}'.");
         throw new Exception("Uknown operation code");
     }
     return $map[$op_code];
 }
Ejemplo n.º 15
0
 public function setFileToArchive($fileName, $fileUrl)
 {
     hd_print(__METHOD__ . ': useCache = ' . EmplexerConfig::getInstance()->getUseCache());
     //no cache
     if (EmplexerConfig::getInstance()->getUseCache()) {
         // hd_print( __METHOD__ .  ': Entrou.... ' );
         //hd_print(__METHOD__ . " fileName=$fileName, fileUrl=$fileUrl");
         $this->urls[$fileName] = $fileUrl;
         EmplexerFifoController::getInstance()->downloadToCache($fileName, $fileUrl);
     } else {
         // hd_print( __METHOD__ .  ': Não Entrou.... ' . $fileUrl);
     }
 }
Ejemplo n.º 16
0
 public function handle_user_input(&$user_input, &$plugin_cookies)
 {
     hd_print('Tv favorites: handle_user_input:');
     foreach ($user_input as $key => $value) {
         hd_print("  {$key} => {$value}");
     }
     if ($user_input->control_id == 'info') {
         if (!isset($user_input->selected_media_url)) {
             return null;
         }
         $media_url = MediaURL::decode($user_input->selected_media_url);
         $channel_id = $media_url->channel_id;
         $channels = $this->tv->get_channels();
         $c = $channels->get($channel_id);
         $id = $c->get_id();
         $title = $c->get_title();
         return ActionFactory::show_title_dialog("Channel '{$title}' (id={$id})");
     } else {
         if ($user_input->control_id == 'popup_menu') {
             if (!isset($user_input->selected_media_url)) {
                 return null;
             }
             $media_url = MediaURL::decode($user_input->selected_media_url);
             $channel_id = $media_url->channel_id;
             $is_favorite = $this->tv->is_favorite_channel_id($channel_id, $plugin_cookies);
             $add_favorite_action = UserInputHandlerRegistry::create_action($this, 'add_favorite');
             $caption = 'Add to Favorites';
             $menu_items[] = array(GuiMenuItemDef::caption => $caption, GuiMenuItemDef::action => $add_favorite_action);
             return ActionFactory::show_popup_menu($menu_items);
         } else {
             if ($user_input->control_id == 'add_favorite') {
                 if (!isset($user_input->selected_media_url)) {
                     return null;
                 }
                 $media_url = MediaURL::decode($user_input->selected_media_url);
                 $channel_id = $media_url->channel_id;
                 $is_favorite = $this->tv->is_favorite_channel_id($channel_id, $plugin_cookies);
                 if ($is_favorite) {
                     return ActionFactory::show_title_dialog('Channel already resides in Favorites', $this->get_sel_item_update_action($user_input, $plugin_cookies));
                 } else {
                     $this->tv->change_tv_favorites(PLUGIN_FAVORITES_OP_ADD, $channel_id, $plugin_cookies);
                     return ActionFactory::show_title_dialog('Channel has been added to Favorites', $this->get_sel_item_update_action($user_input, $plugin_cookies));
                 }
             }
         }
     }
     return null;
 }
Ejemplo n.º 17
0
 private function addNextToChunk($chunckArray, $currentChunk, $index)
 {
     hd_print(__METHOD__);
     // hd_print('chunckArray =' . print_r($chunckArray, true));
     // hd_print('currentChunk =' . print_r($currentChunk, true));
     // hd_print('index =' . print_r($index, true));
     if ($index >= count($chunckArray)) {
         hd_print('é maior' . print_r($currentChunk, true));
         return $currentChunk;
     } else {
         hd_print('Não é maior');
     }
     $currentChunk[] = $chunckArray[$index];
     $currentChunk[] = array(GuiMenuItemDef::is_separator => true);
     $currentChunk[] = array(GuiMenuItemDef::caption => $this->nextText, GuiMenuItemDef::action => ActionFactory::show_popup_menu($this->addNextToChunk($chunckArray, $currentChunk, $index + 1)));
 }
Ejemplo n.º 18
0
 public static function deregister()
 {
     if (!self::$_logged_in) {
         return false;
     }
     $result = ZTVDaemonController::deregister();
     if ($result->output === false) {
         hd_print('Error: can not execute arescam.');
         throw new DuneException('%tr%caption_system_error', 0, ActionFactory::show_error(true, '%tr%caption_system_error', array('%tr%error_daemon_execution_failed', '%tr%error_contact_support')));
     }
     if ($result->rc === 0) {
         self::$_logged_in = false;
         self::$_login_expire = 0;
         return true;
     }
     return false;
 }
Ejemplo n.º 19
0
 public function handle_user_input(&$user_input, &$plugin_cookies)
 {
     hd_print('Vod favorites: handle_user_input:');
     foreach ($user_input as $key => $value) {
         hd_print("  {$key} => {$value}");
     }
     if ($user_input->control_id == 'remove_favorite') {
         if (!isset($user_input->selected_media_url)) {
             return null;
         }
         $media_url = MediaURL::decode($user_input->selected_media_url);
         $movie_id = $media_url->movie_id;
         $this->vod->remove_favorite_movie($movie_id, $plugin_cookies);
         return ActionFactory::invalidate_folders(array(self::get_media_url_str($movie_id)));
     }
     return null;
 }
Ejemplo n.º 20
0
 public function get_tv_info(MediaURL $media_url, &$plugin_cookies)
 {
     $this->ensure_channels_loaded($plugin_cookies);
     $channels = array();
     foreach ($this->get_groups() as $g) {
         hd_print('DEBUG: group ' . $g->get_id());
     }
     foreach ($this->get_channels() as $c) {
         $group_id_arr = array();
         if ($this->mode == self::MODE_CHANNELS_N_TO_M) {
             $group_id_arr[] = $this->get_all_channel_group_id();
         }
         foreach ($c->get_groups() as $g) {
             $group_id_arr[] = $g->get_id();
         }
         array_push($channels, array(PluginTvChannel::id => $c->get_id(), PluginTvChannel::caption => $c->get_title(), PluginTvChannel::group_ids => $group_id_arr, PluginTvChannel::icon_url => $c->get_icon_url(), PluginTvChannel::number => $c->get_number(), PluginTvChannel::have_archive => $c->has_archive(), PluginTvChannel::is_protected => $c->is_protected(), PluginTvChannel::past_epg_days => intval($c->get_past_epg_days()), PluginTvChannel::future_epg_days => intval($c->get_future_epg_days()), PluginTvChannel::archive_past_sec => intval($c->get_archive_past_sec()), PluginTvChannel::archive_delay_sec => intval($c->get_archive_delay_sec()), PluginTvChannel::buffering_ms => intval($c->get_buffering_ms()), PluginTvChannel::timeshift_hours => intval($c->get_timeshift_hours()), PluginTvChannel::playback_url_is_stream_url => $this->playback_url_is_stream_url));
     }
     $groups = array();
     foreach ($this->get_groups() as $g) {
         if ($g->is_favorite_channels()) {
             continue;
         }
         if ($this->mode == self::MODE_CHANNELS_1_TO_N && $g->is_all_channels()) {
             continue;
         }
         array_push($groups, array(PluginTvGroup::id => $g->get_id(), PluginTvGroup::caption => $g->get_title(), PluginTvGroup::icon_url => $g->get_icon_url()));
     }
     $is_favorite_group = isset($media_url->is_favorites);
     $initial_group_id = strval($media_url->group_id);
     $initial_is_favorite = 0;
     if ($is_favorite_group) {
         $initial_group_id = null;
         $initial_is_favorite = 1;
     }
     if ($this->mode == self::MODE_CHANNELS_1_TO_N && $initial_group_id === $this->get_all_channel_group_id()) {
         $initial_group_id = null;
     }
     $fav_channel_ids = null;
     if ($this->is_favorites_supported()) {
         $fav_channel_ids = $this->get_fav_channel_ids($plugin_cookies);
     }
     $archive = $this->get_archive($media_url);
     $archive_def = is_null($archive) ? null : $archive->get_archive_def();
     return array(PluginTvInfo::show_group_channels_only => $this->mode, PluginTvInfo::groups => $groups, PluginTvInfo::channels => $channels, PluginTvInfo::favorites_supported => $this->is_favorites_supported(), PluginTvInfo::favorites_icon_url => strval($this->get_fav_icon_url()), PluginTvInfo::initial_channel_id => strval($media_url->channel_id), PluginTvInfo::initial_group_id => $initial_group_id, PluginTvInfo::initial_is_favorite => $initial_is_favorite, PluginTvInfo::favorite_channel_ids => $fav_channel_ids, PluginTvInfo::archive => $archive_def);
 }
Ejemplo n.º 21
0
 public function handle_user_input(&$user_input, &$plugin_cookies)
 {
     hd_print('Vod genres: handle_user_input:');
     foreach ($user_input as $key => $value) {
         hd_print("  {$key} => {$value}");
     }
     if ($user_input->control_id == 'select_genre') {
         if (!isset($user_input->selected_media_url)) {
             return null;
         }
         $media_url = MediaURL::decode($user_input->selected_media_url);
         $genre_id = $media_url->genre_id;
         $caption = $this->vod->get_genre_caption($genre_id);
         $media_url_str = $this->vod->get_genre_media_url_str($genre_id);
         return ActionFactory::open_folder($media_url_str, $caption);
     }
     return null;
 }
Ejemplo n.º 22
0
 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 handle_user_input(&$user_input, &$plugin_cookies)
 {
     hd_print('Movie: handle_user_input:');
     foreach ($user_input as $key => $value) {
         hd_print("  {$key} => {$value}");
     }
     if ($user_input->control_id == 'favorites') {
         $movie_id = $user_input->movie_id;
         $is_favorite = $this->vod->is_favorite_movie_id($movie_id);
         if ($is_favorite) {
             $this->vod->remove_favorite_movie($movie_id, $plugin_cookies);
         } else {
             $this->vod->add_favorite_movie($movie_id, $plugin_cookies);
         }
         $message = $is_favorite ? 'Movie has been removed from My Movies' : 'Movie has been added to My Movies';
         return ActionFactory::show_title_dialog($message, ActionFactory::invalidate_folders(array(self::get_media_url_str($movie_id), VodFavoritesScreen::get_media_url_str())));
     }
     return null;
 }
Ejemplo n.º 24
0
 protected function load_favorites(&$plugin_cookies)
 {
     $doc = $this->session->api_vod_favlist();
     if (!isset($doc->total)) {
         throw new Exception('Invalid data returned from server');
     }
     $total = intval($doc->total);
     if ($total === 0) {
         $this->set_fav_movie_ids(array());
         return;
     }
     $fav_movie_ids = array();
     foreach ($doc->rows as $row) {
         $movie_id = $row->id;
         $movie_name = $row->name;
         $poster_url = 'http://' . KTV::$SERVER . $row->poster;
         $fav_movie_ids[] = $movie_id;
         $this->set_cached_short_movie(new ShortMovie($movie_id, $movie_name, $poster_url));
     }
     $this->set_fav_movie_ids($fav_movie_ids);
     hd_print('The ' . count($fav_movie_ids) . ' favorite movies loaded.');
 }
Ejemplo n.º 25
0
 protected function load_channels(&$plugin_cookies)
 {
     $this->session->check_logged_in();
     $settings = $this->session->get_settings();
     $buffering_ms = $settings->http_caching->value;
     $default_timeshift_hours = $settings->timeshift->value;
     $this->channels = new HashedArray();
     $this->groups = new HashedArray();
     $this->groups->put(new FavoritesGroup($this, '__favorites', 'Избранное', $this->session->get_icon('favorites.png')));
     $this->groups->put(new AllChannelsGroup($this, 'Все каналы', $this->session->get_icon('all.png')));
     $num_groups = 0;
     $num_channels = 0;
     $num_protected = 0;
     $num_have_archive = 0;
     foreach ($this->session->get_channel_list()->groups as $g) {
         $ktv_group = new DefaultGroup($g->id, $g->name, $this->session->get_group_icon($g->id));
         $this->groups->put($ktv_group);
         $num_groups++;
         foreach ($g->channels as $c) {
             $have_archive = isset($c->have_archive) ? $c->have_archive == 1 : false;
             $is_protected = isset($c->protected) ? $c->protected == 1 : false;
             // TODO: timeshift
             $timeshift_hours = 0;
             $ktv_channel = new KtvChannel($c->id, $c->name, $this->session->get_channel_icon($c->id), $have_archive, $is_protected, $buffering_ms, $timeshift_hours);
             $this->channels->put($ktv_channel);
             $ktv_channel->add_group($ktv_group);
             $ktv_group->add_channel($ktv_channel);
             $num_channels++;
             if ($is_protected) {
                 $num_protected++;
             }
             if ($have_archive) {
                 $num_have_archive++;
             }
         }
     }
     hd_print("KTV: {$num_groups} groups and " . "{$num_channels} channels ({$num_have_archive} have archive, " . "{$num_protected} protected)");
 }
Ejemplo n.º 26
0
 public function get_vod_info($media_url_str, &$plugin_cookies)
 {
     // hd_print(print_r(debug_backtrace(), true));
     HD::print_backtrace();
     $media_url = MediaURL::decode($media_url_str);
     hd_print(__METHOD__ . ': ' . print_r($media_url, true));
     if ($media_url->screen_id == 'emplexer_base_channel') {
         $toPlay = $media_url->video_media_array[$plugin_cookies->channel_selected_index];
         return EmplexerBaseChannel::get_vod_info($toPlay);
     }
     if ($media_url->screen_id == 'vod_movie') {
         return $this->vod->get_vod_info($media_url, $plugin_cookies);
         // EmplexerVod::get_vod_info($media_url, $plugin_cookies);
     }
     $handler = $media_url->back_screen_id == EmplexerVideoList::ID ? EmplexerVideoList::ID : EmplexerMovieList::ID;
     $params = array('key' => $media_url->key, 'back_screen_id' => $media_url->back_screen_id, 'back_key' => $media_url->back_key, 'back_filter_name' => $media_url->back_filter_name);
     $stop_action = UserInputHandlerRegistry::create_action($this->get_screen_by_id($handler), 'stop', $params);
     $time_action = UserInputHandlerRegistry::create_action($this->get_screen_by_id($handler), 'time', $params);
     $series_array = array();
     $series_array[] = array(PluginVodSeriesInfo::name => $media_url->title, PluginVodSeriesInfo::playback_url => $media_url->video_url, PluginVodSeriesInfo::playback_url_is_stream_url => true);
     $toBeReturned = array(PluginVodInfo::id => $media_url->movie_id, PluginVodInfo::series => $series_array, PluginVodInfo::name => $media_url->name, PluginVodInfo::description => $media_url->summary, PluginVodInfo::poster_url => $media_url->thumb, PluginVodInfo::initial_series_ndx => 0, PluginVodInfo::buffering_ms => 3000, PluginVodInfo::initial_position_ms => EmplexerVideoList::$viewOffset, PluginVodInfo::advert_mode => false, PluginVodInfo::timer => array(GuiTimerDef::delay_ms => 5000), PluginVodInfo::actions => array(GUI_EVENT_PLAYBACK_STOP => $stop_action, GUI_EVENT_TIMER => $time_action));
     hd_print(print_r($toBeReturned, true));
     return $toBeReturned;
 }
Ejemplo n.º 27
0
 public function getVideoUrl(SimpleXMLElement &$node, &$plugin_cookies)
 {
     // hd_print(__METHOD__);
     $httpVidelUrl = $this->base_url . (string) $node->Part->attributes()->key;
     $nfsVideoUrl = 'nfs://' . $plugin_cookies->plexIp . ':' . (string) $node->Part->attributes()->file;
     if ($plugin_cookies->connectionMethod == 'smb') {
         $smbVideoUrl = 'smb://' . $plugin_cookies->userName . ':' . $plugin_cookies->password . '@' . $plugin_cookies->plexIp . '/' . (string) $node->Media->Part->attributes()->file;
         $videoUrl[SMB_CONNECTION_TYPE] = $smbVideoUrl;
     }
     $videoUrl[HTTP_CONNECTION_TYPE] = $httpVidelUrl;
     $videoUrl[NFS_CONNECTION_TYPE] = $nfsVideoUrl;
     $v = null;
     if ($node->Part->attributes()->file && $node->Part->attributes()->file != "") {
         $v = $videoUrl[$plugin_cookies->connectionMethod];
     } else {
         $v = $httpVidelUrl;
     }
     if (!$v) {
         hd_print('connectionMethod not setted use http as default');
         $v = $httpVidelUrl;
     }
     hd_print(__METHOD__ . ":-----------videoUrl = {$v}-----------");
     return $v;
 }
Ejemplo n.º 28
0
 public function dune_api_exception($e, $def_caption, $is_playback)
 {
     $is_ktv_error = $e instanceof KtvException;
     if (!$is_ktv_error) {
         hd_print('General exception: ' . $e->getMessage());
         $title = !$is_playback ? 'Error' : 'Failed to connect to Internet.';
         $text_lines = $is_playback ? array() : array('Failed to connect to Internet.', 'Please check Internet connection.');
         return new DuneException($def_caption, -1, ActionFactory::show_error(false, $title, $text_lines));
     }
     hd_print('Kartina.TV API exception: ' . 'code=' . $e->getCode() . ', message=' . $e->getMessage());
     $ecode = $e->getCode();
     $fatal = $ecode == 5 || $ecode == 6 || $ecode == 11 || $ecode == 12 || $ecode == 13;
     if ($fatal) {
         $this->logout();
     }
     if ($ecode == 2 || $ecode == 4) {
         $this->login_incorrect = true;
         $title = !$is_playback ? 'Error' : 'Subscription is invalid, please check settings.';
         $text_lines = $is_playback ? array() : array('Subscription is invalid, please check settings.');
         return new DuneException($def_caption, $ecode, ActionFactory::show_error($fatal, $title, $text_lines));
     }
     if ($ecode == 3) {
         $title = !$is_playback ? 'Error' : 'Access denied for 10 minutes.';
         $text_lines = $is_playback ? array() : array('Access denied for 10 minutes.');
         return new DuneException($def_caption, $ecode, ActionFactory::show_error($fatal, $title, $text_lines));
     }
     if ($ecode == 12) {
         $title = !$is_playback ? 'Error' : 'Access denied. Probably subscription is used elsewhere.';
         $text_lines = $is_playback ? array() : array('Access denied.', 'Probably subscription is used elsewhere.');
         return new DuneException($def_caption, $ecode, ActionFactory::show_error($fatal, $title, $text_lines));
     }
     if ($ecode == 11) {
         $title = !$is_playback ? 'Error' : 'Subscription is used elsewhere.';
         $text_lines = $is_playback ? array() : array('Subscription is used elsewhere.');
         return new DuneException($def_caption, $ecode, ActionFactory::show_error($fatal, $title, $text_lines));
     }
     if ($ecode == 19) {
         $title = !$is_playback ? 'Error' : 'Current code is wrong.';
         $text_lines = $is_playback ? array() : array('Current code is wrong.');
         return new DuneException($def_caption, $ecode, ActionFactory::show_error($fatal, $title, $text_lines));
     }
     $title = !$is_playback ? 'Error' : $e->getMessage();
     $text_lines = $is_playback ? array() : array('Description: ' . $e->getMessage(), 'Error code: ' . $ecode);
     return new DuneException($def_caption, $ecode, ActionFactory::show_error($fatal, $title, $text_lines));
 }
 private function get_right_media_url($type, $key, &$plugin_cookies)
 {
     hd_print(__METHOD__);
     if ($type == "movie") {
         // hd_print ("key =$key type=$type  movie");
         return EmplexerMovieList::get_media_url_str($key, isset($plugin_cookies->defaultMovieFilter) ? $plugin_cookies->defaultMovieFilter : 'all', 'movie');
     } else {
         if ($type == "artist") {
             return EmplexerMusicList::get_media_url_str("/library/sections/{$key}");
         } else {
             // hd_print ("key =$key type=$ddtype  show");
             return EmplexerRootList::get_media_url_str($key, isset($plugin_cookies->defaultShowFilter) ? $plugin_cookies->defaultShowFilter : 'all', 'show');
         }
     }
 }
Ejemplo n.º 30
0
 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);
         }
     }
 }