public function gen_afterPageBuild(X_Page_ItemList_PItem $items, Zend_Controller_Action $controller) { if (count($items->getItems()) == 0) { X_Debug::i("Plugin triggered"); $item = new X_Page_Item_PItem('emptylists', X_Env::_('p_emptylists_moveaway')); $item->setType(X_Page_Item_PItem::TYPE_ELEMENT)->setLink(X_Env::completeUrl($controller->getHelper('url')->url())); $items->append($item); } }
public function gen_afterPageBuild(X_Page_ItemList_PItem $items, Zend_Controller_Action $controller) { if ($this->helpers()->devices()->isWiimc() && $this->helpers()->devices()->isWiimcBeforeVersion('1.0.9')) { if (count($items->getItems()) === 1) { X_Debug::i("Plugin triggered"); $item = new X_Page_Item_PItem('workaroundwiimcplaylistitemsbug', '-- Workaround for bug in Wiimc <= 1.0.9 --'); $item->setType(X_Page_Item_PItem::TYPE_ELEMENT)->setLink(X_Env::completeUrl($controller->getHelper('url')->url())); $items->append($item); } } }
/** * Add the button BackToStream in controls page * * @param X_Streamer_Engine $engine * @param Zend_Controller_Action $controller the controller who handle the request * @return array */ public function preGetControlItems(X_Streamer_Engine $engine, Zend_Controller_Action $controller) { // ignore if the streamer is not vlc if (!$engine instanceof X_Streamer_Engine_RtmpDump) { return; } $outputLink = "http://{%SERVER_NAME%}:{$this->helpers()->rtmpdump()->getStreamPort()}/"; $outputLink = str_replace(array('{%SERVER_IP%}', '{%SERVER_NAME%}'), array($_SERVER['SERVER_ADDR'], strstr($_SERVER['HTTP_HOST'], ':') ? strstr($_SERVER['HTTP_HOST'], ':') : $_SERVER['HTTP_HOST']), $outputLink); $item = new X_Page_Item_PItem($this->getId(), X_Env::_('p_profiles_backstream')); $item->setType(X_Page_Item_PItem::TYPE_PLAYABLE)->setIcon('/images/icons/play.png')->setLink($outputLink); return new X_Page_ItemList_PItem(array($item)); }
public function getModeItems($provider, $location, Zend_Controller_Action $controller) { $list = new X_Page_ItemList_PItem(); $urlHelper = $controller->getHelper('url'); if ($this->countdown > 0) { $countdown = new X_Page_Item_PItem('core-countdown', X_Env::_('core_countdown', $this->countdown)); $countdown->setType(X_Page_Item_PItem::TYPE_ELEMENT)->setIcon("/images/{$this->getId()}/logo.png")->setLink(X_Env::completeUrl($urlHelper->url())); $list->append($countdown); } if ($this->error_message) { $error = new X_Page_Item_PItem('core-error', X_Env::_($this->error_message)); $error->setType(X_Page_Item_PItem::TYPE_ELEMENT)->setIcon("/images/{$this->getId()}/logo.png")->setLink(X_Env::completeUrl($urlHelper->url())); $list->append($error); } return $list; }
/** * Add the button BackToStream in controls page * * @param X_Streamer_Engine $engine * @param Zend_Controller_Action $controller the controller who handle the request * @return array */ public function preGetControlItems(X_Streamer_Engine $engine, Zend_Controller_Action $controller) { $urlHelper = $controller->getHelper('url'); $return = new X_Page_ItemList_PItem(); if ($this->config('show.title', true)) { $onAirName = X_Env::_("p_streaminfo_unknown_source"); if ($engine instanceof X_Streamer_Engine_Vlc) { $vlc = $engine->getVlcWrapper(); $onAirName = $vlc->getCurrentName(); } else { // try to find the name from the location (if any) $providerId = $controller->getRequest()->getParam('p', false); $location = $controller->getRequest()->getParam('l', false); if ($providerId && $location) { $providerObj = X_VlcShares_Plugins::broker()->getPlugins($providerId); $location = X_Env::decode($location); if ($providerObj instanceof X_VlcShares_Plugins_ResolverInterface) { $onAirName = $providerObj->resolveLocation($location); } } } // show the title of the file $item = new X_Page_Item_PItem('streaminfo-onair', X_Env::_('p_streaminfo_onair') . ": {$onAirName}"); $item->setType(X_Page_Item_PItem::TYPE_ELEMENT)->setLink(X_Env::completeUrl($urlHelper->url())); $return->append($item); } if ($engine instanceof X_Streamer_Engine_Vlc) { $vlc = $engine->getVlcWrapper(); if ($this->config('show.time', false)) { $currentTime = X_Env::formatTime($vlc->getCurrentTime()); $totalTime = X_Env::formatTime($vlc->getTotalTime()); $item = new X_Page_Item_PItem('streaminfo-time', "{$currentTime}/{$totalTime}"); $item->setType(X_Page_Item_PItem::TYPE_ELEMENT)->setLink(X_Env::completeUrl($urlHelper->url())); $return->append($item); } } return $return; }
protected function libraryMenu(X_Page_ItemList_PItem $items, $submode = false) { X_Debug::i("Submode requested: " . print_r($submode, true)); // disabling cache plugin try { $cachePlugin = X_VlcShares_Plugins::broker()->getPlugins('cache'); if (method_exists($cachePlugin, 'setDoNotCache')) { $cachePlugin->setDoNotCache(); } } catch (Exception $e) { // cache plugin not registered, no problem } if ($submode === false || $submode == null) { // load all categories in the library $categories = Application_Model_YoutubeCategoriesMapper::i()->fetchAll(); foreach ($categories as $category) { /* @var $category Application_Model_YoutubeCategory */ $item = new X_Page_Item_PItem('youtube-category-' . $category->getId(), $category->getLabel()); $item->setThumbnail($category->getThumbnail())->setIcon('/images/youtube/icons/category.png')->setCustom(__CLASS__ . ':location', self::MODE_LIBRARY . "/" . $category->getId())->setLink(array('l' => X_Env::encode(self::MODE_LIBRARY . "/" . $category->getId())), 'default', false)->setGenerator(__CLASS__); $items->append($item); } } else { // load all video inside a category categories /* @var $category Application_Model_YoutubeCategory */ $category = new Application_Model_YoutubeCategory(); Application_Model_YoutubeCategoriesMapper::i()->find($submode, $category); X_Debug::i('Category found: ' . print_r($category, true)); if ($category->getId() != null && $category->getId() == $submode) { $videos = Application_Model_YoutubeVideosMapper::i()->fetchByCategory($category->getId()); foreach ($videos as $video) { /* @var $video Application_Model_YoutubeVideo */ $item = new X_Page_Item_PItem('youtube-library-' . $video->getId(), $video->getLabel()); $item->setType(X_Page_Item_PItem::TYPE_ELEMENT)->setIcon('/images/youtube/icons/video.png')->setDescription($video->getDescription())->setThumbnail($video->getThumbnail())->setCustom(__CLASS__ . ':location', self::MODE_LIBRARY . "/" . $category->getId() . "/0/" . $video->getId())->setLink(array('action' => 'mode', 'l' => X_Env::encode(self::MODE_LIBRARY . "/" . $category->getId() . "/0/" . $video->getId())), 'default', false)->setGenerator(__CLASS__); $items->append($item); } } } }
/** * Add the button BackToStream in controls page * * @param X_Streamer_Engine $engine * @param Zend_Controller_Action $controller the controller who handle the request * @return array */ public function preGetControlItems(X_Streamer_Engine $engine, Zend_Controller_Action $controller) { // ignore if the streamer is not vlc if (!$engine instanceof X_Streamer_Engine_RtmpDumpWeebTv) { return; } $outputLink = "http://{%SERVER_NAME%}:{$this->getStreamingPort()}/stream"; $outputLink = str_replace(array('{%SERVER_IP%}', '{%SERVER_NAME%}'), array($_SERVER['SERVER_ADDR'], strstr($_SERVER['HTTP_HOST'], ':') ? strstr($_SERVER['HTTP_HOST'], ':') : $_SERVER['HTTP_HOST']), $outputLink); // try to get the location and provider /* $provider = $controller->getRequest()->getParam('p', false); $location = $controller->getRequest()->getParam('l', false); if ( $provider == $this->getId() && $location ) { $location = X_Env::decode($location); // try to decode the $location try { $outputLink .= $this->getLinkParams($location); } catch (Exception $e) { X_Debug::e("Unable to decode rtmp params"); } } */ $item = new X_Page_Item_PItem($this->getId(), X_Env::_('p_profiles_backstream')); $item->setType(X_Page_Item_PItem::TYPE_PLAYABLE)->setIcon('/images/icons/play.png')->setLink($outputLink); return new X_Page_ItemList_PItem(array($item)); }
/** * Prepare and return a -previous-page- item * * @param string $location * @param int $previousPage * @param int $totalPages */ static function getPreviousPage($location, $previousPage, $totalPages = '???') { $item = new X_Page_Item_PItem('previouspage', X_Env::_("previouspage", $previousPage, $totalPages)); $item->setType(X_Page_Item_PItem::TYPE_CONTAINER)->setCustom(__CLASS__ . ':location', $location)->setDescription(APPLICATION_ENV == 'development' ? $location : null)->setLink(array('l' => X_Env::encode($location)), 'default', false); return $item; }
/** * Add the go-to-control-page * * @param X_Streamer_Engine $engine selected streamer engine * @param string $uri * @param string $provider id of the plugin that should handle request * @param string $location to stream * @param Zend_Controller_Action $controller the controller who handle the request * @return X_Page_ItemList_PItem */ public function getStreamItems(X_Streamer_Engine $engine, $uri, $provider, $location, Zend_Controller_Action $controller) { $urlHelper = $controller->getHelper('url'); $item = new X_Page_Item_PItem($this->getId(), X_Env::_('p_controls_gotocontrols')); $item->setType(X_Page_Item_PItem::TYPE_ELEMENT)->setIcon('/images/icons/controls.png')->setLink(array('controller' => 'controls', 'action' => 'control'), 'default', false); return new X_Page_ItemList_PItem(array($item)); }
public function menuChannels(X_Page_ItemList_PItem $items) { /* @var $parsed SimpleXmlElement */ $dom = simplexml_load_string($this->getChannelsList()); $parsed = $dom->xpath('//stream'); // failed xpath, no results if (!$parsed) { return; } foreach ($parsed as $match) { /* @var $match SimpleXmlElement */ $id = (string) $match->title; $label = (string) $match->title . " [" . (string) $match->language . "]"; $item = new X_Page_Item_PItem($this->getId() . "-{$id}", $label); $item->setType(X_Page_Item_PItem::TYPE_ELEMENT)->setCustom(__CLASS__ . ':location', "{$id}")->setDescription(APPLICATION_ENV == 'development' ? "{$id}" : null)->setIcon("/images/icons/hosters/direct-url.png")->setLink(array('action' => 'mode', 'l' => X_Env::encode("{$id}")), 'default', false); $items->append($item); } }
/** * Show the list of valid streams * @param string $provider * @param string $location * @param string $pid * @param Zend_Controller_Action $controller * @return X_Page_ItemList_PItem */ public function getSelectionItems($provider, $location, $pid, Zend_Controller_Action $controller) { // we want to expose items only if pid is this plugin if ($this->getId() != $pid) { return; } X_Debug::i('Plugin triggered'); $urlHelper = $controller->getHelper('url'); // i try to mark current selected sub based on $this->getId() param // in $currentSub i get the name of the current profile $currentStream = $controller->getRequest()->getParam($this->getId(), false); $return = new X_Page_ItemList_PItem(); try { /* @var $realdebridHelper X_VlcShares_Plugins_Helper_RealDebrid */ $realdebridHelper = $this->helpers('realdebrid'); // check if a valid location has been setted if (!$realdebridHelper->isValid()) { X_Debug::i("Try to force location retrieval"); $providerObj = X_VlcShares_Plugins::broker()->getPlugins($provider); if ($providerObj instanceof X_VlcShares_Plugins_ResolverInterface) { $providerObj->resolveLocation($location); } elseif (method_exists($providerObj, 'resolveLocation')) { // try to check if resolveLocation is there, even if not the interface $providerObj->resolveLocation($location); } else { X_Debug::e("Provider can't be called for location resolving"); return; } } $links = $realdebridHelper->getUrls(); X_Debug::i('Plugin triggered. Location could be provided by RealDebrid'); // if $pid == ID:refresh, only force refresh the link if ($controller->getRequest()->getParam("{$this->getId()}:refresh", false) != false) { $realdebridHelper->cleanCurrentCacheEntry(); $item = new X_Page_Item_PItem($this->getId(), X_Env::_('p_realdebrid_refreshdone')); $item->setType(X_Page_Item_PItem::TYPE_ELEMENT)->setLink(array('action' => 'mode', "{$this->getId()}:refresh" => null, 'pid' => null), 'default', false); $return->append($item); } else { foreach ($links as $i => $streamlink) { $linkPart = explode('/', $streamlink); $label = urldecode(array_pop($linkPart)); $item = new X_Page_Item_PItem($this->getId() . "-{$i}", X_Env::_('p_realdebrid_streamoption', $label, $streamlink)); $item->setType(X_Page_Item_PItem::TYPE_ELEMENT)->setLink(array('action' => 'mode', $this->getId() => $i == 0 ? null : $i, 'pid' => null), 'default', false)->setHighlight($currentStream == $i); $return->append($item); } } } catch (Exception $e) { X_Debug::f("Location is not provided by RealDebrid, but i'm inside the stream type selection O_o"); } return $return; }
private function _fetchThreads(X_Page_ItemList_PItem $items, $sortType, $subType, $page = 1) { X_Debug::i("Fetching threads for {$sortType}/{$subType}/{$page}"); switch ($sortType) { case self::SORT_ALPHA: // subType = letter $url = $this->config('index.alpha.url', "http://www.gogocinema.com/disp_abcd.php?letter=") . $subType; break; case self::SORT_YEAR: // subType = year $url = $this->config('index.year.url', "http://www.gogocinema.com/disp_year.php?year=") . $subType; break; case self::SORT_TYPE: // subType = year $url = $this->config('index.type.url', "http://www.gogocinema.com/disp_genre.php?genre=") . $subType; break; case self::SORT_SEARCH: // subType = year $url = $this->config('index.search.url', "http://www.gogocinema.com/disp_search.php?search=") . urlencode($subType); break; } if ($page > 1) { // adding page param $url .= "&page={$page}"; } $htmlString = $this->_loadPage($url); $pattern = '/<a href\\=\\"movie\\.php\\?movie_id\\=([^\\"]+)\\" style\\=\\"color\\:\\#E95C24\\;\\"><img src\\=\\"([^\\"]+)\\" width\\=\\"68\\" height\\=\\"100\\" alt\\=\\"Watch ([^\\"]+) Online\\"/'; $patternNext = '/<span class\\=\\"disabled\\"\\>Next\\<\\/span\\>/'; $patternPrevious = '/<span class\\=\\"disabled\\"\\>Previous\\<\\/span\\>/'; $patternPagination = '/<div class\\=\\"pagination\\"\\>/'; $matches = array(); if (preg_match_all($pattern, $htmlString, $matches, PREG_SET_ORDER)) { X_Debug::i("Threads found: " . count($matches)); $paginationEnabled = preg_match($patternPagination, $htmlString) ? true : false; if ($paginationEnabled && !preg_match($patternPrevious, $htmlString, $submatch)) { //X_Debug::i("Previous page allowed: ".var_export($submatch, true)); $ppage = $page > 2 ? "/" . ($page - 1) : ''; $item = new X_Page_Item_PItem($this->getId() . "-previouspage", X_Env::_('p_gogocinema_previouspage', $page - 1)); $item->setType(X_Page_Item_PItem::TYPE_CONTAINER)->setCustom(__CLASS__ . ':location', "{$sortType}/{$subType}{$ppage}")->setLink(array('l' => X_Env::encode("{$sortType}/{$subType}{$ppage}")), 'default', false); if (APPLICATION_ENV == 'development') { $item->setDescription("{$sortType}/{$subType}{$ppage}"); } $items->append($item); } foreach ($matches as $thread) { @(list(, $threadId, $thumbnail, $label) = $thread); $item = new X_Page_Item_PItem($this->getId() . "-{$sortType}-{$subType}-{$threadId}", $label); $item->setIcon('/images/icons/folder_32.png')->setThumbnail($thumbnail)->setType(X_Page_Item_PItem::TYPE_CONTAINER)->setCustom(__CLASS__ . ':location', "{$sortType}/{$subType}/{$page}/{$threadId}")->setLink(array('l' => X_Env::encode("{$sortType}/{$subType}/{$page}/{$threadId}")), 'default', false); if (APPLICATION_ENV == 'development') { $item->setDescription("{$sortType}/{$subType}/{$page}/{$threadId}"); } $items->append($item); } if ($paginationEnabled && !preg_match($patternNext, $htmlString, $submatch)) { //X_Debug::i("Next page allowed: ".var_export($submatch, true)); $item = new X_Page_Item_PItem($this->getId() . "-nextpage", X_Env::_('p_gogocinema_nextpage', $page + 1)); $item->setType(X_Page_Item_PItem::TYPE_CONTAINER)->setCustom(__CLASS__ . ':location', "{$sortType}/{$subType}/" . ($page + 1))->setLink(array('l' => X_Env::encode("{$sortType}/{$subType}/" . ($page + 1))), 'default', false); if (APPLICATION_ENV == 'development') { $item->setDescription("{$sortType}/{$subType}/" . ($page + 1)); } $items->append($item); } } else { X_Debug::e("Regex failed {{$pattern}}"); } }
private function _fillPlaylist(X_Page_ItemList_PItem $items, $decoded, $lStack) { X_Debug::i("Decoded: " . print_r($decoded, true)); // The format of $decoded (only notable parts): // { // ok: true|false // msg: $msg ; Setted only if ok = false // folderId: $thisFolder // folders: [ // { // id: $folderID // name: $folderName // }, ... // ] // objects: [ // { // id: $objectID // name: $objectName // link: http://...?...&video=urlencoded(URL)&... // }, // { // id: $objectID // name: $objectName // link: http://...?...&host=megavideo&video=urlencoded(MEGAVIDEOURL)&... // }, // ] // ... // } foreach ($decoded->folders as $folder) { $_stack = $lStack; $_stack[] = $folder->id; $item = new X_Page_Item_PItem("opfitalia-folder-{$folder->id}", urldecode($folder->name)); $item->setType(X_Page_Item_PItem::TYPE_CONTAINER)->setGenerator(__CLASS__)->setCustom(__CLASS__ . ':location', implode(':', $_stack))->setLink(array('l' => X_Env::encode(implode(':', $_stack))), 'default', false); $items->append($item); } foreach ($decoded->objects as $object) { $item = new X_Page_Item_PItem("opfitalia-video-{$object->id}", urldecode($object->name)); $item->setType(X_Page_Item_PItem::TYPE_ELEMENT)->setGenerator(__CLASS__); // time to decode the link arg // file: index.php?page=show_streaming&video=http:\/\/www.dbforever.net\/strm\/onepiece\/one_piece_459.mp4&width=704&height=430 // megavideo: index.php?page=show_streaming&host=megavideo&video=http:\/\/www.megavideo.com\/v\/GIV2R76V038221ac298ceb332a9cad75288c318b&width=640&height=480 $link = explode('&', $object->link); $type = 'file'; $href = ''; foreach ($link as $sublink) { list($arg, $value) = @explode('=', $sublink, 2); if ($arg == 'host') { if ($value == 'megavideo') { $type = 'megavideo'; } } if ($arg == 'video') { $href = str_replace('\\/', '/', urldecode($value)); } } if ($type == 'megavideo') { // i gave to split the /v/ param only $splitted = explode('/v/', $href, 2); if (count($splitted) == 2) { $href = $splitted[1]; } else { // try to decode it // as ?v= preg_match('#\\?v=(.+?)$#', $href, $id); if (count($id) >= 2) { $href = $id[1]; } else { // if even this fail // i have to skip thi entry continue; } } $item->setLabel($item->getLabel() . " [Megavideo]"); } $item->setCustom(__CLASS__ . ':location', implode(':', $lStack) . "/{$type}/{$href}")->setLink(array('action' => 'mode', 'l' => X_Env::encode(implode(':', $lStack) . "/{$type}/{$href}")), 'default', false); $items->append($item); } }
public function menuLinks(X_Page_ItemList_PItem $items, $type, $filter, $title, $season, $episode, $pageN = 1) { $pageN = X_VlcShares_Plugins_Utils::isset_or($pageN, 1); if ($type == 'documentaries') { $page = X_PageParser_Page::getPage(sprintf(self::URL_INDEX_LINKS_DOCUMENTARIES, $type, $title, $pageN), new X_PageParser_Parser_TvLinks(X_PageParser_Parser_TvLinks::MODE_LINKS, $type, $filter, $title, $season, $episode, $pageN)); } else { $page = X_PageParser_Page::getPage(sprintf(self::URL_INDEX_LINKS, $type, $title, $season, $episode, $pageN), new X_PageParser_Parser_TvLinks(X_PageParser_Parser_TvLinks::MODE_LINKS, $type, $filter, $title, $season, $episode, $pageN)); } $this->preparePageLoader($page); $parsed = $page->getParsed(); if ($pageN > 1) { // add -previous-page- $previousPage = $pageN - 1; $items->append(X_VlcShares_Plugins_Utils::getPreviousPage("{$type}/{$filter}/{$title}/{$season}/{$episode}/{$previousPage}", $previousPage)); } foreach ($parsed as $match) { $id = $match['id']; $hoster = $match['hoster']; $label = X_Env::_('p_tvlinks_watchon', ucfirst($hoster)); $thumbnail = array_key_exists('thumbnail', $match) ? $match['thumbnail'] : null; $item = new X_Page_Item_PItem($this->getId() . "-{$type}-{$filter}-{$title}-{$season}-{$episode}-{$id}", $label); if (file_exists(APPLICATION_PATH . '/../public/images/icons/hosters/' . $hoster . '.png')) { $item->setIcon("/images/icons/hosters/{$hoster}.png"); } else { if (X_VlcShares::VERSION == "0.5.4") { $item->setIcon("/images/icons/file_32.png"); } else { // icons exists only in vlc-shares > 0.5.4 $item->setIcon("/images/icons/unknown-hoster.png"); } } $item->setType(X_Page_Item_PItem::TYPE_ELEMENT)->setCustom(__CLASS__ . ':location', "{$type}/{$filter}/{$title}/{$season}/{$episode}/{$pageN}/{$id}")->setDescription(APPLICATION_ENV == 'development' ? "{$type}/{$filter}/{$title}/{$season}/{$episode}/{$pageN}/{$id}" : null)->setLink(array('action' => 'mode', 'l' => X_Env::encode("{$type}/{$filter}/{$title}/{$season}/{$episode}/{$pageN}/{$id}")), 'default', false); if ($thumbnail) { $item->setThumbnail($thumbnail); } $items->append($item); } if ($page->getParsed(new X_PageParser_Parser_TvLinks(X_PageParser_Parser_TvLinks::MODE_NEXTPAGE, $type, $filter, $title, $season, $episode, $pageN))) { $nextPage = $pageN + 1; $items->append(X_VlcShares_Plugins_Utils::getNextPage("{$type}/{$filter}/{$title}/{$season}/{$episode}/{$nextPage}", $nextPage)); } }
public function menuEpisodes(X_Page_ItemList_PItem $items, $type, $filter, $pageN, $show, $season, $showType) { $page = X_PageParser_Page::getPage(sprintf(self::URL_BASE, $show), new X_PageParser_Parser_Preg('/new VideoSlider\\("' . $showType . '",(?P<json>.*?)\\)\\s+\\/\\/]]>/si', X_PageParser_Parser_Preg::PREG_MATCH)); $this->preparePageLoader($page); $parsed = $page->getParsed(); if ($parsed) { $json = Zend_Json::decode($parsed['json']); $url = "{$json['url']}?"; foreach ($json['urlOptions'] as $key => $value) { if ($key == 'season') { $value = $season; } if ($key == 'page') { $value = "%s"; } $url .= "{$key}={$value}&"; } $url = rtrim($url, "&"); $i = 1; while (true) { $page = X_PageParser_Page::getPage(sprintf($url, $i++), new X_PageParser_Parser_Preg('/<li.*?<a href=".*?watch\\/(?P<epid>.*?)\\/(?P<epname>.*?)".*?<img src="(?P<thumbnail>.*?)".*?alt="(?P<label>.*?)"(?P<extra>.*?)<\\/li>/s', X_PageParser_Parser_Preg::PREG_MATCH_ALL, PREG_SET_ORDER)); $this->preparePageLoader($page); $parsed = $page->getParsed(); // exit first time no item found if (!count($parsed)) { return; } foreach ($parsed as $match) { $label = $match['label']; $href = "{$match['epid']}:{$match['epname']}"; $thumbnail = $match['thumbnail']; if (strpos($match['extra'], 'class="hplus-sticker') !== false) { // can ignore plus content if (!$this->config('show.plus', true)) { continue; } $label = "[Hulu+] {$label}"; } $item = new X_Page_Item_PItem($this->getId() . "-{$show}-{$season}-{$href}", $label); $item->setIcon("/images/icons/file_32.png"); $item->setType(X_Page_Item_PItem::TYPE_ELEMENT)->setCustom(__CLASS__ . ':location', "{$type}/{$filter}/{$pageN}/{$show}/{$season}:{$showType}/{$href}")->setThumbnail($thumbnail)->setDescription(APPLICATION_ENV == 'development' ? "{$type}/{$filter}/{$pageN}/{$show}/{$season}:{$showType}/{$href}" : null)->setLink(array('action' => 'mode', 'l' => X_Env::encode("{$type}/{$filter}/{$pageN}/{$show}/{$season}:{$showType}/{$href}")), 'default', false); $items->append($item); } // if parsed < per-page, i know there are no more videos if (count($parsed) < 5) { break; } } } }
/** * Fill a list of resource by type, group and page * @param X_Page_ItemList_PItem $items an empty list * @param string $resourceType the resource type selected * @param string $resourceGroup the resource group selected * @param int $page number of the page * @return X_Page_ItemList_PItem the list filled */ private function _fetchResources(X_Page_ItemList_PItem $items, $resourceType, $resourceGroup, $page = 1) { X_Debug::i("Fetching resources for {$resourceType}/{$resourceGroup}/{$page}"); // if resourceGroup == new, query and url are specials if ($resourceGroup == 'new') { switch ($resourceType) { case self::TYPE_MOVIES: $url = self::URL_MOVIES_INDEX_NEW; $xpathQuery = '//div[@id="maincontent"]//div[@class="galleryitem"]'; break; case self::TYPE_ANIME: $url = self::URL_ANIME_INDEX_NEW; $xpathQuery = '//div[@id="sidebar"]//div[@id="text-5"]//tr[11]//td'; break; case self::TYPE_TVSHOWS: $url = self::URL_TVSHOWS_INDEX_NEW; $xpathQuery = '//div[@id="sidebar"]//div[@id="text-5"]//tr[position()=1 or position()=4 or position()=5]//td//a/parent::node()'; break; } } else { switch ($resourceType) { case self::TYPE_MOVIES: $url = sprintf(self::URL_MOVIES_INDEX_AZ, $resourceGroup); $xpathQuery = '//div[@id="maincontent"]//p/*/a[1][node()][text()]'; $hasThumbnail = false; $hasDescription = false; break; case self::TYPE_ANIME: $url = self::URL_ANIME_INDEX_AZ; $xpathQuery = '//div[@id="maincontent"]//p/*/a[1][node()][text()]'; break; case self::TYPE_TVSHOWS: $url = self::URL_TVSHOWS_INDEX_AZ; $xpathQuery = '//div[@id="maincontent"]//p/*/a[1][node()][text()]'; break; } } // fetch the page from filmstream (url is different for each $resourceType) $htmlString = $this->_loadPage($url); // load the readed page inside a DOM object, so we can user XPath for traversal $dom = new Zend_Dom_Query($htmlString); // execute the query $result = $dom->queryXpath($xpathQuery); if ($result->valid()) { X_Debug::i("Resources found: " . $result->count()); $perPage = $this->config('items.perpage', 50); // before to slice the results, we must check if a -next-page- is needed $nextNeeded = $result->count() > $page * $perPage ? true : false; $matches = array(); $i = 1; while ($result->valid()) { if ($i > ($page - 1) * $perPage && $i < $page * $perPage) { $currentRes = $result->current(); if ($resourceGroup == 'new') { $IdNode = $currentRes->firstChild; while ($IdNode instanceof DOMText && $IdNode != null) { $IdNode = $IdNode->nextSibling; } // anime, tvshow, subbed are on the side bar, and $currentRes has 1 child only if ($currentRes->childNodes->length == 1) { $labelNode = $IdNode; } else { $labelNode = $IdNode->nextSibling; } if (is_object($labelNode) && trim($labelNode->nodeValue) == '') { $labelNode = $labelNode->parentNode; } $resourceId = str_replace('/', ':', substr($IdNode->getAttribute('href'), strlen(self::URL_BASE), -1)); // i've done everthing. If all doesn't work, just skip this entry if ($resourceId == "") { $i++; $result->next(); continue; } $resourceLabel = trim(@$labelNode->nodeValue); if ($resourceLabel == '') { $resourceLabel = $currentRes->nodeValue; } $resourceDescription = null; $resourceThumbnail = $IdNode->firstChild != null && !$IdNode->firstChild instanceof DOMText ? $IdNode->firstChild->getAttribute('src') : null; } else { $resourceId = str_replace('/', ':', substr($currentRes->getAttribute('href'), strlen(self::URL_BASE), -1)); $resourceLabel = trim($currentRes->nodeValue); $resourceDescription = null; $resourceThumbnail = null; } $matches[] = array($resourceId, $resourceLabel, $resourceDescription, $resourceThumbnail); } $i++; $result->next(); } if ($page > 1) { // we need the "previus-page" link $item = new X_Page_Item_PItem($this->getId() . "-previouspage", X_Env::_("p_filmstream_page_previous", $page - 1)); $item->setType(X_Page_Item_PItem::TYPE_CONTAINER)->setCustom(__CLASS__ . ':location', "{$resourceType}/{$resourceGroup}/" . ($page - 1))->setLink(array('l' => X_Env::encode("{$resourceType}/{$resourceGroup}/" . ($page - 1))), 'default', false); $items->append($item); } foreach ($matches as $resource) { @(list($resourceId, $resourceLabel, $resourceDescription, $resourceThumbnail) = $resource); $item = new X_Page_Item_PItem($this->getId() . "-{$resourceType}-{$resourceGroup}-{$page}-{$resourceId}", $resourceLabel); $item->setIcon('/images/icons/folder_32.png')->setType(X_Page_Item_PItem::TYPE_CONTAINER)->setCustom(__CLASS__ . ':location', "{$resourceType}/{$resourceGroup}/{$page}/{$resourceId}")->setLink(array('l' => X_Env::encode("{$resourceType}/{$resourceGroup}/{$page}/{$resourceId}")), 'default', false); if ($resourceDescription != null) { $item->setDescription($resourceDescription); } elseif (APPLICATION_ENV == 'development') { $item->setDescription("{$resourceType}/{$resourceGroup}/{$page}/{$resourceId}"); } if ($resourceThumbnail != null) { $item->setThumbnail($resourceThumbnail); } $items->append($item); } if ($nextNeeded) { // we need the "previus-page" link $item = new X_Page_Item_PItem($this->getId() . "-nextpage", X_Env::_("p_filmstream_page_next", $page + 1)); $item->setType(X_Page_Item_PItem::TYPE_CONTAINER)->setCustom(__CLASS__ . ':location', "{$resourceType}/{$resourceGroup}/" . ($page + 1))->setLink(array('l' => X_Env::encode("{$resourceType}/{$resourceGroup}/" . ($page + 1))), 'default', false); $items->append($item); } } else { X_Debug::e("Query failed {{$xpathQuery}}"); } }
/** * Show a list of valid subs for the selected location * @param string $provider * @param string $location * @param string $pid * @param Zend_Controller_Action $controller * @return X_Page_ItemList_PItem */ public function getSelectionItems($provider, $location, $pid, Zend_Controller_Action $controller) { // we want to expose items only if pid is this plugin if ($this->getId() != $pid) { return; } X_Debug::i('Plugin triggered'); $urlHelper = $controller->getHelper('url'); // i try to mark current selected sub based on $this->getId() param // in $currentSub i get the name of the current profile $currentSub = $controller->getRequest()->getParam($this->getId() . ':quality', false); $return = new X_Page_ItemList_PItem(); $item = new X_Page_Item_PItem($this->getId() . '-normal', X_Env::_('p_megavideo_qualityselection_normal')); $item->setType(X_Page_Item_PItem::TYPE_ELEMENT)->setLink(array('action' => 'mode', $this->getId() . ':quality' => null, 'pid' => null), 'default', false)->setHighlight($currentSub === false || $currentSub == X_VlcShares_Plugins_Helper_Megavideo::QUALITY_NORMAL); $return->append($item); $item = new X_Page_Item_PItem($this->getId() . '-full', X_Env::_('p_megavideo_qualityselection_full')); $item->setType(X_Page_Item_PItem::TYPE_ELEMENT)->setLink(array('action' => 'mode', $this->getId() . ':quality' => X_VlcShares_Plugins_Helper_Megavideo::QUALITY_FULL, 'pid' => null), 'default', false)->setHighlight($currentSub == X_VlcShares_Plugins_Helper_Megavideo::QUALITY_FULL); $return->append($item); $item = new X_Page_Item_PItem($this->getId() . '-full', X_Env::_('p_megavideo_qualityselection_nopremium')); $item->setType(X_Page_Item_PItem::TYPE_ELEMENT)->setLink(array('action' => 'mode', $this->getId() . ':quality' => X_VlcShares_Plugins_Helper_Megavideo::QUALITY_NOPREMIUM, 'pid' => null), 'default', false)->setHighlight($currentSub == X_VlcShares_Plugins_Helper_Megavideo::QUALITY_NOPREMIUM); $return->append($item); return $return; }
protected function fetchChannels(X_Page_ItemList_PItem $items, $page = 1) { $json = $this->_loadPage(self::CHANNELS_INDEX, $this->config('channels.cache.validity', 3)); $_channels = Zend_Json::decode($json); // filter channels $channels = array(); foreach ($_channels as $channel) { if (isset($channel['flashEnabled']) && $channel['flashEnabled'] == true) { $channels[] = $channel; } } $totalPageCount = $this->helpers()->paginator()->getPages($channels); if ($this->helpers()->paginator()->hasPrevious($channels, $page)) { $item = new X_Page_Item_PItem('previouspage', X_Env::_("previouspage", $page - 1, $totalPageCount)); $item->setType(X_Page_Item_PItem::TYPE_CONTAINER)->setCustom(__CLASS__ . ':location', $page - 1)->setLink(array('l' => X_Env::encode($page - 1)), 'default', false); $items->append($item); } foreach ($this->helpers()->paginator()->getPage($channels, $page) as $channel) { $item = new X_Page_Item_PItem($this->getId() . '-' . $channel['channelId'], $channel['title']); $item->setIcon('/images/icons/hosters/veetle.png')->setThumbnail(@$channel['logo']['lg'] ? @$channel['logo']['lg'] : @$channel['logo']['sm'])->setDescription(@$channel['description'])->setType(X_Page_Item_PItem::TYPE_ELEMENT)->setCustom(__CLASS__ . ':location', "{$page}/veetle:{$channel['channelId']}")->setLink(array('action' => 'mode', 'l' => X_Env::encode("{$page}/veetle:{$channel['channelId']}")), 'default', false); $items->append($item); } if ($this->helpers()->paginator()->hasNext($channels, $page)) { $item = new X_Page_Item_PItem('nextpage', X_Env::_("nextpage", $page + 1, $totalPageCount)); $item->setType(X_Page_Item_PItem::TYPE_CONTAINER)->setCustom(__CLASS__ . ':location', $page + 1)->setLink(array('l' => X_Env::encode($page + 1)), 'default', false); $items->append($item); } }
public function menuChannels(X_Page_ItemList_PItem $items) { /* @var $parsed SimpleXmlElement */ $page = $this->getChannelsListRaw(); $parser = new X_PageParser_Parser_Own3dLive(); $parsed = $parser->parse($page); if (!$parsed) { return; } foreach ($parsed as $match) { /* @var $match array */ $id = "{$match['hoster']}:{$match['id']}"; $label = $match['label']; $item = new X_Page_Item_PItem($this->getId() . "-{$id}", $label); $item->setType(X_Page_Item_PItem::TYPE_ELEMENT)->setCustom(__CLASS__ . ':location', "{$id}")->setDescription(APPLICATION_ENV == 'development' ? "{$id}" : null)->setIcon("/images/icons/hosters/own3dlive.png")->setLink(array('action' => 'mode', 'l' => X_Env::encode("{$id}")), 'default', false); $items->append($item); } }
/** * Add megavideo id to jdownloader download queue * @param string $provider * @param string $location * @param string $pid * @param Zend_Controller_Action $controller * @return X_Page_ItemList_PItem */ public function getSelectionItems($provider, $location, $pid, Zend_Controller_Action $controller) { // we want to expose items only if pid is this plugin if ($this->getId() != $pid) { return; } X_Debug::i('Plugin triggered'); $action = $controller->getRequest()->getParam("{$this->getId()}:action", ''); /* @var $jdownloader X_VlcShares_Plugins_Helper_JDownloader */ $jdownloader = $this->helpers('jdownloader'); // IF action = 'start, stop or pause' // execute the action and return confirm, then exit if ($action != '') { try { if ($action == "start") { $jdownloader->sendRawCommand(X_VlcShares_Plugins_Helper_JDownloader::CMD_ACTION_START); $link = new X_Page_Item_PItem($this->getId() . '-started', X_Env::_('p_jdownloader_selection_started')); $link->setType(X_Page_Item_PItem::TYPE_ELEMENT)->setLink(array('action' => 'share', 'pid' => null, "{$this->getId()}:action" => null), 'default', false); return new X_Page_ItemList_PItem(array($link)); } if ($action == "pause") { $jdownloader->sendRawCommand(X_VlcShares_Plugins_Helper_JDownloader::CMD_ACTION_PAUSE); $link = new X_Page_Item_PItem($this->getId() . '-started', X_Env::_('p_jdownloader_selection_paused')); $link->setType(X_Page_Item_PItem::TYPE_ELEMENT)->setLink(array('action' => 'share', 'pid' => null, "{$this->getId()}:action" => null), 'default', false); return new X_Page_ItemList_PItem(array($link)); } if ($action == "stop") { $jdownloader->sendRawCommand(X_VlcShares_Plugins_Helper_JDownloader::CMD_ACTION_STOP); $link = new X_Page_Item_PItem($this->getId() . '-started', X_Env::_('p_jdownloader_selection_stopped')); $link->setType(X_Page_Item_PItem::TYPE_ELEMENT)->setLink(array('action' => 'share', 'pid' => null, "{$this->getId()}:action" => null), 'default', false); return new X_Page_ItemList_PItem(array($link)); } } catch (Exception $e) { // connection problems or timeout $link = new X_Page_Item_PItem($this->getId() . '-error', X_Env::_('p_jdownloader_selection_error_network')); $link->setDescription($e->getMessage()); $link->setType(X_Page_Item_PItem::TYPE_ELEMENT)->setLink(array('action' => 'share', 'pid' => null, "{$this->getId()}:action" => null), 'default', false); return new X_Page_ItemList_PItem(array($link)); } } else { // else only confirm the addict /* @var $megavideo X_VlcShares_Plugins_Helper_Megavideo */ $megavideo = $this->helpers('megavideo'); try { $megavideo->getServer(); } catch (Exception $e) { // not loaded location yet X_Debug::i("Force location loading"); $providerObj = X_VlcShares_Plugins::broker()->getPlugins($provider); if ($providerObj instanceof X_VlcShares_Plugins_ResolverInterface) { $providerObj->resolveLocation($location); } } $url = null; try { $url = "http://www.megavideo.com/?v=" . $megavideo->getId(); } catch (Exception $e) { // TODO please, rewrite this piece of code // it's really a shame // let's try to get the url from the hoster try { switch ($provider) { // special cases case 'onlinelibrary': // hoster/id is stored inside db $exploded = explode('/', $location); $exploded = array_pop($exploded); $video = new Application_Model_Video(); Application_Model_VideosMapper::i()->find($exploded, $video); $hoster = $video->getHoster(); $videoId = $video->getIdVideo(); break; default: // we try to get information by location decoding // many plugins use a /-divided location with last param in the format of HOSTER:VIDEOID $exploded = explode('/', $location); $exploded = array_pop($exploded); $exploded = explode(':', $exploded, 2); @(list($hoster, $videoId) = $exploded); break; } // lets search a valid hoster $url = $this->helpers()->hoster()->getHoster($hoster)->getHosterUrl($videoId); } catch (Exception $e) { // simply: provider isn't compatible // trying direct download $pObj = X_VlcShares_Plugins::broker()->getPlugins($provider); if ($pObj instanceof X_VlcShares_Plugins_ResolverInterface) { $url = $pObj->resolveLocation($location); if (!X_Env::startWith($url, "http://") && !X_Env::startWith($url, "https://")) { // not valid, revert changes $url = null; } } } } try { if ($url === null) { throw new Exception(); } X_Debug::i("Appending {{$url}} to the queue"); $jdownloader->addLink($url); $link = new X_Page_Item_PItem($this->getId() . '-added', X_Env::_('p_jdownloader_selection_added')); } catch (Zend_Http_Client_Adapter_Exception $e) { // connection problems or timeout $link = new X_Page_Item_PItem($this->getId() . '-error', X_Env::_('p_jdownloader_selection_error_network')); $link->setDescription($e->getMessage()); } catch (Exception $e) { // wrapper/other error X_Debug::e("Trying to add a new download to JDowloader, but location isn't a megavideo url or there is an error"); $link = new X_Page_Item_PItem($this->getId() . '-error', X_Env::_('p_jdownloader_selection_error_invalid')); $link->setDescription($e->getMessage()); } $link->setType(X_Page_Item_PItem::TYPE_ELEMENT)->setLink(array('action' => 'mode', $this->getId() => null, 'pid' => null), 'default', false); return new X_Page_ItemList_PItem(array($link)); } }
/** * Fetch videos in $category and $itemPage */ protected function fetchVideos(X_Page_ItemList_PItem $items, $catPage, $category, $itemPage) { // FIXME we shouldn't use paginator. We could use db for pagination // it's faster $videos = Application_Model_VideosMapper::i()->fetchByCategory($category); $totalPageCount = $this->helpers()->paginator()->getPages($videos); if ($this->helpers()->paginator()->hasPrevious($videos, $itemPage)) { $item = new X_Page_Item_PItem($this->getId() . '-previousvidpage', X_Env::_("p_onlinelibrary_previouspage", $itemPage - 1, $totalPageCount)); $item->setType(X_Page_Item_PItem::TYPE_CONTAINER)->setCustom(__CLASS__ . ':location', "{$catPage}/" . X_Env::encode($category) . "/" . ($itemPage - 1))->setLink(array('l' => X_Env::encode("{$catPage}/" . X_Env::encode($category) . "/" . ($itemPage - 1))), 'default', false); $items->append($item); } foreach ($this->helpers()->paginator()->getPage($videos, $itemPage) as $video) { /* @var $video Application_Model_Video */ $item = new X_Page_Item_PItem($this->getId() . '-' . $video->getId(), $video->getTitle() . " [" . ucfirst($video->getHoster() . "]")); $item->setIcon("/images/icons/hosters/{$video->getHoster()}.png")->setType(X_Page_Item_PItem::TYPE_ELEMENT)->setCustom(__CLASS__ . ':location', "{$catPage}/" . X_Env::encode($category) . "/{$itemPage}/" . $video->getId())->setLink(array('action' => 'mode', 'l' => X_Env::encode("{$catPage}/" . X_Env::encode($category) . "/{$itemPage}/" . $video->getId())), 'default', false); if (trim($video->getDescription()) != '') { $item->setDescription(trim($video->getDescription())); } if (trim($video->getThumbnail()) != '') { $item->setThumbnail(trim($video->getThumbnail())); } $items->append($item); } if ($this->helpers()->paginator()->hasNext($videos, $itemPage)) { $item = new X_Page_Item_PItem($this->getId() . '-previousvidpage', X_Env::_("p_onlinelibrary_nextpage", $itemPage + 1, $totalPageCount)); $item->setType(X_Page_Item_PItem::TYPE_CONTAINER)->setCustom(__CLASS__ . ':location', "{$catPage}/" . X_Env::encode($category) . "/" . ($itemPage + 1))->setLink(array('l' => X_Env::encode("{$catPage}/" . X_Env::encode($category) . "/" . ($itemPage + 1))), 'default', false); $items->append($item); } }
public function menuLinks(X_Page_ItemList_PItem $items, $category, $show, $type) { $i = 0; while (true) { $page = X_PageParser_Page::getPage(sprintf(self::URL_INDEX_LINKS, $type, $i++), new X_PageParser_Parser_Preg('/<a .*?href=\\"\\/dl\\/RaiTV\\/programmi\\/media\\/ContentItem-(?P<href>.*?).html#p=0\\".*?src=\\"(?P<thumbnail>.*?)\\".*?><h2>(?P<label>.*?)<\\/h2>/s', X_PageParser_Parser_Preg::PREG_MATCH_ALL, PREG_SET_ORDER)); $this->preparePageLoader($page); $parsed = $page->getParsed(); // exit first time no item found if (!count($parsed)) { return; } foreach ($parsed as $match) { $label = $match['label']; $href = $match['href']; $thumbnail = $match['thumbnail']; if ($thumbnail && !X_Env::startWith($thumbnail, 'http://')) { $thumbnail = sprintf(self::URL_BASE, ltrim($thumbnail, '/')); } $item = new X_Page_Item_PItem($this->getId() . "-{$show}-{$type}-{$href}", $label); $item->setIcon("/images/icons/file_32.png"); $item->setType(X_Page_Item_PItem::TYPE_ELEMENT)->setCustom(__CLASS__ . ':location', "{$category}/{$show}/{$type}/{$href}")->setThumbnail($thumbnail)->setDescription(APPLICATION_ENV == 'development' ? "{$category}/{$show}/{$type}/{$href}" : null)->setLink(array('action' => 'mode', 'l' => X_Env::encode("{$category}/{$show}/{$type}/{$href}")), 'default', false); $items->append($item); } } }
public function getSelectionItems($provider, $location, $pid, Zend_Controller_Action $controller) { // we want to expose items only if pid is this plugin if ($this->getId() != $pid) { return; } // check for resolvable $location // this plugin is useless if i haven't an access // to the real location (url for stream or path for file) $provider = X_VlcShares_Plugins::broker()->getPlugins($provider); if (!$provider instanceof X_VlcShares_Plugins_ResolverInterface) { return; } $providerClass = get_class($provider); X_Debug::i('Plugin triggered'); $urlHelper = $controller->getHelper('url'); // i try to mark current selected sub based on $this->getId() param // in $currentSub i get the name of the current profile $currentSub = $controller->getRequest()->getParam($this->getId(), false); if ($currentSub !== false) { $currentSub = X_Env::decode($currentSub); } $return = new X_Page_ItemList_PItem(); $item = new X_Page_Item_PItem($this->getId() . '-none', X_Env::_('p_audioswitcher_selection_none')); $item->setType(X_Page_Item_PItem::TYPE_ELEMENT)->setLink(array('action' => 'mode', $this->getId() => null, 'pid' => null), 'default', false)->setHighlight($currentSub === false); $return->append($item); // i do the check for this on top // location param come in a plugin encoded way $location = $provider->resolveLocation($location); // check if infile support is enabled // by default infile.enabled is true if ($this->config('infile.enabled', true)) { // check for infile tracks $infileTracks = $this->helpers()->stream()->setLocation($location)->getAudiosInfo(); //X_Debug::i(var_export($infileSubs, true)); foreach ($infileTracks as $streamId => $track) { X_Debug::i("Valid infile-sub: [{$streamId}] {$track['language']} ({$track['format']})"); $item = new X_Page_Item_PItem($this->getId() . '-stream-' . $streamId, X_Env::_("p_audioswitcher_subtype_" . self::STREAM) . " {$streamId} {$track['language']} {$track['format']}"); $item->setType(X_Page_Item_PItem::TYPE_ELEMENT)->setCustom(__CLASS__ . ':sub', self::STREAM . ":{$streamId}")->setLink(array('action' => 'mode', 'pid' => null, $this->getId() => X_Env::encode(self::STREAM . ":{$streamId}")), 'default', false)->setHighlight($currentSub == self::STREAM . ":{$streamId}"); $return->append($item); } } // for file system source i will search for subs in filename notation // by default file.enabled is true if ($this->config('file.enabled', true) && is_a($provider, 'X_VlcShares_Plugins_FileSystem')) { $dirname = pathinfo($location, PATHINFO_DIRNAME); $filename = pathinfo($location, PATHINFO_FILENAME); $extTracks = $this->getFSTracks($dirname, $filename); foreach ($extTracks as $streamId => $track) { X_Debug::i("Valid extfile-sub: {$track['language']} ({$track['format']})"); $item = new X_Page_Item_PItem($this->getId() . '-file-' . $streamId, X_Env::_("p_audioswitcher_subtype_" . self::FILE) . " {$track['language']} ({$track['format']})"); $item->setType(X_Page_Item_PItem::TYPE_ELEMENT)->setCustom(__CLASS__ . ':sub', self::FILE . ":{$streamId}")->setLink(array('action' => 'mode', 'pid' => null, $this->getId() => X_Env::encode(self::FILE . ":{$streamId}")), 'default', false)->setHighlight($currentSub == self::FILE . ":{$streamId}"); $return->append($item); } } // general profiles are in the bottom of array return $return; }
public function executeAction() { $request = $this->getRequest(); //X_VlcShares_Plugins::broker()->gen_preProviderSelection($this); /* $provider = $request->getParam('p', false); if ( $provider === false || !X_VlcShares_Plugins::broker()->isRegistered($provider) ) { throw new Exception("Invalid provider"); } $location = X_Env::decode($request->getParam('l', '')); */ $pid = $request->getParam('pid', false); $a = $request->getParam('a', false); $engineId = X_Streamer::i()->getStreamingEngineId(); $engine = X_VlcShares_Plugins::helpers()->streamer()->get($engineId); X_VlcShares_Plugins::broker()->preExecute($engine, $pid, $a, $this); X_VlcShares_Plugins::broker()->execute($engine, $pid, $a, $this); X_VlcShares_Plugins::broker()->postExecute($engine, $pid, $a, $this); $pageItems = new X_Page_ItemList_PItem(); $done = new X_Page_Item_PItem('core-opdone', X_Env::_('controls_done')); $done->setCustom('vlc_still_alive', $this->vlc->isRunning())->setType(X_Page_Item_PItem::TYPE_ELEMENT)->setLink(array('controller' => 'controls', 'action' => 'control', 'pid' => null, 'a' => null, 'param' => null), 'default', false); $pageItems->append($done); // links on top $pageItems->merge(X_VlcShares_Plugins::broker()->preGetExecuteItems($pid, $a, $this)); // add separator between play items and options items $separator = new X_Page_Item_PItem('core-separator', X_Env::_('_____options_separator_____')); $separator->setType(X_Page_Item_PItem::TYPE_ELEMENT)->setLink(array('controller' => 'controls', 'action' => 'control', 'pid' => null, 'a' => null, 'param' => null), 'default', false); $pageItems->append($separator); // normal links $pageItems->merge(X_VlcShares_Plugins::broker()->getExecuteItems($pid, $a, $this)); // bottom links $pageItems->merge(X_VlcShares_Plugins::broker()->postGetExecuteItems($pid, $a, $this)); // trigger for page creation X_VlcShares_Plugins::broker()->gen_afterPageBuild($pageItems, $this); }
public function selectionAction() { $request = $this->getRequest(); X_VlcShares_Plugins::broker()->gen_preProviderSelection($this); $provider = $request->getParam('p', false); if ($provider === false || !X_VlcShares_Plugins::broker()->isRegistered($provider)) { throw new Exception("Invalid provider"); } $pid = $request->getParam('pid', false); if ($pid === false || !X_VlcShares_Plugins::broker()->isRegistered($pid)) { throw new Exception("Invalid pluginId"); } $location = X_Env::decode($request->getParam('l', '')); $pageItems = new X_Page_ItemList_PItem(); // I add a "Back" button as first, this should redirect to mode action $back = new X_Page_Item_PItem('core-back', X_Env::_('back')); $back->setType(X_Page_Item_PItem::TYPE_ELEMENT)->setLink(array('action' => 'mode', 'pid' => null), 'default', false); $pageItems->append($back); // links on top $pageItems->merge(X_VlcShares_Plugins::broker()->preGetSelectionItems($provider, $location, $pid, $this)); // add separator between header items and options items $separator = new X_Page_Item_PItem('core-separator', X_Env::_('_____options_separator_____')); $separator->setType(X_Page_Item_PItem::TYPE_ELEMENT)->setLink(X_Env::completeUrl($this->_helper->url->url())); $pageItems->append($separator); // normal links $pageItems->merge(X_VlcShares_Plugins::broker()->getSelectionItems($provider, $location, $pid, $this)); // bottom links $pageItems->merge(X_VlcShares_Plugins::broker()->postGetSelectionItems($provider, $location, $pid, $this)); // filter out items (parental-control / hidden file / system dir) foreach ($pageItems->getItems() as $key => $item) { $results = X_VlcShares_Plugins::broker()->filterSelectionItems($item, $provider, $pid, $this); if ($results != null && in_array(false, $results)) { $pageItems->remove($item); } } // trigger for page creation X_VlcShares_Plugins::broker()->gen_afterPageBuild($pageItems, $this); }
private function _fetchThreads(X_Page_ItemList_PItem $items, $sortType, $subType, $page = 1) { X_Debug::i("Fetching threads for {$sortType}/{$subType}/{$page}"); switch ($sortType) { case self::SORT_MOVIES: // subType = letter $url = $this->config('index.movies.url', "http://www.icefilms.info/movies/a-z/") . $subType; $pattern = '/<a href=\\/ip\\.php\\?v\\=([^\\&]+)\\&>([^\\<]+)<\\/a>/'; break; case self::SORT_TVSHOWS: // subType = letter $url = $this->config('index.tvshows.url', "http://www.icefilms.info/tv/a-z/") . $subType; $pattern = '/<a href=\\/tv\\/series\\/([^\\>]+)>([^\\<]+)<\\/a>([^\\<]+)<br>/'; break; case self::SORT_OTHER: // subType = letter $url = $this->config('index.other.url', "http://www.icefilms.info/other/a-z/") . $subType; $pattern = '/<a href=\\/ip\\.php\\?v\\=([^\\&]+)\\&>([^\\<]+)<\\/a>/'; break; case self::SORT_MUSIC: // subType = letter $url = $this->config('index.music.url', "http://www.icefilms.info/music/a-z/") . $subType; $pattern = '/<a href=\\/ip\\.php\\?v\\=([^\\&]+)\\&>([^\\<]+)<\\/a>/'; break; case self::SORT_STANDUP: // subType = letter $url = $this->config('index.standup.url', "http://www.icefilms.info/standup/a-z/") . $subType; $pattern = '/<a href=\\/ip\\.php\\?v\\=([^\\&]+)\\&>([^\\<]+)<\\/a>/'; break; } /* if ( $page > 1 ) { // adding page param $url .= "&page=$page"; } */ // cache validity for the request = 15 minutes $htmlString = $this->_loadPage($url, 15); $matches = array(); if (preg_match_all($pattern, $htmlString, $matches, PREG_SET_ORDER)) { X_Debug::i("Threads found: " . count($matches)); //X_Debug::i("Threads: ".var_export($matches, true)); // check for next page before match overwrite $hasNext = $this->helpers()->paginator()->hasNext($matches, $page); $pageCount = $this->helpers()->paginator()->getPages($matches); if ($this->helpers()->paginator()->hasPrevious($matches, $page)) { $item = new X_Page_Item_PItem('previous-page', X_Env::_('previouspage', $page - 1, $pageCount)); $tmpPage = $page - 1; $item->setType(X_Page_Item_PItem::TYPE_CONTAINER)->setCustom(__CLASS__ . ':location', "{$sortType}/{$subType}/{$tmpPage}")->setLink(array('l' => X_Env::encode("{$sortType}/{$subType}/{$tmpPage}")), 'default', false); if (APPLICATION_ENV == 'development') { $item->setDescription("{$sortType}/{$subType}/{$tmpPage}"); } $items->append($item); } // reduce the matches for this items only $matches = $this->helpers()->paginator()->getPage($matches, $page); foreach ($matches as $thread) { if ($sortType == self::SORT_TVSHOWS) { @(list(, $threadId, $label, $episodes) = $thread); $threadId = str_replace('/', ':', $threadId); $label .= " [{$episodes}]"; } else { @(list(, $threadId, $label) = $thread); $threadId = "null/{$threadId}"; } $item = new X_Page_Item_PItem($this->getId() . "-{$sortType}-{$subType}-{$threadId}", $label); $item->setIcon('/images/icons/folder_32.png')->setType(X_Page_Item_PItem::TYPE_CONTAINER)->setCustom(__CLASS__ . ':location', "{$sortType}/{$subType}/{$page}/{$threadId}")->setLink(array('l' => X_Env::encode("{$sortType}/{$subType}/{$page}/{$threadId}")), 'default', false); if (APPLICATION_ENV == 'development') { $item->setDescription("{$sortType}/{$subType}/{$page}/{$threadId}"); } $items->append($item); } if ($hasNext) { $item = new X_Page_Item_PItem('next-page', X_Env::_('nextpage', $page + 1, $pageCount)); $tmpPage = $page + 1; $item->setType(X_Page_Item_PItem::TYPE_CONTAINER)->setCustom(__CLASS__ . ':location', "{$sortType}/{$subType}/{$tmpPage}")->setLink(array('l' => X_Env::encode("{$sortType}/{$subType}/{$tmpPage}")), 'default', false); if (APPLICATION_ENV == 'development') { $item->setDescription("{$sortType}/{$subType}/{$tmpPage}"); } $items->append($item); } } else { X_Debug::e("Regex failed {{$pattern}}"); } }
/** * Add the button BackToStream in controls page * * @param X_Streamer_Engine $engine * @param Zend_Controller_Action $controller the controller who handle the request * @return array */ public function preGetControlItems(X_Streamer_Engine $engine, Zend_Controller_Action $controller) { // ignore if the streamer is not vlc if (!$engine instanceof X_Streamer_Engine_Vlc) { return; } X_Debug::i('Plugin triggered'); $profileId = $controller->getRequest()->getParam($this->getId(), false); $urlHelper = $controller->getHelper('url'); $outputLink = false; // i store the default link, so if i don't find the proper output // i will have a valid link for -go-to-stream- button //$output->setLink($this->config('default.link', "http://{$_SERVER['SERVER_ADDR']}:8081")); if ($profileId !== false) { $profile = new Application_Model_Profile(); Application_Model_ProfilesMapper::i()->find($profileId, $profile); $outputLink = $profile->getLink(); } else { // if store session is enabled, i try to get last output // method from store // else i fallback to best selection try { if ($this->config('store.session', true)) { /* @var $cache X_VlcShares_Plugins_Helper_Cache */ $cache = $this->helpers()->helper('cache'); $outputLink = $cache->retrieveItem('profile::lastvlclink'); } } catch (Exception $e) { // cache expired or cache disabled; X_Debug::i("Stored session not used"); } if (!$outputLink) { X_Debug::i("Outputlink not found. Using best for this device"); $profile = $this->getBest(); $outputLink = $profile->getLink(); } } $outputLink = self::prepareOutputLink($outputLink); $outputLink = str_replace(array('{%SERVER_IP%}', '{%SERVER_NAME%}'), array($_SERVER['SERVER_ADDR'], $_SERVER['HTTP_HOST']), $outputLink); $item = new X_Page_Item_PItem($this->getId(), X_Env::_('p_profiles_backstream')); $item->setType(X_Page_Item_PItem::TYPE_PLAYABLE)->setIcon('/images/icons/play.png')->setLink($outputLink); return new X_Page_ItemList_PItem(array($item)); }
/** * Show the list of valid positions * @param string $provider * @param string $location * @param string $pid * @param Zend_Controller_Action $controller * @return X_Page_ItemList_PItem */ public function getSelectionItems($provider, $location, $pid, Zend_Controller_Action $controller) { // we want to expose items only if pid is this plugin if ($this->getId() != $pid) { return; } X_Debug::i('Plugin triggered'); $urlHelper = $controller->getHelper('url'); // i try to mark current selected sub based on $this->getId() param // in $currentSub i get the name of the current profile $startValue = $controller->getRequest()->getParam($this->getId(), false); $return = new X_Page_ItemList_PItem(); $item = new X_Page_Item_PItem("{$this->getId()}-positions-begin", X_Env::_('p_streamseeker_begin_start_label')); $item->setType(X_Page_Item_PItem::TYPE_ELEMENT)->setHighlight($startValue == false || $startValue == 0 || $startValue == null)->setLink(array('action' => 'mode', "{$this->getId()}" => null, 'pid' => null), 'default', false); $return->append($item); $hosterWrapper = $this->helpers()->hoster(); if (!$hosterWrapper instanceof X_VlcShares_Plugins_Helper_HosterSSWrapper) { X_Debug::w("Hoster replacement failed, can't handler this"); return $return; } /* @var $providerObj X_VlcShares_Plugins_ResolverInterface */ $providerObj = X_VlcShares_Plugins::broker()->getPlugins($provider); if (!$providerObj instanceof X_VlcShares_Plugins_ResolverInterface) { X_Debug::e("Provider is not a resolver. Can't analyze without a location"); return $return; } $resolvedLocation = $providerObj->resolveLocation($location); if (!$resolvedLocation) { X_Debug::e("Invalid stream or invalid location"); return $return; } $hoster = $hosterWrapper->getLastPositiveMatch(); /* @var $ssHelper X_VlcShares_Plugins_Helper_StreamSeeker */ $ssHelper = $this->helpers('streamseeker'); // if valid hoster... if (!$ssHelper->isSeekableHoster($hoster)) { $hosterClass = get_class($hoster); X_Debug::i("Unseekable hoster: {id: {$hoster->getId()}, class: {$hosterClass}}"); return $return; } $positions = $ssHelper->getPositions("{$provider}::{$location}", $resolvedLocation); foreach ($positions as $posValue => $posLabel) { $item = new X_Page_Item_PItem("{$this->getId()}-positions-{$posValue}", $posLabel); $item->setType(X_Page_Item_PItem::TYPE_ELEMENT)->setHighlight($startValue == $posValue)->setLink(array('action' => 'mode', "{$this->getId()}" => $posValue, 'pid' => null), 'default', false); $return->append($item); } return $return; }