public function getModeItems($provider, $location, Zend_Controller_Action $controller) { // if provider is fileSystem, this doesn't work for sure if ($provider == "fileSystem") { return; } $hosterWrapper = $this->helpers()->hoster(); if (!$hosterWrapper instanceof X_VlcShares_Plugins_Helper_HosterSSWrapper) { X_Debug::w("Hoster replacement failed, can't handler this"); return; } /* @var $providerObj X_VlcShares_Plugins_Abstract */ $providerObj = X_VlcShares_Plugins::broker()->getPlugins($provider); // force resolve location if (!$providerObj instanceof X_VlcShares_Plugins_ResolverInterface) { X_Debug::i("Provider not a resolver. Ignoring this"); return; } /* @var $providerObj X_VlcShares_Plugins_ResolverInterface */ $resolvedLocation = $providerObj->resolveLocation($location); if (!$resolvedLocation) { X_Debug::i("Invalid location. Ignoring this"); } // now we know that $location is valid and // that last positive is setted in the hoster wrapper try { $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; } // Prepare the menu $startLabel = X_Env::_("p_streamseeker_begin_start"); // check if param set and prepare the label $startValue = $controller->getRequest()->getParam($this->getId(), 0); if ($startValue > 0) { // ADD priority to filterModeItems to allow url changes on direct-play values $this->setPriority('filterModeItems'); $positions = $ssHelper->getPositions("{$provider}::{$location}", $resolvedLocation); if (array_key_exists($startValue, $positions)) { $startLabel = $positions[$startValue]; } else { $startLabel = X_Env::_('p_streamseeker_begin_unknown', $startValue); } } $link = new X_Page_Item_PItem($this->getId(), X_Env::_('p_streamseeker_startfrom', $startLabel)); $link->setIcon('/images/streamseeker/logo.png')->setType(X_Page_Item_PItem::TYPE_ELEMENT)->setLink(array('action' => 'selection', 'pid' => $this->getId()), 'default', false); return new X_Page_ItemList_PItem(array($link)); } catch (Exception $e) { X_Debug::i("Hoster API not used or not positive match: {$e->getMessage()}"); return; } }
static function getWatchDirectlyOrFilter($pluginId, X_VlcShares_Plugins_ResolverInterface $plugin, $location) { $url = $plugin->resolveLocation($location); if ($url) { // add watch directly link $link = new X_Page_Item_PItem('core-directwatch', X_Env::_('watchdirectly')); $link->setIcon('/images/icons/play.png')->setType(X_Page_Item_PItem::TYPE_PLAYABLE)->setLink($url); } else { // prepare for filter X_Debug::i('Setting priority to filterModeItems'); $plugin->setPriority('filterModeItems', 99); $link = new X_Page_Item_PItem('core-invalidlink', X_Env::_('invalidlink')); $link->setIcon('/images/msg_error.png')->setType(X_Page_Item_PItem::TYPE_ELEMENT)->setLink(array('controller' => 'browse', 'action' => 'share', 'p' => $pluginId, 'l' => X_Env::encode($plugin->getParentLocation($location))), 'default', true); } return new X_Page_ItemList_PItem(array($link)); }
/** * Give back the link for change modes * and the default config for this location * * @param string $provider * @param string $location * @param Zend_Controller_Action $controller * @return X_Page_ItemList_PItem */ public function getModeItems($provider, $location, Zend_Controller_Action $controller) { X_Debug::i('Plugin triggered'); $urlHelper = $controller->getHelper('url'); $profileLabel = X_Env::_('p_profiles_selection_auto'); $profileId = $controller->getRequest()->getParam($this->getId(), false); if ($profileId === false) { $profileId = $this->helpers()->devices()->getDefaultDeviceIdProfile(); } $profile = new Application_Model_Profile(); Application_Model_ProfilesMapper::i()->find($profileId, $profile); if ($profile->getId() != null) { $profileLabel = $profile->getLabel(); } $link = new X_Page_Item_PItem($this->getId(), X_Env::_('p_profiles_profile') . ": {$profileLabel}"); $link->setIcon('/images/manage/plugin.png')->setType(X_Page_Item_PItem::TYPE_ELEMENT)->setLink(array('action' => 'selection', 'pid' => $this->getId()), 'default', false); return new X_Page_ItemList_PItem(array($link)); }
/** * Return the -shared-folders- link * for the collection index * @param Zend_Controller_Action $controller * @return X_Page_ItemList_PItem */ public function preGetCollectionsItems(Zend_Controller_Action $controller) { X_Debug::i("Plugin triggered"); $updates = $this->checkUpdates(); /* @var $urlHelper Zend_Controller_Action_Helper_Url */ $urlHelper = $controller->getHelper('url'); $list = new X_Page_ItemList_PItem(); if ($updates['core'] !== false) { $link = new X_Page_Item_PItem("{$this->getId()}-coreupdate", X_Env::_('p_updatenotifier_collectionindex_core')); $link->setIcon('/images/updatenotifier/logo.png')->setDescription(X_Env::_('p_updatenotifier_collectionindex_core_desc'))->setType(X_Page_Item_PItem::TYPE_ELEMENT)->setLink($urlHelper->url()); $list->append($link); } if (count($updates['plugins'])) { $link = new X_Page_Item_PItem("{$this->getId()}-pluginsupdate", X_Env::_('p_updatenotifier_collectionindex_plugins', count($updates['plugins']))); $link->setIcon('/images/updatenotifier/logo.png')->setDescription(X_Env::_('p_updatenotifier_collectionindex_plugins_desc'))->setType(X_Page_Item_PItem::TYPE_ELEMENT)->setLink($urlHelper->url()); $list->append($link); } return count($list->getItems()) ? $list : null; }
/** * Give back the link for change subs * and the default config for this location * * @param string $provider * @param string $location * @param Zend_Controller_Action $controller * @return X_Page_ItemList_PItem */ public function getModeItems($provider, $location, Zend_Controller_Action $controller) { // 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; } X_Debug::i('Plugin triggered'); $urlHelper = $controller->getHelper('url'); $subLabel = X_Env::_('p_audioswitcher_selection_none'); $subParam = $controller->getRequest()->getParam($this->getId(), false); if ($subParam !== false) { $subParam = X_Env::decode($subParam); list($type, $source) = explode(':', $subParam, 2); $subLabel = X_Env::_("p_audioswitcher_subtype_{$type}") . " ({$source})"; } $link = new X_Page_Item_PItem($this->getId(), X_Env::_('p_audioswitcher_sub') . ": {$subLabel}"); $link->setIcon('/images/manage/plugin.png')->setType(X_Page_Item_PItem::TYPE_ELEMENT)->setLink(array('action' => 'selection', 'pid' => $this->getId()), 'default', false); return new X_Page_ItemList_PItem(array($link)); }
/** * Allow to choose the stream type (if more than one is available) * * @param string $provider * @param string $location * @param Zend_Controller_Action $controller * @return X_Page_ItemList_PItem */ public function getModeItems($provider, $location, Zend_Controller_Action $controller) { // if provider is FileSystem, This isn't needed for sure if (X_VlcShares_Plugins::broker()->getPluginClass($provider) == 'X_VlcShares_Plugins_FileSystem') { return; } 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("Location is not provided by RealDebrid"); return; } $lists = new X_Page_ItemList_PItem(); X_Debug::i('Plugin triggered. Location could be provided by RealDebrid'); $urlHelper = $controller->getHelper('url'); $links = $realdebridHelper->getUrls(); if (count($links) <= 1) { X_Debug::i('Links count is <= 1, no choose needed'); } else { $selectedIndex = $controller->getRequest()->getParam('realdebrid', 0); if (count($links) < $selectedIndex) { $selectedIndex = 0; } $linkPart = explode('/', $links[$selectedIndex]); $selectedLink = urldecode(array_pop($linkPart)); $link = new X_Page_Item_PItem($this->getId(), X_Env::_('p_realdebrid_selected', $selectedLink, $links[$selectedIndex])); $link->setIcon('/images/realdebrid/logo.png')->setType(X_Page_Item_PItem::TYPE_ELEMENT)->setLink(array('action' => 'selection', 'pid' => $this->getId()), 'default', false); $lists->append($link); } $link = new X_Page_Item_PItem($this->getId(), X_Env::_('p_realdebrid_regenerate')); $link->setIcon('/images/realdebrid/logo.png')->setType(X_Page_Item_PItem::TYPE_ELEMENT)->setLink(array('action' => 'selection', 'pid' => "{$this->getId()}", "{$this->getId()}:refresh" => 1), 'default', false); $lists->append($link); return $lists; } catch (Exception $e) { X_Debug::i("Location is not provided by RealDebrid"); } }
public function menuChannels(X_Page_ItemList_PItem $items) { $auth = ''; if ($this->config('auth.enabled', false)) { $auth = "&username="******"&userpassword="******"&option=andback"; } $page = X_PageParser_Page::getPage(sprintf(self::URL_CHANNELS, $auth), new X_PageParser_Parser_Preg('%<p style="font-size:12px;.+>(?P<label>.*?)</a></p>(.*\\n){5}.*<a href="http://weeb.tv/channel/(?P<href>.*?)" title="(.*?)"><img src="(?P<thumbnail>.*)" alt=".*?" height="100" width="100" /></a>%', X_PageParser_Parser_Preg::PREG_MATCH_ALL, PREG_SET_ORDER)); $this->preparePageLoader($page); $parsed = $page->getParsed(); foreach ($parsed as $match) { $thumbnail = $match['thumbnail']; $label = $match['label']; $href = $match['href']; $item = new X_Page_Item_PItem($this->getId() . "-{$label}", $label); $item->setIcon('/images/icons/file_32.png')->setType(X_Page_Item_PItem::TYPE_ELEMENT)->setCustom(__CLASS__ . ':location', "{$href}")->setDescription(APPLICATION_ENV == 'development' ? "{$href}" : null)->setThumbnail($thumbnail)->setLink(array('action' => 'mode', 'l' => X_Env::encode("{$href}")), 'default', false); $items->append($item); } }
private function _fetchVideos(X_Page_ItemList_PItem $items, $letter, $thread) { X_Debug::i("Fetching videos for {$letter}/{$thread}"); $baseUrl = $this->config('base.url', 'http://www.jigoku.it/anime-streaming/'); $baseUrl .= "{$thread}"; $htmlString = $this->_loadPage($baseUrl, true); $dom = new Zend_Dom_Query($htmlString); // xpath index stars from 1 $results = $dom->queryXpath('//div[@class="elenco"]//td[@class="serie"]/a'); X_Debug::i("Links found: " . $results->count()); //$found = false; for ($i = 0; $i < $results->count(); $i++, $results->next()) { $current = $results->current(); $label = trim(trim($current->textContent), chr(0xc2) . chr(0xa0)); if ($label == '') { $label = X_Env::_('p_jigoku_nonamevideo'); } $href = $current->getAttribute('href'); // href format: /anime-streaming/b-gata-h-kei/8306/episodio-2/ @(list(, , $epId, $epName) = explode('/', trim($href, '/'))); // works even without the $epName $href = "{$epId}:{$epName}"; //$found = true; X_Debug::i("Valid link found: {$href}"); $item = new X_Page_Item_PItem($this->getId() . "-{$label}", $label); $item->setIcon('/images/icons/folder_32.png')->setType(X_Page_Item_PItem::TYPE_ELEMENT)->setCustom(__CLASS__ . ':location', "{$letter}/{$thread}/{$href}")->setLink(array('action' => 'mode', 'l' => X_Env::encode("{$letter}/{$thread}/{$href}")), 'default', false); if (APPLICATION_ENV == 'development') { $item->setDescription("{$letter}/{$thread}/{$href}"); } $items->append($item); } /* if (!$found) { $item = new X_Page_Item_PItem($this->getId().'-ops', X_Env::_('p_animedb_opsnovideo')); $item->setType(X_Page_Item_PItem::TYPE_ELEMENT) ->setLink(X_Env::completeUrl( //$urlHelper->url() )); $items->append($item); } */ }
/** * Add button -watch megavideo stream directly- * * @param string $provider * @param string $location * @param Zend_Controller_Action $controller */ public function preGetModeItems($provider, $location, Zend_Controller_Action $controller) { if ($provider != $this->getId()) { return; } X_Debug::i("Plugin triggered"); $url = $this->resolveLocation($location); if ($url != false) { $link = new X_Page_Item_PItem('core-directwatch', X_Env::_('p_onlinelibrary_watchdirectly')); $link->setIcon('/images/icons/play.png')->setType(X_Page_Item_PItem::TYPE_PLAYABLE)->setLink($url); return new X_Page_ItemList_PItem(array($link)); } else { X_Debug::i('Setting priority to filterModeItems'); $this->setPriority('filterModeItems', 99); $link = new X_Page_Item_PItem('invalidvideo-warning', X_Env::_('p_onlinelibrary_invalidlink')); $link->setIcon('/images/msg_error.png')->setType(X_Page_Item_PItem::TYPE_ELEMENT)->setLink(array('controller' => 'browse', 'action' => 'share', 'p' => $this->getId(), 'l' => X_Env::encode($location)), 'default', true); return new X_Page_ItemList_PItem(array($link)); } }
/** * Fill $items of links in page * @param X_Page_ItemList_PItem $items */ public function menuLinks(X_Page_ItemList_PItem $items, $id) { $bookmark = new Application_Model_Bookmark(); Application_Model_BookmarksMapper::i()->find($id, $bookmark); // invalid pageid! if ($bookmark->isNew()) { return; } $page = X_PageParser_Page::getPage($bookmark->getUrl(), new X_PageParser_Parser_HosterLinks($this->helpers()->hoster())); $loader = $page->getLoader(); if ($loader instanceof X_PageParser_Loader_Http || $loader instanceof X_PageParser_Loader_HttpAuthRequired) { $http = $loader->getHttpClient()->setConfig(array('maxredirects' => $this->config('request.maxredirects', 10), 'timeout' => $this->config('request.timeout', 25))); if ($bookmark->getUa()) { X_Debug::i("Setting User-Agent..."); $http->setHeaders(array("User-Agent: {$bookmark->getUa()}")); } if ($bookmark->getCookies()) { X_Debug::i("Setting Cookies..."); $http->setHeaders("Cookie", $bookmark->getCookies()); } } $links = $page->getParsed(); foreach ($links as $i => $link) { /* @var $bookmark Application_Model_Bookmark */ $item = new X_Page_Item_PItem("{$this->getId()}-{$bookmark->getId()}-{$i}", "{$link['label']} [{$link['hoster']->getId()}]"); $item->setIcon("/images/icons/hosters/{$link['hoster']->getId()}.png")->setType(X_Page_Item_PItem::TYPE_ELEMENT)->setCustom(__CLASS__ . ':location', "{$bookmark->getId()}/{$link['url']}")->setLink(array('l' => X_Env::encode("{$bookmark->getId()}/{$link['url']}"), 'action' => 'mode'), 'default', false); $items->append($item); } }
/** * Add the link for megavideo quality change * * @param string $provider * @param string $location * @param Zend_Controller_Action $controller * @return X_Page_ItemList_PItem */ public function getModeItems($provider, $location, Zend_Controller_Action $controller) { try { /* @var $megavideoHelper X_VlcShares_Plugins_Helper_Megavideo */ $megavideoHelper = $this->helpers('megavideo'); // check megavideo helper to be sure that location has been setted for check // if location is not setted, helper throwns an exception. // i don't care for the returned value $megavideoHelper->getServer(); X_Debug::i('Plugin triggered. Location could be provided by Megavideo'); $urlHelper = $controller->getHelper('url'); $subLabel = X_Env::_('p_megavideo_qualityselection_normal'); $subParam = $controller->getRequest()->getParam($this->getId() . ':quality', false); if ($subParam !== false) { //$subParam = X_Env::decode($subParam); //list($type, $source) = explode(':', $subParam, 2); $subLabel = X_Env::_("p_megavideo_qualitycode_{$subParam}"); if ($subLabel == "p_megavideo_qualitycode_{$subParam}") { $subLabel = $subParam; } } $link = new X_Page_Item_PItem($this->getId(), X_Env::_('p_megavideo_qualityselected') . ": {$subLabel}"); $link->setIcon('/images/megavideo/logo.png')->setType(X_Page_Item_PItem::TYPE_ELEMENT)->setLink(array('action' => 'selection', 'pid' => $this->getId()), 'default', false); return new X_Page_ItemList_PItem(array($link)); } catch (Exception $e) { X_Debug::i("Location is not provided by Megavideo Helper"); } }
protected function next($locationPrefix, $nextPage) { $item = new X_Page_Item_PItem('youtube-next', X_Env::_('p_youtube_nextbutton')); $item->setIcon('/images/youtube/icons/next.png')->setType(X_Page_Item_PItem::TYPE_ELEMENT)->setCustom(__CLASS__ . ':location', "{$locationPrefix}/{$nextPage}")->setLink(array('l' => X_Env::encode("{$locationPrefix}/{$nextPage}")), 'default', false)->setGenerator(__CLASS__); return $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 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); } } }
/** * Add the link for megavideo quality change * * @param string $provider * @param string $location * @param Zend_Controller_Action $controller * @return X_Page_ItemList_PItem */ public function getModeItems($provider, $location, Zend_Controller_Action $controller) { // if provider is FileSystem, JDownload isn't needed for sure if (X_VlcShares_Plugins::broker()->getPluginClass($provider) == 'X_VlcShares_Plugins_FileSystem') { return; } try { /* @var $megavideoHelper X_VlcShares_Plugins_Helper_Megavideo */ $megavideoHelper = $this->helpers('megavideo'); // check megavideo helper to be sure that location has been setted for check // if location is not setted, helper throwns an exception. // i don't care for the returned value $megavideoHelper->getServer(); X_Debug::i('Plugin triggered. Location could be provided by Megavideo'); $urlHelper = $controller->getHelper('url'); $link = new X_Page_Item_PItem($this->getId(), X_Env::_('p_jdownloader_downloadlink')); $link->setIcon('/images/jdownloader/logo.png')->setType(X_Page_Item_PItem::TYPE_ELEMENT)->setLink(array('action' => 'selection', 'pid' => $this->getId()), 'default', false); return new X_Page_ItemList_PItem(array($link)); } catch (Exception $e) { // this use the newer hoster api 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 $this->helpers()->hoster()->getHoster($hoster); $link = new X_Page_Item_PItem($this->getId(), X_Env::_('p_jdownloader_downloadlink')); $link->setIcon('/images/jdownloader/logo.png')->setType(X_Page_Item_PItem::TYPE_ELEMENT)->setLink(array('action' => 'selection', 'pid' => $this->getId()), 'default', false); return new X_Page_ItemList_PItem(array($link)); } catch (Exception $e) { X_Debug::i("Location is not provided by a valid plugin/hoster. Try direct download"); // last chance: allow to start download from the resolveLocation $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://")) { $link = new X_Page_Item_PItem($this->getId(), X_Env::_('p_jdownloader_downloadlink_location', $url)); $link->setIcon('/images/jdownloader/logo.png')->setType(X_Page_Item_PItem::TYPE_ELEMENT)->setLink(array('action' => 'selection', 'pid' => $this->getId()), 'default', false); return new X_Page_ItemList_PItem(array($link)); } else { X_Debug::i("Location isn't http or https"); } } } } }
/** * Return a list of page items for the current $location * if the $provider is this */ public function getShareItems($provider, $location, Zend_Controller_Action $controller) { // this plugin add items only if it is the provider if ($provider != $this->getId()) { return; } X_Debug::i("Plugin triggered"); // 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 } $urlHelper = $controller->getHelper('url'); $items = new X_Page_ItemList_PItem(); if ($location != '') { list($shareId, $path) = explode(':', $location, 2); $share = new Application_Model_FilesystemShare(); Application_Model_FilesystemSharesMapper::i()->find($shareId, $share); // TODO prevent ../ $browsePath = realpath($share->getPath() . $path); if (file_exists($browsePath)) { $dir = new DirectoryIterator($browsePath); foreach ($dir as $entry) { if ($entry->isDot()) { continue; } if ($entry->isDir()) { $item = new X_Page_Item_PItem($this->getId() . '-' . $entry->getFilename() . '/', "{$entry->getFilename()}/"); $item->setIcon('/images/icons/folder_32.png')->setType(X_Page_Item_PItem::TYPE_CONTAINER)->setCustom(__CLASS__ . ':location', "{$share->getId()}:{$path}{$entry->getFilename()}/")->setLink(array('l' => X_Env::encode("{$share->getId()}:{$path}{$entry->getFilename()}/")), 'default', false); $items->append($item); } else { if ($entry->isFile()) { $item = new X_Page_Item_PItem($this->getId() . '-' . $entry->getFilename(), "{$entry->getFilename()}"); $item->setIcon('/images/icons/file_32.png')->setType(X_Page_Item_PItem::TYPE_ELEMENT)->setCustom(__CLASS__ . ':location', "{$share->getId()}:{$path}{$entry->getFilename()}")->setLink(array('action' => 'mode', 'l' => X_Env::encode("{$share->getId()}:{$path}{$entry->getFilename()}")), 'default', false); $items->append($item); } else { // scarta i symlink continue; } } } } } else { // if location is not specified, // show collections $shares = Application_Model_FilesystemSharesMapper::i()->fetchAll(); foreach ($shares as $share) { /* @var $share Application_Model_FilesystemShare */ $item = new X_Page_Item_PItem($this->getId() . '-' . $share->getLabel(), $share->getLabel()); $item->setIcon('/images/icons/folder_32.png')->setDescription(APPLICATION_ENV == 'development' ? $share->getPath() : null)->setType(X_Page_Item_PItem::TYPE_CONTAINER)->setCustom(__CLASS__ . ':location', "{$share->getId()}:/")->setLink(array('l' => X_Env::encode("{$share->getId()}:/")), 'default', false); $items->append($item); } } return $items; }
private function _fetchVideos(X_Page_ItemList_PItem $items, $resourceType, $resourceGroup, $page, $resourceId) { X_Debug::i("Fetching videos for {$resourceType}, {$resourceGroup}, {$page}, {$resourceId}"); // as first thing we have to recreate the resource url from resourceId $url = self::URL_BASE; // in _fetchResources we converted / in : inside $resourceId and removed the last / // so to come back to the real address we have to undo this changes $url .= str_replace(':', '/', $resourceId) . '/'; // now url is something like http://film-stream.tv/01/01/2010/resource-name/ // loading page $htmlString = $this->_loadPage($url); // it's useless to execute pattern search in the whole page // so we stip from $htmlString only the usefull part $mainContentStart = '<div id="maincontent">'; $mainContentEnd = '<div id="sidebar">'; $mainContentStart = strpos($htmlString, $mainContentStart); if ($mainContentStart === false) { $mainContentStart = 0; } $mainContentEnd = strpos($htmlString, $mainContentEnd, $mainContentStart); // substr get a substring of $htmlString from $mainContentStart position to $mainContentEnd position - $mainContentStart position (is the fragment length) $htmlString = $mainContentEnd === false ? substr($htmlString, $mainContentStart) : substr($htmlString, $mainContentStart, $mainContentEnd - $mainContentStart); // let's define some pattern // $ytPattern will try to intercept // youtube trailer link // <param name="movie" value="http://www.youtube.com/v/VIDEOID?version=3"> // match[1] = video id $ytPattern = '/<param name\\=\\"movie\\" value\\=\\"http\\:\\/\\/www\\.youtube\\.com\\/v\\/([^\\?\\"\\&]+)([^\\>]*)>/'; $matches = array(); // first let's search for youtube videos if (preg_match_all($ytPattern, $htmlString, $matches, PREG_SET_ORDER)) { foreach ($matches as $match) { $videoId = self::VIDEO_YOUTUBE . ':' . $match[1]; $videoLabel = X_Env::_("p_filmstream_video_youtubetrailer"); $item = new X_Page_Item_PItem("{$this->getId()}-youtube-{$videoId}", $videoLabel); $item->setIcon('/images/icons/file_32.png')->setType(X_Page_Item_PItem::TYPE_ELEMENT)->setCustom(__CLASS__ . ':location', "{$resourceType}/{$resourceGroup}/{$page}/{$resourceId}/{$videoId}")->setLink(array('action' => 'mode', 'l' => X_Env::encode("{$resourceType}/{$resourceGroup}/{$page}/{$resourceId}/{$videoId}")), 'default', false); if (APPLICATION_ENV == 'development') { $item->setDescription("{$resourceType}/{$resourceGroup}/{$page}/{$resourceId}/{$videoId}"); } $items->append($item); } } else { X_Debug::e("Youtube pattern failure {{$ytPattern}}"); } $matches = array(); if (preg_match_all('/href\\=\\"(?P<LINK>[^\\"]+)"([^\\>]*)>(?P<LABEL>[^\\<]+)<\\/a>/', $htmlString, $matches, PREG_SET_ORDER)) { X_Debug::i(var_export($matches, true)); foreach ($matches as $match) { try { $link = $match['LINK']; $hoster = $this->helpers()->hoster()->findHoster($link); $videoLabel = trim(strip_tags($match['LABEL'])) . " [" . ucfirst($hoster->getId()) . "]"; $videoId = "{$hoster->getId()}:{$hoster->getResourceId($link)}"; $item = new X_Page_Item_PItem("{$this->getId()}-hoster-{$videoId}", $videoLabel); $item->setIcon('/images/icons/file_32.png')->setType(X_Page_Item_PItem::TYPE_ELEMENT)->setCustom(__CLASS__ . ':location', "{$resourceType}/{$resourceGroup}/{$page}/{$resourceId}/{$videoId}")->setLink(array('action' => 'mode', 'l' => X_Env::encode("{$resourceType}/{$resourceGroup}/{$page}/{$resourceId}/{$videoId}")), 'default', false); if (APPLICATION_ENV == 'development') { $item->setDescription("{$resourceType}/{$resourceGroup}/{$page}/{$resourceId}/{$videoId}"); } $items->append($item); } catch (Exception $e) { // no hoster for the link, skipped } } } else { X_Debug::e("General pattern failure"); } }
private function _fetchVideos(X_Page_ItemList_PItem $items, $type, $letter, $thread) { X_Debug::i("Fetching videos for {$type}/{$letter}/{$thread}"); if ($type == self::TYPE_SERIES_PERGENRE || $type == self::TYPE_SERIES_PERLETTER) { return $this->_fetchVideosAPI($items, $type, $letter, $thread); } $baseUrl = $this->config('base.url', self::BASE_URL); // threads for movies have / -> : conversion $_thread = str_replace(':', '/', $thread); $baseUrl .= "{$type}/{$_thread}"; $htmlString = $this->_loadPage($baseUrl, true); // XPATH doesn't work well. Maybe for kanji inside the page, so i use regex $cleaned = stristr(strstr($htmlString, 'Episodes:'), '</table>', true); $regexp = "<a\\s[^>]*href=(\"??)([^\" >]*?)\\1[^>]*>(.*)<\\/a>"; if (preg_match_all("/{$regexp}/siU", $cleaned, $matches, PREG_SET_ORDER)) { //X_Debug::i(var_export($matches, true)); foreach ($matches as $match) { // $match[2] = link address // $match[3] = link text $label = $match[3]; if ($label == '') { $label = X_Env::_('p_animeftw_nonamevideo'); } $href = $match[2]; // href format: http://www.animeftw.tv/videos/baccano/ep-3 if (X_Env::startWith($href, $this->config('base.url', self::BASE_URL))) { $href = substr($href, strlen($this->config('base.url', self::BASE_URL))); } // href format: videos/baccano/ep-3 @(list(, , $epName) = explode('/', trim($href, '/'))); // works even without the $epName $href = $epName; //$found = true; X_Debug::i("Valid link found: {$href}"); $item = new X_Page_Item_PItem($this->getId() . "-{$label}", $label); $item->setIcon('/images/icons/folder_32.png')->setType(X_Page_Item_PItem::TYPE_ELEMENT)->setCustom(__CLASS__ . ':location', "{$type}/{$letter}/{$thread}/{$href}")->setLink(array('action' => 'mode', 'l' => X_Env::encode("{$type}/{$letter}/{$thread}/{$href}")), 'default', false); if (APPLICATION_ENV == 'development') { $item->setDescription("{$type}/{$letter}/{$thread}/{$href}"); } $items->append($item); } } }
/** * Find links using an alternative way * @author Valerio Moretti */ private function _parseAlternativeScaper($htmlString, X_Page_ItemList_PItem $items, $category, $letter, $thread) { //mi suddivido il post in righe $htmlRows = explode('<br />', $htmlString); /* //qua volevo selezionarmi solo il codice del post per rendere il tutto piu' veloce //pero' sbaglio qualcosa e non mi funziona $dom = new Zend_Dom_Query($htmlString); $content = $dom->queryXpath('//ol[@id="posts"]/li[1]//div[@class="content"]'); $htmlPost = $content->current(); $htmlRows = explode('<br />', $htmlPost); */ //analizzo riga per riga foreach ($htmlRows as $row) { //la mia ignoranza del Xpath e' immensa e questo e' l'unico modo che ho trovato per farlo funzionare $row = '<root>' . $row . '</root>'; $dom = new Zend_Dom_Query($row); // xpath index stars from 1 $results = $dom->queryXpath('//a'); X_Debug::i("Links found: " . $results->count()); $found = false; $title = ''; //il testo del primo link della riga for ($i = 0; $i < $results->count(); $i++, $results->next()) { $current = $results->current(); $label = trim(trim($current->nodeValue), chr(0xc2) . chr(0xa0)); if ($label == '') { $label = X_Env::_('p_animedb_nonamevideo'); } if ($title == '') { $title = $label; } $href = $current->getAttribute('href'); try { $hoster = $this->helpers()->hoster()->findHoster($href); } catch (Exception $e) { // no hoster = no valid href continue; } $href = "{$hoster->getId()}:{$hoster->getResourceId($href)}"; $label = $label == $title ? $label : $title . ' | ' . $label; $label .= " [" . ucfirst($hoster->getId()) . "]"; $found = true; X_Debug::i("Valid link found: {$href}"); $item = new X_Page_Item_PItem($this->getId() . "-{$label}", $label); $item->setIcon('/images/icons/folder_32.png')->setType(X_Page_Item_PItem::TYPE_ELEMENT)->setCustom(__CLASS__ . ':location', "{$category}/{$letter}/{$thread}/{$href}")->setLink(array('action' => 'mode', 'l' => X_Env::encode("{$category}/{$letter}/{$thread}/{$href}")), 'default', false); if (APPLICATION_ENV == 'development') { $item->setDescription("{$category}/{$letter}/{$thread}/{$href}"); } $items->append($item); } } }
protected function fetchChannels(X_Page_ItemList_PItem $items, $gPage = 1, $groupId, $page = 1) { $xml = $this->_loadPage(self::CHANNELS_INDEX, 10); $dom = new Zend_Dom_Query($xml); $_channels = $dom->queryXpath('//group[@id="' . $groupId . '"]/channel'); $channels = array(); while ($_channels->valid()) { $current = $_channels->current(); $_channel = array('id' => $current->getAttribute('id')); try { $nameTag = $current->getElementsByTagName('name')->item(0); if ($nameTag->getAttribute('en') != '') { $_channel['title'] = $nameTag->getAttribute('en'); } else { $_channel['title'] = $nameTag->nodeValue; } } catch (Exception $e) { $_channels->next(); continue; } try { $sopTag = $current->getElementsByTagName('sop_address')->item(0); $_channel['url'] = trim($sopTag->nodeValue); } catch (Exception $e) { $_channels->next(); continue; } if ($_channel['id'] != '' && $_channel['title'] != '' && $_channel['url'] != '') { $channels[] = $_channel; } $_channels->next(); } $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', "{$gPage}/{$groupId}/" . ($page - 1))->setLink(array('l' => X_Env::encode("{$gPage}/{$groupId}/" . ($page - 1))), 'default', false); $items->append($item); } foreach ($this->helpers()->paginator()->getPage($channels, $page) as $channel) { $item = new X_Page_Item_PItem($this->getId() . "-{$groupId}-" . $channel['id'], $channel['title']); $item->setIcon('/images/icons/hosters/sopcast.png')->setType(X_Page_Item_PItem::TYPE_CONTAINER)->setCustom(__CLASS__ . ':location', "{$gPage}/{$groupId}/{$page}/sopcast:{$channel['url']}")->setDescription("{$gPage}/{$groupId}/{$page}/sopcast:{$channel['url']}")->setLink(array('action' => 'mode', 'l' => X_Env::encode("{$gPage}/{$groupId}/{$page}/sopcast:{$channel['url']}")), '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', "{$gPage}/{$groupId}/" . ($page + 1))->setLink(array('l' => X_Env::encode("{$gPage}/{$groupId}/" . ($page + 1))), 'default', false); $items->append($item); } }
/** * Add button -watch spainradio stream directly- * * @param string $provider * @param string $location * @param Zend_Controller_Action $controller */ public function preGetModeItems($provider, $location, Zend_Controller_Action $controller) { if ($provider != $this->getId()) { return; } X_Debug::i("Plugin triggered"); $url = $this->resolveLocation($location); if ($url) { $link = new X_Page_Item_PItem('core-directwatch', X_Env::_('p_spainradio_watchdirectly')); $link->setIcon('/images/icons/play.png')->setType(X_Page_Item_PItem::TYPE_PLAYABLE)->setLink($url); return new X_Page_ItemList_PItem(array($link)); } else { // if there is no link, i have to remove start-vlc button // and replace it with a Warning button X_Debug::i('Setting priority to filterModeItems'); $this->setPriority('filterModeItems', 99); $link = new X_Page_Item_PItem('megavideo-warning', X_Env::_('p_spainradio_invalidlink')); $link->setIcon('/images/msg_error.png')->setType(X_Page_Item_PItem::TYPE_ELEMENT)->setLink(array('controller' => 'browse', 'action' => 'share', 'p' => $this->getId(), 'l' => X_Env::encode($this->getParentLocation($location))), 'default', true); return new X_Page_ItemList_PItem(array($link)); } }
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; } } } }
private function _fetchVideos(X_Page_ItemList_PItem $items, $resourceType, $pageN, $resourceGroup, $resourceId) { X_Debug::i("Fetching videos for {$resourceType}, {$pageN}, {$resourceGroup}, {$resourceId}"); // as first thing we have to recreate the resource url from resourceId $url = sprintf(self::URL_BASE, $resourceId); $page = X_PageParser_Page::getPage($url, X_PageParser_Parser_StreamingOnlineVideos::instance()); $this->preparePageLoader($page); foreach ($page->getParsed() as $link) { $videoId = $link['videoId']; $hosterId = $link['hosterId']; $videoCode = $link['link']; $videoLabel = trim("{$link['label']} [{$link['hosterId']}]"); //$videoThumb = $link['thumbnail']; $item = new X_Page_Item_PItem("{$this->getId()}-hoster-{$hosterId}-{$videoId}", $videoLabel); $item->setIcon('/images/icons/file_32.png')->setType(X_Page_Item_PItem::TYPE_ELEMENT)->setCustom(__CLASS__ . ':location', "{$resourceType}/{$pageN}/{$resourceGroup}/{$resourceId}/{$videoCode}")->setLink(array('action' => 'mode', 'l' => X_Env::encode("{$resourceType}/{$pageN}/{$resourceGroup}/{$resourceId}/{$videoCode}")), 'default', false); if (APPLICATION_ENV == 'development') { $item->setDescription("{$resourceType}/{$pageN}/{$resourceGroup}/{$resourceId}/{$videoCode}"); } /* if ( $videoThumb ) { $item->setThumbnail($videoThumb); } */ $items->append($item); } }
private function _fetchVideos(X_Page_ItemList_PItem $items, $sortType, $subType, $page, $thread) { X_Debug::i("Fetching videos for {$sortType}/{$subType}/{$page}/{$thread}"); $url = $this->config('index.video.url', 'http://www.gogocinema.com/movie.php?movie_id=') . $thread; $htmlString = $this->_loadPage($url); $htmlString = str_replace(array("\n", "\r", "\t", chr(0xc2), chr(0xa0), chr(157)), '', $htmlString); //X_Debug::i($htmlString); //$megavideoPattern = '/href\=\"http:\/\/megavideo\.com\/\?([^\"]+)\" /'; //$megavideoPattern = '/<tr bgcolor\=\"#043F6E\"><td>\# ([^\"]+)\<\/td><\/tr><tr><td align\=\"center\"><a style\=\"color\:\#FFFFFF\;\" href\=\"http:\/\/megavideo\.com\/\?([^\"]+)\" target\=\"\_blank\">/'; //$youtubePattern = '/<tr bgcolor\=\"#043F6E\"><td>\# ([^\"]+)\<\/td><\/tr><tr><td align\=\"center\"><a style\=\"color\:\#FFFFFF\;\" href\=\"http\:\/\/youtube\.com\/watch\?v\=([^\"]+)\" target\=\"\_blank\">/'; $globalPattern = '/<tr bgcolor\\=\\"#043F6E\\"><td>\\# (?P<label>[^\\"]+)\\<\\/td><\\/tr><tr><td align\\=\\"center\\"><a style\\=\\"color\\:\\#FFFFFF\\;\\" href\\=\\"(?P<link>[^\\"]+)\\" target\\=\\"\\_blank\\">/'; $movietitlePattern = '/<td class\\=\\"movietitle\\" colspan \\= \\"3\\"><a href\\=\\"movie\\.php\\?movie_id=([^\\"]+)\\" style=\\"color\\:\\#E95C24\\;\\">([^\\"]+)<\\/a>/'; $matches = array(); if (preg_match($movietitlePattern, $htmlString, $matches)) { $movieTitle = "{$matches[2]}: "; } else { $movieTitle = ''; } $matches = array(); if (preg_match_all($globalPattern, $htmlString, $matches, PREG_SET_ORDER)) { X_Debug::i("Megavideo videos found: " . count($matches)); X_Debug::i(var_export($matches, true)); foreach ($matches as $video) { //@list(,$label, $videoId) = $video; $label = $video['label']; $link = $video['link']; try { $hoster = $this->helpers()->hoster()->findHoster($link); $label = strip_tags($label) . " [" . ucfirst($hoster->getId()) . "]"; //$videoId = self::TYPE_MEGAVIDEO.":$videoId"; $videoId = "{$hoster->getId()}:{$hoster->getResourceId($link)}"; $item = new X_Page_Item_PItem($this->getId() . "-{$hoster->getId()}", "{$movieTitle}{$label}"); $item->setIcon('/images/icons/file_32.png')->setType(X_Page_Item_PItem::TYPE_ELEMENT)->setCustom(__CLASS__ . ':location', "{$sortType}/{$subType}/{$page}/{$thread}/{$videoId}")->setLink(array('action' => 'mode', 'l' => X_Env::encode("{$sortType}/{$subType}/{$page}/{$thread}/{$videoId}")), 'default', false); if (APPLICATION_ENV == 'development') { $item->setDescription("{$sortType}/{$subType}/{$page}/{$thread}/{$videoId}"); } $items->append($item); } catch (Exception $e) { // no valid hoster for this link } } } else { X_Debug::i("Megavideo videos NOT found: " . var_export($matches, true)); X_Debug::i("No megavideo links found"); } /* $matches = array(); if ( preg_match_all($youtubePattern, $htmlString, $matches, PREG_SET_ORDER) ) { X_Debug::i("Youtube videos found: ".count($matches)); foreach ($matches as $video) { @list(,$label,$videoId) = $video; $label = strip_tags($label); $videoId = self::TYPE_YOUTUBE.":$videoId"; $item = new X_Page_Item_PItem($this->getId()."-youtube", "$movieTitle$label"); $item->setIcon('/images/icons/file_32.png') ->setType(X_Page_Item_PItem::TYPE_ELEMENT) ->setCustom(__CLASS__.':location', "$sortType/$subType/$page/$thread/$videoId") ->setLink(array( 'action' => 'mode', 'l' => X_Env::encode("$sortType/$subType/$page/$thread/$videoId") ), 'default', false); if ( APPLICATION_ENV == 'development' ) { $item->setDescription("$sortType/$subType/$page/$thread/$videoId"); } $items->append($item); } } */ }
/** * Add button -watch megavideo stream directly- * * @param string $provider * @param string $location * @param Zend_Controller_Action $controller */ public function preGetModeItems($provider, $location, Zend_Controller_Action $controller) { if ($provider != $this->getId()) { return; } X_Debug::i("Plugin triggered"); $url = $this->resolveLocation($location); if ($url) { $link = new X_Page_Item_PItem('core-directwatch', X_Env::_('p_animeland_watchdirectly')); $link->setIcon('/images/icons/play.png')->setType(X_Page_Item_PItem::TYPE_PLAYABLE)->setLink($url); return new X_Page_ItemList_PItem(array($link)); } }
private function _fetchVideos(X_Page_ItemList_PItem $items, $sortType, $subType, $page, $serie, $thread) { X_Debug::i("Fetching videos for {$sortType}/{$subType}/{$page}/{$serie}/{$thread}"); $url = $this->config('index.video.url', 'http://www.icefilms.info/membersonly/components/com_iceplayer/video.php?vid=') . $thread; $htmlString = $this->_loadPage($url); //$htmlString = str_replace(array("\n", "\r", "\t", chr(0xC2), chr(0xA0), chr(157)), '', $htmlString); X_Debug::i($htmlString); $catPattern = '/(*ANY)<div class\\=ripdiv><b>([^\\<]+)<\\/b>/'; //$urlPattern = '/url\=http\:\/\/www.megaupload.com\/\?d\=([^\&]+)&([^\>]+)>([^\<]+)</'; $urlPattern = '/onclick\\=\\\'go\\(([0-9]+)\\)\\\'\\>([^\\<]+)</'; $matches = array(); $links = array(); if (preg_match_all($catPattern, $htmlString, $matches, PREG_OFFSET_CAPTURE)) { for ($i = 0; $i < count($matches[0]); $i++) { //$links[$matches[1][$i][0]] = array(); $catLabel = $matches[1][$i][0]; if (array_key_exists($i + 1, $matches[0])) { if (!preg_match_all($urlPattern, substr($htmlString, $matches[0][$i][1], $matches[0][$i + 1][1] - $matches[0][$i][1]), $lMatches, PREG_SET_ORDER)) { X_Debug::e("Pattern failure: {$urlPattern}"); continue; } } else { if (!preg_match_all($urlPattern, substr($htmlString, $matches[0][$i][1]), $lMatches, PREG_SET_ORDER)) { X_Debug::e("Pattern failure: {$urlPattern}"); continue; } } //X_Debug::i(var_export($lMatches, true)); foreach ($lMatches as $lm) { //@list(, $muId, , $label) = $lm; @(list(, $muId, $label) = $lm); // $muId now is a videoId of Icefilms $label = "{$label} ({$catLabel})"; //$videoId = self::TYPE_MEGAUPLOAD.":$muId"; $videoId = $muId; $item = new X_Page_Item_PItem($this->getId() . "-megaupload", "{$label}"); $item->setIcon('/images/icons/file_32.png')->setType(X_Page_Item_PItem::TYPE_ELEMENT)->setCustom(__CLASS__ . ':location', "{$sortType}/{$subType}/{$page}/{$serie}/{$thread}/{$videoId}")->setLink(array('action' => 'mode', 'l' => X_Env::encode("{$sortType}/{$subType}/{$page}/{$serie}/{$thread}/{$videoId}")), 'default', false); if (APPLICATION_ENV == 'development') { $item->setDescription("{$sortType}/{$subType}/{$page}/{$serie}/{$thread}/{$videoId}"); } $items->append($item); } } } else { X_Debug::i("Pattern failure {$catPattern} or no video found"); } }