Example #1
0
 public function try_load_movie($movie_id, &$plugin_cookies)
 {
     // hd_print(__METHOD__  . ': ' . print_r($plugin_cookies, true)) ;
     HD::print_backtrace();
     if (!$this->base_url) {
         $this->base_url = EmplexerConfig::getInstance()->getPlexBaseUrl($plugin_cookies, $this);
     }
     $url = $this->base_url . $movie_id;
     $xml = HD::getAndParseXmlFromUrl($url);
     $movie = new Movie($movie_id);
     // $movie->set_data("American",'The American','Alone among assassins, Jack is a master craftsman. When a job in Sweden ends more harshly than expected for this American abroad, he vows to his contact Larry that his next assignment will be his last. Jack reports to the Italian countryside, where he holes up in a small town and relishes being away from death for a spell. The assignment, as specified by a Belgian woman, Mathilde, is in the offing as a weapon is constructed. Surprising himself, Jack seeks out the friendship of local priest Father Benedetto and pursues romance with local woman Clara. But by stepping out of the shadows, Jack may be tempting fate.','http://192.168.2.9:32400/library/metadata/4376/thumb/1342928192',1050,'2010','Anton Corbijn','Hiporã',
     // "George Clooney \n Jack,Thekla Reuten|Mathilde,Bruce Altman|Larry,Violante Placido|Clara|,Paolo Bonacelli|Father Benedetto",'Crime,Drama,Suspense,Thriller',6.4000000953674299,10,'R','USA','1 real');
     $grandparentTitle = (string) $xml->Video->attributes()->grandparentTitle;
     $title = $grandparentTitle ? "Episode " . (string) $xml->Video->attributes()->index . ' : ' . (string) $xml->Video->attributes()->title : (string) $xml->Video->attributes()->title;
     // (string)$xml->Video->attributes()->summary
     $movie->set_data($name = $grandparentTitle, $name_original = $title, $description = (string) $xml->Video->attributes()->summary, $poster_url = $this->base_url . '/photo/:/transcode?width=' . THUMB_WIDTH . '&height=' . THUMB_HEIGHT . '&url=' . $this->base_url . (string) $xml->Video->attributes()->thumb, $length_min = (double) $xml->Video->attributes()->duration / 1000 / 60, $year = (string) $xml->Video->attributes()->year, $directors_str = $this->geDirectorStr($xml), $scenarios_str = null, $actors_str = $this->getRolesStr($xml), $genres_str = $this->getGenreStr($xml), $rate_imdb = (double) $xml->Video->attributes()->rating, $rate_kinopoisk = null, $rate_mpaa = (string) $xml->Video->attributes()->contentRating, $country = $this->getCountryStr($xml), $budget = null);
     $tab = '     ';
     $details = array('Video' => '_', $tab . 'Bitrate' => (string) $xml->Video->Media->attributes()->bitrate, $tab . 'Width' => (string) $xml->Video->Media->attributes()->width, $tab . 'Height' => (string) $xml->Video->Media->attributes()->height, $tab . 'Aspect Ratio' => (string) $xml->Video->Media->attributes()->aspectRatio, $tab . 'Video Resolution' => (string) $xml->Video->Media->attributes()->videoResolution, $tab . 'Video Frame Rate' => (string) $xml->Video->Media->attributes()->videoFrameRate, $tab . 'Container' => (string) $xml->Video->Media->attributes()->container, $tab . 'Codec' => (string) $xml->Video->Media->attributes()->videoCodec);
     $movie->details = $details;
     $httpVidelUrl = EmplexerConfig::getInstance()->getPlexBaseUrl($plugin_cookies, $this) . (string) $xml->Video->Media->Part->attributes()->key;
     $nfsVideoUrl = 'nfs://' . $plugin_cookies->plexIp . ':' . (string) $xml->Video->Media->Part->attributes()->file;
     if ($plugin_cookies->connectionMethod == 'smb') {
         $smbVideoUrl = 'smb://' . $plugin_cookies->userName . ':' . $plugin_cookies->password . '@' . $plugin_cookies->plexIp . '/' . (string) $xml->Video->Media->Part->attributes()->file;
         $videoUrl[SMB_CONNECTION_TYPE] = $smbVideoUrl;
     }
     $videoUrl[HTTP_CONNECTION_TYPE] = $httpVidelUrl;
     $videoUrl[NFS_CONNECTION_TYPE] = $nfsVideoUrl;
     $v = $videoUrl[$plugin_cookies->connectionMethod];
     hd_print(__METHOD__ . ":-----------videoUrl = {$v}-----------");
     $movie->add_series_data(1, $movie->name, $v, true);
     // hd_print(__METHOD__ . ':' . print_r($movie, true));
     $this->set_cached_movie($movie);
     hd_print(print_r($this, true));
 }
 public function getNextScreen($parameters)
 {
     $key = $parameters['key'];
     $type = $parameters['type'];
     $params = $parameters['params'];
     $art = $params['art'];
     $a = EmplexerConfig::getInstance()->GET_SECTIONS_LIST_VIEW();
     $this->folder_views = $a;
     return $this->get_media_url_str($key, $type, $params);
 }
 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);
     }
 }
 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;
         }
     }
 }
 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 get_folder_views()
 {
     return EmplexerConfig::getInstance()->GET_SECTIONS_LIST_VIEW();
 }
 public function get_folder_views()
 {
     hd_print(__METHOD__);
     return EmplexerConfig::getInstance()->GET_VIDEOS_LIST_VIEW();
 }
Example #8
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;
 }