/**
  * 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 gen_afterPageBuild(X_Page_ItemList_PItem $list, Zend_Controller_Action $controller)
 {
     if (!$this->isDefaultRenderer()) {
         return;
     }
     X_Debug::i("Plugin triggered");
     $request = $controller->getRequest();
     $responseType = 'u:BrowseResponse';
     $num = count($list->getItems());
     if ($this->request['browseflag'] == 'BrowseMetadata') {
         $parentID = $this->_getParent($controller->getRequest());
         $item = new X_Page_Item_PItem('fake-item', "Container");
         $item->setLink(array_merge(array('controller' => $controller->getRequest()->getControllerName(), 'action' => $controller->getRequest()->getActionName()), $controller->getRequest()->getParams()));
         $item->setDescription("Fake description");
         $didl = X_Upnp::createMetaDIDL($item, $parentID, $num, $controller->getRequest()->getControllerName(), $controller->getRequest()->getActionName(), $controller->getRequest()->getParam('p', 'null'));
     } elseif ($this->request['browseflag'] == 'BrowseDirectChildren') {
         $parentID = $this->request['objectid'];
         $didl = X_Upnp::createDIDL($list->getItems(), $parentID, $num, $controller->getRequest()->getControllerName(), $controller->getRequest()->getActionName(), $controller->getRequest()->getParam('p', 'null'));
     }
     $xmlDIDL = $didl->saveXML();
     X_Debug::i("DIDL response: {$xmlDIDL}");
     // Build SOAP-XML reply from DIDL-XML and send it to upnp device
     $domSOAP = X_Upnp::createSOAPEnvelope($xmlDIDL, $num, $num, $responseType, $parentID);
     $soapXML = $domSOAP->saveXML();
     // turn off viewRenderer and Layout, add Content-Type and set response body
     $this->_render($soapXML, $controller);
 }
 /**
  * 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;
 }
 public function gen_afterPageBuild(X_Page_ItemList_PItem $items, Zend_Controller_Action $controller)
 {
     if (count($items->getItems()) == 0) {
         X_Debug::i("Plugin triggered");
         $item = new X_Page_Item_PItem('emptylists', X_Env::_('p_emptylists_moveaway'));
         $item->setType(X_Page_Item_PItem::TYPE_ELEMENT)->setLink(X_Env::completeUrl($controller->getHelper('url')->url()));
         $items->append($item);
     }
 }
 public function gen_afterPageBuild(X_Page_ItemList_PItem $items, Zend_Controller_Action $controller)
 {
     if ($this->helpers()->devices()->isWiimc() && $this->helpers()->devices()->isWiimcBeforeVersion('1.0.9')) {
         if (count($items->getItems()) === 1) {
             X_Debug::i("Plugin triggered");
             $item = new X_Page_Item_PItem('workaroundwiimcplaylistitemsbug', '-- Workaround for bug in Wiimc <= 1.0.9 --');
             $item->setType(X_Page_Item_PItem::TYPE_ELEMENT)->setLink(X_Env::completeUrl($controller->getHelper('url')->url()));
             $items->append($item);
         }
     }
 }
示例#6
0
 /**
  * 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;
 }
 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;
 }
 /**
  * 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);
     }
 }
 /**
  * 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;
 }
 protected function dispatchRequest(Zend_Controller_Request_Http $request, X_Page_ItemList_PItem $items, Zend_Controller_Action $controller)
 {
     /* @var $view Zend_Controller_Action_Helper_ViewRenderer */
     $view = $controller->getHelper('viewRenderer');
     /* @var $layout Zend_Layout_Controller_Action_Helper_Layout */
     $layout = $controller->getHelper('layout');
     try {
         $view->setNoRender(true);
         $layout->disableLayout();
     } catch (Exception $e) {
         X_Debug::e("Layout or View not enabled: " . $e->getMessage());
     }
     $result = array();
     $actionName = $request->getActionName();
     $controllerName = $request->getControllerName();
     $result['controller'] = $controllerName;
     $result['action'] = $actionName;
     $result['success'] = true;
     $result['items'] = array();
     /* @var $urlHelper Zend_Controller_Action_Helper_Url */
     $urlHelper = $controller->getHelper('url');
     $skipMethod = array('getCustom', 'getLinkParam', 'getLinkAction', 'getLinkController');
     foreach ($items->getItems() as $itemId => $item) {
         /* @var $item X_Page_Item_PItem */
         $aItem = array();
         $methods = get_class_methods(get_class($item));
         foreach ($methods as $method) {
             if (array_search($method, $skipMethod) !== false) {
                 continue;
             }
             if ($method == "getIcon") {
                 $aItem['icon'] = $request->getBaseUrl() . $item->getIcon();
             } elseif (X_Env::startWith($method, 'get')) {
                 $aItem[lcfirst(substr($method, 3))] = $item->{$method}();
             } elseif (X_Env::startWith($method, 'is')) {
                 $aItem[lcfirst(substr($method, 2))] = $item->{$method}();
             }
         }
         $result['items'][] = $aItem;
     }
     /* @var $jsonHelper Zend_Controller_Action_Helper_Json */
     $jsonHelper = $controller->getHelper('Json');
     $jsonHelper->direct($result, true, false);
 }
 /**
  * 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;
 }
示例#12
0
 /**
  * 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");
     $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;
 }
 /**
  * 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;
 }
 /**
  * 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);
         $items->append($item);
     }
     return $items;
 }
 public function collectionsAction()
 {
     $pageItems = new X_Page_ItemList_PItem();
     // links on top
     $pageItems->merge(X_VlcShares_Plugins::broker()->preGetCollectionsItems($this));
     // normal links
     $pageItems->merge(X_VlcShares_Plugins::broker()->getCollectionsItems($this));
     // bottom links
     $pageItems->merge(X_VlcShares_Plugins::broker()->postGetCollectionsItems($this));
     // filter out items (parental-control / hidden file / system dir)
     foreach ($pageItems->getItems() as $key => $item) {
         $results = X_VlcShares_Plugins::broker()->filterCollectionsItems($item, $this);
         if ($results != null && in_array(false, $results)) {
             //unset($pageItems[$key]);
             $pageItems->remove($item);
         }
     }
     // trigger for page creation
     X_VlcShares_Plugins::broker()->gen_afterPageBuild($pageItems, $this);
 }
示例#17
0
 /**
  * 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 streamAction()
 {
     $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', ''));
     $providerObj = X_VlcShares_Plugins::broker()->getPlugins($provider);
     // if provider is a resolver, i can use new streamer api
     if (X_VlcShares_Plugins::helpers()->streamer()->isEnabled() && $providerObj instanceof X_VlcShares_Plugins_ResolverInterface) {
         $url = $providerObj->resolveLocation($location);
         X_Debug::i("Resolved location: {{$url}}");
         // check if url is valid (resolver give null or false on error)
         if (!$url) {
             X_Debug::e("Invalid location: {$location}");
             throw new Exception("Stream location is invalid: {$url}");
         }
         $engine = X_VlcShares_Plugins::helpers()->streamer()->find($url);
         X_Debug::i("Streamer engine found: {{$engine->getId()}}");
         // automatically set the url as source param in the engine
         $engine->setSource($url);
         // NEW APIS
         // each arg is stored as in a LIFO stack. If i put top priority as first,
         // low priority args could override it. So i use an inverse priority insertion
         // register low priority args
         X_VlcShares_Plugins::broker()->preRegisterStreamerArgs($engine, $url, $provider, $location, $this);
         // register normal priority args
         X_VlcShares_Plugins::broker()->registerStreamerArgs($engine, $url, $provider, $location, $this);
         // register top priority args
         X_VlcShares_Plugins::broker()->postRegisterStreamerArgs($engine, $url, $provider, $location, $this);
         X_VlcShares_Plugins::broker()->preStartStreamer($engine, $url, $provider, $location, $this);
         $results = X_VlcShares_Plugins::broker()->canStartStreamer($engine, $url, $provider, $location, $this);
         $started = false;
         if (is_null($results) || !in_array(false, $results)) {
             X_Debug::i("Starting streamer {{$engine->getId()}}: {$engine}");
             $started = true;
             X_Streamer::i()->start($engine);
         } else {
             $pluginId = array_search(false, $results, true);
             X_Debug::f("Plugin {{$pluginId}} prevented streamer from starting...");
             //throw new Exception("Plugin {{$pluginId}} prevented streamer from starting");
         }
         X_VlcShares_Plugins::broker()->postStartStreamer($started, $engine, $url, $provider, $location, $this);
     } else {
         // otherwise i'm forced to fallback to old api
         //{{{ THIS CODE BLOCK WILL IS DEPRECATED AND WILL BE REMOVED IN 0.5.6 or 0.6
         //TODO remove in 0.5.6 or 0.6
         // each arg is stored as in a LIFO stack. If i put top priority as first,
         // low priority args could override it. So i use an inverse priority insertion
         // register low priority args
         X_VlcShares_Plugins::broker()->preRegisterVlcArgs($this->vlc, $provider, $location, $this);
         // register normal priority args
         X_VlcShares_Plugins::broker()->registerVlcArgs($this->vlc, $provider, $location, $this);
         // register top priority args
         X_VlcShares_Plugins::broker()->postRegisterVlcArgs($this->vlc, $provider, $location, $this);
         X_VlcShares_Plugins::broker()->preSpawnVlc($this->vlc, $provider, $location, $this);
         $this->vlc->spawn();
         X_VlcShares_Plugins::broker()->postSpawnVlc($this->vlc, $provider, $location, $this);
         try {
             $engine = X_VlcShares_Plugins::helpers()->streamer()->get('vlc');
         } catch (Exception $e) {
             X_Debug::w('No vlc streamer available');
             $engine = new X_Streamer_Engine_Vlc($this->vlc);
         }
         $url = $this->vlc->getArg('source');
         //}}}
     }
     $pageItems = new X_Page_ItemList_PItem();
     // i can't add here the go to play button
     // because i don't know the output type
     // i need to leave this to the plugins, too
     // i hope that an output manager plugin
     // will be always enabled
     // top links
     $pageItems->merge(X_VlcShares_Plugins::broker()->preGetStreamItems($engine, $url, $provider, $location, $this));
     // normal links
     $pageItems->merge(X_VlcShares_Plugins::broker()->getStreamItems($engine, $url, $provider, $location, $this));
     // bottom links
     $pageItems->merge(X_VlcShares_Plugins::broker()->postGetStreamItems($engine, $url, $provider, $location, $this));
     // trigger for page creation
     X_VlcShares_Plugins::broker()->gen_afterPageBuild($pageItems, $this);
 }
 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);
     }
 }
示例#20
0
 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);
     }
 }
 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;
 }
示例#22
0
 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);
     }
 }
示例#23
0
 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);
     }
     */
 }
示例#24
0
 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");
     }
 }
示例#25
0
 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;
     }
 }
示例#26
0
 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);
     }
 }
示例#27
0
 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;
             }
         }
     }
 }
 /**
  * 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;
 }
 /**
  * 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 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);
 }