/** * Get category/video list * @param unknown_type $provider * @param unknown_type $location * @param Zend_Controller_Action $controller */ 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"); $urlHelper = $controller->getHelper('url'); $items = new X_Page_ItemList_PItem(); if ($location != '' && ($location == self::INDEX_NARUTO || $location == self::INDEX_ONEPIECE || $location == self::INDEX_BLEACH)) { $pageIndex = $this->config('index.url', 'http://www.dbforever.net/home.php') . "?page={$location}"; $htmlString = $this->_loadPage($pageIndex); $dom = new Zend_Dom_Query($htmlString); $results = $dom->queryXpath('//div[@align="left"]/a'); for ($i = 0; $i < $results->count(); $i++, $results->next()) { $node = $results->current(); $href = $node->getAttribute('href'); $label = $node->nodeValue; $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)->setLink(array('action' => 'mode', 'l' => X_Env::encode($href)), 'default', false); $items->append($item); } } else { $item = new X_Page_Item_PItem($this->getId() . '-' . self::INDEX_NARUTO, X_Env::_('p_dbforever_naruto_ep')); $item->setIcon('/images/icons/folder_32.png')->setType(X_Page_Item_PItem::TYPE_CONTAINER)->setCustom(__CLASS__ . ':location', self::INDEX_NARUTO)->setThumbnail('http://www.dbforever.net/img/banner/naruto_banner_grande.jpg')->setLink(array('l' => X_Env::encode(self::INDEX_NARUTO)), 'default', false); $items->append($item); $item = new X_Page_Item_PItem($this->getId() . '-' . self::INDEX_ONEPIECE, X_Env::_('p_dbforever_onepiece_ep')); $item->setIcon('/images/icons/folder_32.png')->setType(X_Page_Item_PItem::TYPE_CONTAINER)->setCustom(__CLASS__ . ':location', self::INDEX_ONEPIECE)->setThumbnail('http://www.dbforever.net/img/banner/onepiece_banner_grande.jpg')->setLink(array('l' => X_Env::encode(self::INDEX_ONEPIECE)), 'default', false); $items->append($item); $item = new X_Page_Item_PItem($this->getId() . '-' . self::INDEX_BLEACH, X_Env::_('p_dbforever_bleach_ep')); $item->setIcon('/images/icons/folder_32.png')->setType(X_Page_Item_PItem::TYPE_CONTAINER)->setCustom(__CLASS__ . ':location', self::INDEX_BLEACH)->setThumbnail('http://www.dbforever.net/img/banner/bleach_banner_grande.jpg')->setLink(array('l' => X_Env::encode(self::INDEX_BLEACH)), 'default', false); $items->append($item); } return $items; }
/** * 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; }
/** * Add the go to stream link (only if engine is rtmpdump) * * @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) { // ignore the call if streamer is not rtmpdump if (!$engine instanceof X_Streamer_Engine_RtmpDump) { return; } X_Debug::i('Plugin triggered'); $return = new X_Page_ItemList_PItem(); $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_outputs_gotostream')); $item->setType(X_Page_Item_PItem::TYPE_PLAYABLE)->setIcon('/images/icons/play.png')->setLink($outputLink); $return->append($item); /* $item = new X_Page_Item_PItem('controls-stop', X_Env::_('p_controls_stop')); $item->setType(X_Page_Item_PItem::TYPE_ELEMENT) ->setIcon('/images/icons/stop.png') ->setLink(array( 'controller' => 'controls', 'action' => 'execute', 'a' => 'stop', 'pid' => $this->getId(), ), 'default', false); $return->append($item); */ return $return; }
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; }
/** * Get category/video list * @param unknown_type $provider * @param unknown_type $location * @param Zend_Controller_Action $controller */ 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"); $urlHelper = $controller->getHelper('url'); $items = new X_Page_ItemList_PItem(); if ($location != '') { // try to disable SortItems plugin, so link are listed as in html page X_VlcShares_Plugins::broker()->unregisterPluginClass('X_VlcShares_Plugins_SortItems'); $pageIndex = rtrim($this->config('base.url', 'http://www.animeland.it/'), '/') . "/{$location}"; $htmlString = $this->_loadPage($pageIndex); $dom = new Zend_Dom_Query($htmlString); $results = $dom->queryXpath('//a[@href!="menu_streaming.html"]'); for ($i = 0; $i < $results->count(); $i++, $results->next()) { $node = $results->current(); $href = $node->getAttribute('href'); $label = $node->nodeValue; $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)->setLink(array('action' => 'mode', 'l' => X_Env::encode($href)), 'default', false); $items->append($item); } } else { $pageIndex = rtrim($this->config('base.url', 'http://www.animeland.it/'), '/') . "/" . $this->config('index.page', 'menu_streaming.html'); $htmlString = $this->_loadPage($pageIndex); $dom = new Zend_Dom_Query($htmlString); $results = $dom->queryXpath('//a[@href!="menu_streaming.html"]'); for ($i = 0; $i < $results->count(); $i++, $results->next()) { $node = $results->current(); $href = $node->getAttribute('href'); $label = $node->nodeValue; $target = $node->getAttribute('target'); if ($target == '_blank') { $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)->setLink(array('action' => 'mode', 'l' => X_Env::encode($href)), 'default', false); $items->append($item); } else { $item = new X_Page_Item_PItem($this->getId() . '-' . $label, $label); $item->setIcon('/images/icons/folder_32.png')->setType(X_Page_Item_PItem::TYPE_CONTAINER)->setCustom(__CLASS__ . ':location', $href)->setLink(array('action' => 'share', 'l' => X_Env::encode($href)), 'default', false); $items->append($item); } } } return $items; }
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); } }
/** * 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; }
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) { $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; }
/** * Add pause/resume, stop, forward, rewind, shift buttons * @param X_Streamer_Engine $engine streamer engine * @param Zend_Controller_Action $controller the controller who handle the request * @return X_Page_ItemList_PItem */ public function getControlItems(X_Streamer_Engine $engine, Zend_Controller_Action $controller) { $urlHelper = $controller->getHelper('url'); $return = new X_Page_ItemList_PItem(); if ($this->config('stop.enabled', true)) { // stop $item = new X_Page_Item_PItem('controls-stop', X_Env::_('p_controls_stop')); $item->setType(X_Page_Item_PItem::TYPE_ELEMENT)->setIcon('/images/icons/stop.png')->setLink(array('controller' => 'controls', 'action' => 'execute', 'a' => 'stop', 'pid' => $this->getId()), 'default', false); $return->append($item); } if ($engine instanceof X_Streamer_Engine_Vlc) { if ($this->config('pauseresume.enabled', false)) { // pause/resume $item = new X_Page_Item_PItem('controls-pauseresume', X_Env::_('p_controls_pauseresume')); $item->setType(X_Page_Item_PItem::TYPE_ELEMENT)->setIcon('/images/icons/pause.png')->setLink(array('controller' => 'controls', 'action' => 'execute', 'a' => 'pause', 'pid' => $this->getId()), 'default', false); $return->append($item); } if ($this->config('forwardrelative.enabled', false)) { // forward relative $item = new X_Page_Item_PItem('controls-forwardcustom', X_Env::_('p_controls_forwardcustom')); $item->setType(X_Page_Item_PItem::TYPE_REQUEST)->setIcon('/images/icons/forward.png')->setDescription(X_Env::_('p_controls_forwardcustom_desc'))->setLink(array('controller' => 'controls', 'action' => 'execute', 'a' => 'forward', 'pid' => $this->getId(), 'param' => ''), 'default', false); $return->append($item); } if ($this->config('backrelative.enabled', false)) { // rewind relative $item = new X_Page_Item_PItem('controls-backcustom', X_Env::_('p_controls_backcustom')); $item->setType(X_Page_Item_PItem::TYPE_REQUEST)->setIcon('/images/icons/back.png')->setDescription(X_Env::_('p_controls_backcustom_desc'))->setLink(array('controller' => 'controls', 'action' => 'execute', 'a' => 'back', 'pid' => $this->getId(), 'param' => ''), 'default', false); $return->append($item); } if ($this->config('seek.enabled', true)) { // seek to time $item = new X_Page_Item_PItem('controls-seek', X_Env::_('p_controls_seektominute')); $item->setType(X_Page_Item_PItem::TYPE_REQUEST)->setIcon('/images/icons/seek.png')->setDescription(X_Env::_('p_controls_seektominute_desc'))->setLink(array('controller' => 'controls', 'action' => 'execute', 'a' => 'seek', 'pid' => $this->getId(), 'param' => ''), 'default', false); $return->append($item); } if ($this->config('oldstylecontrols.enabled', false)) { $item = new X_Page_Item_PItem('controls-back5', X_Env::_('p_controls_back_5')); $item->setType(X_Page_Item_PItem::TYPE_ELEMENT)->setIcon('/images/icons/back.png')->setLink(array('controller' => 'controls', 'action' => 'execute', 'a' => 'back', 'pid' => $this->getId(), 'param' => '5'), 'default', false); $return->append($item); $item = new X_Page_Item_PItem('controls-forward5', X_Env::_('p_controls_forward_5')); $item->setType(X_Page_Item_PItem::TYPE_ELEMENT)->setIcon('/images/icons/forward.png')->setLink(array('controller' => 'controls', 'action' => 'execute', 'a' => 'forward', 'pid' => $this->getId(), 'param' => '5'), 'default', false); $return->append($item); $item = new X_Page_Item_PItem('controls-back30', X_Env::_('p_controls_back_30')); $item->setType(X_Page_Item_PItem::TYPE_ELEMENT)->setIcon('/images/icons/back.png')->setLink(array('controller' => 'controls', 'action' => 'execute', 'a' => 'back', 'pid' => $this->getId(), 'param' => '30'), 'default', false); $return->append($item); $item = new X_Page_Item_PItem('controls-forward30', X_Env::_('p_controls_forward_30')); $item->setType(X_Page_Item_PItem::TYPE_ELEMENT)->setIcon('/images/icons/forward.png')->setLink(array('controller' => 'controls', 'action' => 'execute', 'a' => 'forward', 'pid' => $this->getId(), 'param' => '30'), 'default', false); $return->append($item); } } return $return; }
/** * Get category/video list * @param unknown_type $provider * @param unknown_type $location * @param Zend_Controller_Action $controller */ 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"); // try to disable SortItems plugin, so link are listed as in html page X_VlcShares_Plugins::broker()->unregisterPluginClass('X_VlcShares_Plugins_SortItems'); $urlHelper = $controller->getHelper('url'); $items = new X_Page_ItemList_PItem(); if ($location != '' && array_key_exists((int) $location, $this->seasons)) { // episodes list $url = $this->seasons[(int) $location]; $html = $this->_loadPage($url); $dom = new Zend_Dom_Query($html); $results = $dom->queryXpath('//div[@id="randomVideos"]//div[@class="randomTab"]//a[@class="previewDescriptionTitle"]'); $resultsImages = $dom->queryXpath('//div[@id="randomVideos"]//div[@class="randomTab"]//img[1]/attribute::src'); for ($i = 0; $i < $results->count(); $i++, $results->next()) { $node = $results->current(); $href = $node->getAttribute('href'); $label = $node->nodeValue; $id = explode('id=', $href, 2); $id = @$id[1]; $thumb = null; try { if ($resultsImages->valid()) { $thumb = $resultsImages->current()->nodeValue; $resultsImages->next(); } } catch (Exception $e) { $thumb = null; } $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', $id)->setLink(array('action' => 'mode', 'l' => X_Env::encode($id)), 'default', false); if ($thumb !== null) { $item->setThumbnail($thumb); } $items->append($item); } } else { foreach ($this->seasons as $key => $seasons) { $item = new X_Page_Item_PItem($this->getId() . '-' . $key, X_Env::_('p_allsp_season_n') . ": {$key}"); $item->setIcon('/images/icons/folder_32.png')->setType(X_Page_Item_PItem::TYPE_CONTAINER)->setCustom(__CLASS__ . ':location', $key)->setLink(array('action' => 'share', 'l' => X_Env::encode($key)), 'default', false); $items->append($item); } } return $items; }
private function _prepareVideo(X_Page_ItemList_PItem $items, Zend_Gdata_Media_Feed $feed, $locationPrefix) { foreach ($feed as $yvideo) { /* @var $yvideo Zend_Gdata_YouTube_VideoEntry */ if ($yvideo->getVideoDuration() == 0) { continue; } // no duration = no video $item = new X_Page_Item_PItem('youtube-video-' . $yvideo->getVideoId(), $yvideo->getVideoTitle() . ' [' . X_Env::formatTime($yvideo->getVideoDuration()) . ']'); $thumb = $yvideo->getVideoThumbnails(); @($thumb = $thumb[0]['url']); $item->setDescription($yvideo->getVideoDescription())->setType(X_Page_Item_PItem::TYPE_ELEMENT)->setIcon('/images/youtube/icons/video.png')->setThumbnail($thumb)->setCustom(__CLASS__ . ':location', "{$locationPrefix}/{$yvideo->getVideoId()}")->setLink(array('action' => 'mode', 'l' => X_Env::encode("{$locationPrefix}/{$yvideo->getVideoId()}")), 'default', false)->setGenerator(__CLASS__); $items->append($item); } }
protected function fetchItems(X_Page_ItemList_PItem $items, $group, $thread) { if ($group == self::GROUP_LIVE) { $html = $this->_loadPage(self::INDEX_LIVE, 10); $pattern = '/<td class\\=\\"competition\\">(?P<label>[^\\<]{1}[^\\<]*)<\\/td>/'; $matches = array(); if (preg_match_all($pattern, $html, $matches, PREG_OFFSET_CAPTURE)) { $labels = $matches['label']; if (count($labels) <= $thread) { // invalid thread values, emptyyyyyy!!! return; } $start = $labels[$thread][1]; $end = null; if (array_key_exists($thread + 1, $labels)) { $end = $labels[$thread + 1][1]; } // reducing the search area if ($end !== null) { $html = substr($html, $start, $end - $start); } else { $html = substr($html, $start); } $pattern = '/window\\.open\\(\'(?P<url>[^\\\']*)\'\\)[^\\>]*>(?P<label>[^\\<]*)/'; $matches = array(); if (preg_match_all($pattern, $html, $matches, PREG_SET_ORDER)) { foreach ($matches as $i => $match) { $item = new X_Page_Item_PItem("{$this->getId()}-live-{$thread}-{$i}", $match['label']); $item->setIcon('/images/icons/hosters/direct-url.png')->setType(X_Page_Item_PItem::TYPE_ELEMENT)->setCustom(__CLASS__ . ":location", "{$group}/{$thread}/direct-url:{$match['url']}")->setLink(array('action' => 'mode', 'l' => X_Env::encode("{$group}/{$thread}/direct-url:{$match['url']}")), 'default', false); $items->append($item); } } else { X_Debug::e("Thread pattern failure {{$pattern}}"); } } else { X_Debug::e("Group pattern failure {{$pattern}}"); } } elseif ($group == self::GROUP_EVENTS) { $html = $this->_loadPage(self::INDEX_MATCH . $thread, 10); $pattern = '/<span class\\=\\"subtext\\"><b>(?P<label>[^\\<]+)<\\/b><\\/span><\\/td><td width\\=\\"50\\" class\\=\\"itemlist\\_alt.\\"><span class\\=\\"subtext\\"><a href\\=\\"(?P<url>[^\\"]+)\\" target\\=\\"\\_BLANK\\">Play<\\/a>/'; $matches = array(); if (preg_match_all($pattern, $html, $matches, PREG_SET_ORDER)) { foreach ($matches as $i => $match) { try { $hoster = $this->helpers()->hoster()->findHoster($match['url']); $id = $hoster->getResourceId($match['url']); $hosterId = $hoster->getId(); $label = "{$match['label']} [" . ucfirst($hosterId) . "]"; $item = new X_Page_Item_PItem("{$this->getId()}-events-{$thread}-{$i}", $label); $item->setIcon("/images/icons/hosters/{$hosterId}.png")->setType(X_Page_Item_PItem::TYPE_ELEMENT)->setCustom(__CLASS__ . ":location", "{$group}/{$thread}/{$hosterId}:{$id}")->setLink(array('action' => 'mode', 'l' => X_Env::encode("{$group}/{$thread}/{$hosterId}:{$id}")), 'default', false); $items->append($item); } catch (Exception $e) { X_Debug::i("No supported hoster for url {{$match['url']}}"); } } } else { X_Debug::e("Thread pattern failure {{$pattern}}"); } } }
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; }
/** * Get category/video list * @param unknown_type $provider * @param unknown_type $location * @param Zend_Controller_Action $controller */ public function getShareItems($provider, $location, Zend_Controller_Action $controller) { if ($provider != $this->getId()) { return; } X_Debug::i('Plugin triggered'); X_VlcShares_Plugins::broker()->unregisterPluginClass('X_VlcShares_Plugins_SortItems'); if (X_VlcShares_Plugins::broker()->isRegistered('cache')) { $cachePlugin = X_VlcShares_Plugins::broker()->getPlugins('cache'); if (method_exists($cachePlugin, 'setDoNotCache')) { $cachePlugin->setDoNotCache(); } } $items = new X_Page_ItemList_PItem(); foreach ($this->channels as $name => $url) { $item = new X_Page_Item_PItem($this->getId() . "-{$url}", $name); $item->setIcon('/images/icons/file_32.png')->setType(X_Page_Item_PItem::TYPE_CONTAINER)->setCustom(__CLASS__ . ':location', $url)->setLink(array('l' => X_Env::encode($url), 'action' => 'mode'), 'default', false)->setThumbnail('/vlc-shares/public/images/spainradio/' . $url . '.png'); //new a thumbnail. $items->append($item); } return $items; }
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 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); } }
/** * Fill an X_Page_ItemList_PItem object ($items) with a * simple list of static values * @param X_Page_ItemList_PItem $items * @param array $menuEntries an array of menu entries, keys are locations and values are label keys * @param string $keyPrefix a string prepended to all items key * @param string $locationPrefix a string prepended to all items location * @return X_Page_ItemList_PItem */ static function fillStaticMenu(X_Page_ItemList_PItem $items, $menuEntries = array(), $keyPrefix = '', $locationPrefix = '') { foreach ($menuEntries as $location => $labelKey) { $entry = new X_Page_Item_PItem("{$keyPrefix}-{$location}", X_Env::_($labelKey)); $entry->setDescription(APPLICATION_ENV == 'development' ? "{$locationPrefix}{$location}" : null); $entry->setGenerator(__METHOD__)->setIcon('/images/icons/folder_32.png')->setCustom(__METHOD__ . ":location", "{$locationPrefix}{$location}")->setType(X_Page_Item_PItem::TYPE_CONTAINER)->setLink(array('l' => X_Env::encode("{$locationPrefix}{$location}")), 'default', false); $items->append($entry); } return $items; }
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'); try { /* $provider = X_VlcShares_Plugins::broker()->getPlugins($provider); $providerClass = get_class($provider); // i try to mark current selected profile based on $this->getId() param // in $profileLabel i get the name of the current profile $currentLabel = false; $profileId = $controller->getRequest()->getParam($this->getId(), false); if ( $profileId !== false ) { $_profile = new Application_Model_Profile(); Application_Model_ProfilesMapper::i()->find($profileId, $_profile); if ( $_profile->getId() != null ) { $currentLabel = $_profile->getLabel(); } } // if i can resolve the real location of the item // i can try to use special profiles $codecCond = null; if ( $provider instanceof X_VlcShares_Plugins_ResolverInterface ) { // location param come in a plugin encoded way $location = $provider->resolveLocation($location); $codecCond = array(); $this->helpers()->stream()->setLocation($location); if ( $this->helpers()->stream()->getVideoStreamsNumber() ) { $codecCond[] = $this->helpers()->stream()->getVideoCodecName(); } if ( $this->helpers()->stream()->getVideoStreamsNumber() ) { $codecCond[] = $this->helpers()->stream()->getAudioCodecName(); } $codecCond = implode('+', $codecCond); if ( $codecCond == '') $codecCond = null; } $deviceCond = $this->helpers()->devices()->getDeviceType(); $profiles = Application_Model_ProfilesMapper::i()->fetchByConds($codecCond, $deviceCond, $providerClass); */ // i try to mark current selected profile based on $this->getId() param // in $profileLabel i get the name of the current profile $currentLabel = false; $profileId = $controller->getRequest()->getParam($this->getId(), false); if ($profileId !== false) { $_profile = new Application_Model_Profile(); Application_Model_ProfilesMapper::i()->find($profileId, $_profile); if ($_profile->getId() != null) { $currentLabel = $_profile->getLabel(); } } $defaultId = $this->helpers()->devices()->getDefaultDeviceIdProfile(); $profile = new Application_Model_Profile(); Application_Model_ProfilesMapper::i()->find($defaultId, $profile); $profiles = array($profile); $extraIds = $this->helpers()->devices()->getDevice()->getExtra('alt-profiles'); //X_Debug::i("Profiles: ".$extraIds); if ($extraIds && is_array($extraIds) && count($extraIds)) { foreach ($extraIds as $id) { if ($defaultId == $id) { continue; } $profile = new Application_Model_Profile(); Application_Model_ProfilesMapper::i()->find($id, $profile); if ($profile->getId()) { $profiles[] = $profile; } } } $return = new X_Page_ItemList_PItem(); /* $item = new X_Page_Item_PItem($this->getId().'-auto', X_Env::_('p_profiles_selection_auto')); $item->setType(X_Page_Item_PItem::TYPE_ELEMENT) ->setLink(array( 'action' => 'mode', $this->getId() => null, // unset this plugin selection 'pid' => null ), 'default', false) ->setHighlight($currentLabel === false); $return->append($item); */ if (count($profiles)) { X_Debug::e("No valid profiles for this device: i need at least a profile"); } // the best is the first foreach ($profiles as $profile) { /* @var $profile Application_Model_Profile */ X_Debug::i("Valid profile: [{$profile->getId()}] {$profile->getLabel()}"); $item = new X_Page_Item_PItem($this->getId() . '-' . $profile->getId(), $profile->getLabel() . ($profile->getId() == $defaultId ? " [" . X_Env::_('p_profiles_selection_auto') . "]" : '')); $item->setType(X_Page_Item_PItem::TYPE_ELEMENT)->setLink(array('action' => 'mode', 'pid' => null, $this->getId() => $profile->getId()), 'default', false)->setHighlight($currentLabel == $profile->getLabel() || !$currentLabel && $profile->getId() == $defaultId); $return->append($item); } // general profiles are in the bottom of array return $return; } catch (Exception $e) { X_Debug::f("Problem while getting provider obj: {$e->getMessage()}"); throw $e; } }
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); } }
/** * Get category/video list * @param unknown_type $provider * @param unknown_type $location * @param Zend_Controller_Action $controller */ 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"); $urlHelper = $controller->getHelper('url'); $items = new X_Page_ItemList_PItem(); /* if ( $location != '' ) { /* if ( $location == self::INDEX_SHIPPUDEN ) { */ //try to disable SortItems plugin, so link are listed as in html page X_VlcShares_Plugins::broker()->unregisterPluginClass('X_VlcShares_Plugins_SortItems'); $pageIndex = $this->config('index.shippuden.url', 'http://www.narutoget.com/naruto-shippuden-episodes/'); $htmlString = $this->_loadPage($pageIndex); $dom = new Zend_Dom_Query($htmlString); $results = $dom->queryXpath('//a[@class="movie"]'); for ($i = 0; $i < $results->count(); $i++, $results->next()) { $node = $results->current(); $href = $node->getAttribute('href'); $label = $node->nodeValue; $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)->setLink(array('action' => 'mode', 'l' => X_Env::encode($href)), 'default', false); $items->append($item); } /* } else { list($type, $cat) = @explode(':', $location, 2); if ( $cat != null ) { $htmlString = $this->_loadPage($cat); $dom = new Zend_Dom_Query($htmlString); $results = $dom->queryXpath('//a[@class="movie"]'); for ( $i = 0; $i < $results->count(); $i++, $results->next()) { $node = $results->current(); $href = $node->getAttribute('href'); $label = $node->nodeValue; $items[] = array( 'label' => "$label", 'link' => X_Env::completeUrl( $urlHelper->url( array( 'action' => 'mode', 'l' => X_Env::encode($href) ), 'default', false ) ), __CLASS__.':location' => $href ); } } else { $pageIndex = $this->config('index.naruto.url', 'http://www.narutoget.com/page/10-naruto-episodes-subbed/'); $htmlString = $this->_loadPage($pageIndex); $dom = new Zend_Dom_Query($htmlString); $results = $dom->queryXpath('//div[@id="side-a"]//div[@align="left"]//a'); for ( $i = 0; $i < $results->count(); $i++, $results->next()) { $node = $results->current(); $href = $node->getAttribute('href'); $label = $node->nodeValue; $items[] = array( 'label' => "$label", 'link' => X_Env::completeUrl( $urlHelper->url( array( 'action' => 'share', 'l' => X_Env::encode("$type:$href") ), 'default', false ) ), __CLASS__.':location' => "$type:$href" ); } } } } else { $items[] = array( 'label' => X_Env::_('p_narutoget_index_naruto'), 'link' => X_Env::completeUrl( $urlHelper->url( array( 'action' => 'share', 'l' => X_Env::encode(self::INDEX_NARUTO) ), 'default', false ) ), __CLASS__.':location' => self::INDEX_NARUTO ); $items[] = array( 'label' => X_Env::_('p_narutoget_index_shippuden'), 'link' => X_Env::completeUrl( $urlHelper->url( array( 'action' => 'share', 'l' => X_Env::encode(self::INDEX_SHIPPUDEN) ), 'default', false ) ), __CLASS__.':location' => self::INDEX_SHIPPUDEN ); } */ return $items; }
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); } }
/** * 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; }
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; } } } }
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); }
/** * 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); } } }
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); } */ }
/** * Get download queue status * @param unknown_type $provider * @param unknown_type $location * @param Zend_Controller_Action $controller * @return X_Page_ItemList_PItem */ 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 } // unregister sort plugin, it's useless now X_VlcShares_Plugins::broker()->unregisterPluginClass('X_VlcShares_Plugins_SortItems'); /* @var $jdHelper X_VlcShares_Plugins_Helper_JDownloader */ $jdHelper = $this->helpers('jdownloader'); /* @var $url Zend_View_Helper_Url */ $urlHelper = $controller->getHelper('url'); $packages = $jdHelper->getDownloads(); X_Debug::i("Packages found: " . count($packages)); $list = new X_Page_ItemList_PItem(); foreach ($packages as $package) { /* @var $package Application_Model_JDownloaderPackage */ if ($this->helpers()->devices()->isWiimc()) { $packageLabel = X_Env::_('p_jdownloader_share_packageentry_nohtml', $package->getName(), $package->getSize(), $package->getFilesCount(), $package->getETA(), $package->getPercent(), X_Env::_('p_jdownloader_downloadstate_' . ($package->isDownloading() ? '1' : '0'))); $packageDesc = X_Env::_('p_jdownloader_share_packageentry_desc_nohtml', $package->getSize(), $package->getFilesCount(), $package->getETA(), $package->getPercent(), X_Env::_('p_jdownloader_downloadstate_' . ($package->isDownloading() ? '1' : '0'))); } else { $packageLabel = X_Env::_('p_jdownloader_share_packageentry_html', $package->getName()); $packageDesc = X_Env::_('p_jdownloader_share_packageentry_desc_html', $package->getSize(), $package->getFilesCount(), $package->getETA(), $package->getPercent(), X_Env::_('p_jdownloader_downloadstate_' . ($package->isDownloading() ? '1' : '0'))); } $link = new X_Page_Item_PItem($this->getId() . '-package', $packageLabel); $link->setIcon('/images/icons/folder.png')->setDescription($packageDesc)->setType(X_Page_Item_PItem::TYPE_ELEMENT)->setLink(X_Env::completeUrl($urlHelper->url())); $list->append($link); X_Debug::i("{$package->getFilesCount()} files in package {$package->getName()}"); foreach ($package->getFiles() as $file) { /* @var $file Application_Model_JDownloaderFile */ if ($this->helpers()->devices()->isWiimc()) { $fileLabel = X_Env::_('p_jdownloader_share_fileentry_nohtml', $file->getName(), $file->getHoster(), $file->getPercent(), X_Env::_('p_jdownloader_downloadstate_' . ($file->isDownloading() ? '1' : '0'))); $fileDesc = X_Env::_('p_jdownloader_share_fileentry_desc_nohtml', $file->getHoster(), $file->getPercent(), X_Env::_('p_jdownloader_downloadstate_' . ($file->isDownloading() ? '1' : '0'))); } else { $fileLabel = X_Env::_('p_jdownloader_share_fileentry_html', $file->getName()); $fileDesc = X_Env::_('p_jdownloader_share_fileentry_desc_html', $file->getHoster(), $file->getPercent(), X_Env::_('p_jdownloader_downloadstate_' . ($file->isDownloading() ? '1' : '0'))); } $link = new X_Page_Item_PItem($this->getId() . '-file', $fileLabel); $link->setDescription($fileDesc)->setType(X_Page_Item_PItem::TYPE_ELEMENT)->setLink(X_Env::completeUrl($urlHelper->url())); $list->append($link); } } return $list; }
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"); } }