/**
  * 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;
 }
Example #2
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;
 }
 /**
  * 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;
 }
 /**
  * Check the item in the collection should be filtered out
  * If return is false, the item will be discarded at 100%
  * If return is true, isn't sure that the item will be added
  * 'cause another plugin can prevent this
  * 
  * Plugins who check per-item acl or blacklist should hook here
  * 
  * @param X_Page_Item_PItem $item
  * @param string $provider
  * @param Zend_Controller_Action $controller
  * @return boolean true if item is ok, false if item should be discarded
  */
 public function filterShareItems(X_Page_Item_PItem $item, $provider, Zend_Controller_Action $controller)
 {
     $providerClass = X_VlcShares_Plugins::broker()->getPluginClass($provider);
     $providerObj = X_VlcShares_Plugins::broker()->getPlugins($provider);
     if (is_a($providerObj, 'X_VlcShares_Plugins_FileSystem')) {
         if ($item->getType() == X_Page_Item_PItem::TYPE_ELEMENT) {
             $itemLocation = $item->getCustom('X_VlcShares_Plugins_FileSystem:location');
             /* @var $urlHelper Zend_Controller_Action_Helper_Url */
             $urlHelper = $controller->getHelper('url');
             $path = $providerObj->resolveLocation($itemLocation);
             $thumb = new Application_Model_FsThumb();
             Application_Model_FsThumbsMapper::i()->fetchByPath($path, $thumb);
             if ($thumb->isNew()) {
                 $thumbUrl = X_Env::completeUrl($urlHelper->direct('thumb', 'fsthumbs', 'default', array('l' => X_Env::encode($itemLocation), 't' => 'dummy.jpg')));
             } else {
                 $thumbUrl = X_Env::completeUrl(Zend_Controller_Front::getInstance()->getBaseUrl() . $thumb->getUrl());
             }
             //$item->setDescription($itemLocation);
             $item->setThumbnail($thumbUrl);
         }
     }
     return true;
 }
Example #5
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);
     }
 }
 public function menuChannels(X_Page_ItemList_PItem $items)
 {
     /* @var $parsed SimpleXmlElement */
     $dom = simplexml_load_string($this->getChannelsList());
     $parsed = $dom->xpath('//stream');
     // failed xpath, no results
     if (!$parsed) {
         return;
     }
     foreach ($parsed as $match) {
         /* @var $match SimpleXmlElement */
         $id = (string) $match->title;
         $label = (string) $match->title . " [" . (string) $match->language . "]";
         $item = new X_Page_Item_PItem($this->getId() . "-{$id}", $label);
         $item->setType(X_Page_Item_PItem::TYPE_ELEMENT)->setCustom(__CLASS__ . ':location', "{$id}")->setDescription(APPLICATION_ENV == 'development' ? "{$id}" : null)->setIcon("/images/icons/hosters/direct-url.png")->setLink(array('action' => 'mode', 'l' => X_Env::encode("{$id}")), 'default', false);
         $items->append($item);
     }
 }
 public function deleteAction()
 {
     $request = $this->getRequest();
     $id = $request->getParam('id', null);
     $type = $request->getParam('type', 'video');
     if (!is_null($id)) {
         if ($type == 'video') {
             $video = new Application_Model_Video();
             Application_Model_VideosMapper::i()->find($id, $video);
             if ($video->getId()) {
                 $category = $video->getCategory();
                 Application_Model_VideosMapper::i()->delete($video);
                 $this->_helper->redirector('category', 'onlinelibrary', 'default', array('id' => X_Env::encode($category)));
             }
         } elseif ($type == 'category') {
             Application_Model_VideosMapper::i()->deleteCategory(X_Env::decode($id));
         }
     }
     $this->_helper->redirector('index', 'onlinelibrary');
 }
 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);
     }
 }
 /**
  * @see X_VlcShares_Plugins_ResolverInterface::resolveLocation
  * @param string $location
  * @return string real address of a resource
  */
 function resolveLocation($location = null)
 {
     if ($location == '' || $location == null) {
         return false;
     }
     // if it isn't in the channels array it's an invalid location
     if (!array_search($location, $this->channels)) {
         return null;
     }
     // X_Env::routeLink should be deprecated, but now is the best option
     $linkUrl = X_Env::routeLink('spainradio', 'proxy', array('v' => X_Env::encode($location)));
     $return = $linkUrl;
     return $return;
 }
Example #10
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);
     }
 }
 /**
  *	Add button -watch megavideo stream directly-
  * 
  * @param string $provider
  * @param string $location
  * @param Zend_Controller_Action $controller
  */
 public function preGetModeItems($provider, $location, Zend_Controller_Action $controller)
 {
     if ($provider != $this->getId()) {
         return;
     }
     X_Debug::i("Plugin triggered");
     $url = $this->resolveLocation($location);
     if ($url != false) {
         $link = new X_Page_Item_PItem('core-directwatch', X_Env::_('p_onlinelibrary_watchdirectly'));
         $link->setIcon('/images/icons/play.png')->setType(X_Page_Item_PItem::TYPE_PLAYABLE)->setLink($url);
         return new X_Page_ItemList_PItem(array($link));
     } else {
         X_Debug::i('Setting priority to filterModeItems');
         $this->setPriority('filterModeItems', 99);
         $link = new X_Page_Item_PItem('invalidvideo-warning', X_Env::_('p_onlinelibrary_invalidlink'));
         $link->setIcon('/images/msg_error.png')->setType(X_Page_Item_PItem::TYPE_ELEMENT)->setLink(array('controller' => 'browse', 'action' => 'share', 'p' => $this->getId(), 'l' => X_Env::encode($location)), 'default', true);
         return new X_Page_ItemList_PItem(array($link));
     }
 }
 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);
         }
     }
 }
 /**
  * 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;
 }
 /**
  * Return a list of page items for the current $location
  * if the $provider is this
  */
 public function getShareItems($provider, $location, Zend_Controller_Action $controller)
 {
     // this plugin add items only if it is the provider
     if ($provider != $this->getId()) {
         return;
     }
     X_Debug::i("Plugin triggered");
     // disabling cache plugin
     try {
         $cachePlugin = X_VlcShares_Plugins::broker()->getPlugins('cache');
         if (method_exists($cachePlugin, 'setDoNotCache')) {
             $cachePlugin->setDoNotCache();
         }
     } catch (Exception $e) {
         // cache plugin not registered, no problem
     }
     $urlHelper = $controller->getHelper('url');
     $items = new X_Page_ItemList_PItem();
     if ($location != '') {
         list($shareId, $path) = explode(':', $location, 2);
         $share = new Application_Model_FilesystemShare();
         Application_Model_FilesystemSharesMapper::i()->find($shareId, $share);
         // TODO prevent ../
         $browsePath = realpath($share->getPath() . $path);
         if (file_exists($browsePath)) {
             $dir = new DirectoryIterator($browsePath);
             foreach ($dir as $entry) {
                 if ($entry->isDot()) {
                     continue;
                 }
                 if ($entry->isDir()) {
                     $item = new X_Page_Item_PItem($this->getId() . '-' . $entry->getFilename() . '/', "{$entry->getFilename()}/");
                     $item->setIcon('/images/icons/folder_32.png')->setType(X_Page_Item_PItem::TYPE_CONTAINER)->setCustom(__CLASS__ . ':location', "{$share->getId()}:{$path}{$entry->getFilename()}/")->setLink(array('l' => X_Env::encode("{$share->getId()}:{$path}{$entry->getFilename()}/")), 'default', false);
                     $items->append($item);
                 } else {
                     if ($entry->isFile()) {
                         $item = new X_Page_Item_PItem($this->getId() . '-' . $entry->getFilename(), "{$entry->getFilename()}");
                         $item->setIcon('/images/icons/file_32.png')->setType(X_Page_Item_PItem::TYPE_ELEMENT)->setCustom(__CLASS__ . ':location', "{$share->getId()}:{$path}{$entry->getFilename()}")->setLink(array('action' => 'mode', 'l' => X_Env::encode("{$share->getId()}:{$path}{$entry->getFilename()}")), 'default', false);
                         $items->append($item);
                     } else {
                         // scarta i symlink
                         continue;
                     }
                 }
             }
         }
     } else {
         // if location is not specified,
         // show collections
         $shares = Application_Model_FilesystemSharesMapper::i()->fetchAll();
         foreach ($shares as $share) {
             /* @var $share Application_Model_FilesystemShare */
             $item = new X_Page_Item_PItem($this->getId() . '-' . $share->getLabel(), $share->getLabel());
             $item->setIcon('/images/icons/folder_32.png')->setDescription(APPLICATION_ENV == 'development' ? $share->getPath() : null)->setType(X_Page_Item_PItem::TYPE_CONTAINER)->setCustom(__CLASS__ . ':location', "{$share->getId()}:/")->setLink(array('l' => X_Env::encode("{$share->getId()}:/")), 'default', false);
             $items->append($item);
         }
     }
     return $items;
 }
 private function _fetchVideos(X_Page_ItemList_PItem $items, $resourceType, $resourceGroup, $page, $resourceId)
 {
     X_Debug::i("Fetching videos for {$resourceType}, {$resourceGroup}, {$page}, {$resourceId}");
     // as first thing we have to recreate the resource url from resourceId
     $url = self::URL_BASE;
     // in _fetchResources we converted / in : inside $resourceId and removed the last /
     // so to come back to the real address we have to undo this changes
     $url .= str_replace(':', '/', $resourceId) . '/';
     // now url is something like http://film-stream.tv/01/01/2010/resource-name/
     // loading page
     $htmlString = $this->_loadPage($url);
     // it's useless to execute pattern search in the whole page
     // so we stip from $htmlString only the usefull part
     $mainContentStart = '<div id="maincontent">';
     $mainContentEnd = '<div id="sidebar">';
     $mainContentStart = strpos($htmlString, $mainContentStart);
     if ($mainContentStart === false) {
         $mainContentStart = 0;
     }
     $mainContentEnd = strpos($htmlString, $mainContentEnd, $mainContentStart);
     // substr get a substring of $htmlString from $mainContentStart position to $mainContentEnd position - $mainContentStart position (is the fragment length)
     $htmlString = $mainContentEnd === false ? substr($htmlString, $mainContentStart) : substr($htmlString, $mainContentStart, $mainContentEnd - $mainContentStart);
     // let's define some pattern
     // $ytPattern will try to intercept
     // youtube trailer link
     // <param name="movie" value="http://www.youtube.com/v/VIDEOID?version=3">
     // match[1] = video id
     $ytPattern = '/<param name\\=\\"movie\\" value\\=\\"http\\:\\/\\/www\\.youtube\\.com\\/v\\/([^\\?\\"\\&]+)([^\\>]*)>/';
     $matches = array();
     // first let's search for youtube videos
     if (preg_match_all($ytPattern, $htmlString, $matches, PREG_SET_ORDER)) {
         foreach ($matches as $match) {
             $videoId = self::VIDEO_YOUTUBE . ':' . $match[1];
             $videoLabel = X_Env::_("p_filmstream_video_youtubetrailer");
             $item = new X_Page_Item_PItem("{$this->getId()}-youtube-{$videoId}", $videoLabel);
             $item->setIcon('/images/icons/file_32.png')->setType(X_Page_Item_PItem::TYPE_ELEMENT)->setCustom(__CLASS__ . ':location', "{$resourceType}/{$resourceGroup}/{$page}/{$resourceId}/{$videoId}")->setLink(array('action' => 'mode', 'l' => X_Env::encode("{$resourceType}/{$resourceGroup}/{$page}/{$resourceId}/{$videoId}")), 'default', false);
             if (APPLICATION_ENV == 'development') {
                 $item->setDescription("{$resourceType}/{$resourceGroup}/{$page}/{$resourceId}/{$videoId}");
             }
             $items->append($item);
         }
     } else {
         X_Debug::e("Youtube pattern failure {{$ytPattern}}");
     }
     $matches = array();
     if (preg_match_all('/href\\=\\"(?P<LINK>[^\\"]+)"([^\\>]*)>(?P<LABEL>[^\\<]+)<\\/a>/', $htmlString, $matches, PREG_SET_ORDER)) {
         X_Debug::i(var_export($matches, true));
         foreach ($matches as $match) {
             try {
                 $link = $match['LINK'];
                 $hoster = $this->helpers()->hoster()->findHoster($link);
                 $videoLabel = trim(strip_tags($match['LABEL'])) . " [" . ucfirst($hoster->getId()) . "]";
                 $videoId = "{$hoster->getId()}:{$hoster->getResourceId($link)}";
                 $item = new X_Page_Item_PItem("{$this->getId()}-hoster-{$videoId}", $videoLabel);
                 $item->setIcon('/images/icons/file_32.png')->setType(X_Page_Item_PItem::TYPE_ELEMENT)->setCustom(__CLASS__ . ':location', "{$resourceType}/{$resourceGroup}/{$page}/{$resourceId}/{$videoId}")->setLink(array('action' => 'mode', 'l' => X_Env::encode("{$resourceType}/{$resourceGroup}/{$page}/{$resourceId}/{$videoId}")), 'default', false);
                 if (APPLICATION_ENV == 'development') {
                     $item->setDescription("{$resourceType}/{$resourceGroup}/{$page}/{$resourceId}/{$videoId}");
                 }
                 $items->append($item);
             } catch (Exception $e) {
                 // no hoster for the link, skipped
             }
         }
     } else {
         X_Debug::e("General pattern failure");
     }
 }
 private function _fetchVideos(X_Page_ItemList_PItem $items, $type, $letter, $thread)
 {
     X_Debug::i("Fetching videos for {$type}/{$letter}/{$thread}");
     if ($type == self::TYPE_SERIES_PERGENRE || $type == self::TYPE_SERIES_PERLETTER) {
         return $this->_fetchVideosAPI($items, $type, $letter, $thread);
     }
     $baseUrl = $this->config('base.url', self::BASE_URL);
     // threads for movies have / -> : conversion
     $_thread = str_replace(':', '/', $thread);
     $baseUrl .= "{$type}/{$_thread}";
     $htmlString = $this->_loadPage($baseUrl, true);
     // XPATH doesn't work well. Maybe for kanji inside the page, so i use regex
     $cleaned = stristr(strstr($htmlString, 'Episodes:'), '</table>', true);
     $regexp = "<a\\s[^>]*href=(\"??)([^\" >]*?)\\1[^>]*>(.*)<\\/a>";
     if (preg_match_all("/{$regexp}/siU", $cleaned, $matches, PREG_SET_ORDER)) {
         //X_Debug::i(var_export($matches, true));
         foreach ($matches as $match) {
             // $match[2] = link address
             // $match[3] = link text
             $label = $match[3];
             if ($label == '') {
                 $label = X_Env::_('p_animeftw_nonamevideo');
             }
             $href = $match[2];
             // href format: http://www.animeftw.tv/videos/baccano/ep-3
             if (X_Env::startWith($href, $this->config('base.url', self::BASE_URL))) {
                 $href = substr($href, strlen($this->config('base.url', self::BASE_URL)));
             }
             // href format: videos/baccano/ep-3
             @(list(, , $epName) = explode('/', trim($href, '/')));
             // works even without the $epName
             $href = $epName;
             //$found = true;
             X_Debug::i("Valid link found: {$href}");
             $item = new X_Page_Item_PItem($this->getId() . "-{$label}", $label);
             $item->setIcon('/images/icons/folder_32.png')->setType(X_Page_Item_PItem::TYPE_ELEMENT)->setCustom(__CLASS__ . ':location', "{$type}/{$letter}/{$thread}/{$href}")->setLink(array('action' => 'mode', 'l' => X_Env::encode("{$type}/{$letter}/{$thread}/{$href}")), 'default', false);
             if (APPLICATION_ENV == 'development') {
                 $item->setDescription("{$type}/{$letter}/{$thread}/{$href}");
             }
             $items->append($item);
         }
     }
 }
 /**
  * Find links using an alternative way
  * @author Valerio Moretti
  */
 private function _parseAlternativeScaper($htmlString, X_Page_ItemList_PItem $items, $category, $letter, $thread)
 {
     //mi suddivido il post in righe
     $htmlRows = explode('<br />', $htmlString);
     /*
     //qua volevo selezionarmi solo il codice del post per rendere il tutto piu' veloce
     //pero' sbaglio qualcosa e non mi funziona
     
     $dom = new Zend_Dom_Query($htmlString);
     $content = $dom->queryXpath('//ol[@id="posts"]/li[1]//div[@class="content"]');
     $htmlPost = $content->current();
     
     $htmlRows = explode('<br />', $htmlPost);
     */
     //analizzo riga per riga
     foreach ($htmlRows as $row) {
         //la mia ignoranza del Xpath e' immensa e questo e' l'unico modo che ho trovato per farlo funzionare
         $row = '<root>' . $row . '</root>';
         $dom = new Zend_Dom_Query($row);
         // xpath index stars from 1
         $results = $dom->queryXpath('//a');
         X_Debug::i("Links found: " . $results->count());
         $found = false;
         $title = '';
         //il testo del primo link della riga
         for ($i = 0; $i < $results->count(); $i++, $results->next()) {
             $current = $results->current();
             $label = trim(trim($current->nodeValue), chr(0xc2) . chr(0xa0));
             if ($label == '') {
                 $label = X_Env::_('p_animedb_nonamevideo');
             }
             if ($title == '') {
                 $title = $label;
             }
             $href = $current->getAttribute('href');
             try {
                 $hoster = $this->helpers()->hoster()->findHoster($href);
             } catch (Exception $e) {
                 // no hoster = no valid href
                 continue;
             }
             $href = "{$hoster->getId()}:{$hoster->getResourceId($href)}";
             $label = $label == $title ? $label : $title . ' | ' . $label;
             $label .= " [" . ucfirst($hoster->getId()) . "]";
             $found = true;
             X_Debug::i("Valid link found: {$href}");
             $item = new X_Page_Item_PItem($this->getId() . "-{$label}", $label);
             $item->setIcon('/images/icons/folder_32.png')->setType(X_Page_Item_PItem::TYPE_ELEMENT)->setCustom(__CLASS__ . ':location', "{$category}/{$letter}/{$thread}/{$href}")->setLink(array('action' => 'mode', 'l' => X_Env::encode("{$category}/{$letter}/{$thread}/{$href}")), 'default', false);
             if (APPLICATION_ENV == 'development') {
                 $item->setDescription("{$category}/{$letter}/{$thread}/{$href}");
             }
             $items->append($item);
         }
     }
 }
 private function _fillPlaylist(X_Page_ItemList_PItem $items, $decoded, $lStack)
 {
     X_Debug::i("Decoded: " . print_r($decoded, true));
     // The format of $decoded (only notable parts):
     // {
     //		ok: true|false
     //		msg: $msg ; Setted only if ok = false
     //		folderId: $thisFolder
     //		folders: [
     //				{
     //					id: $folderID
     //					name: $folderName
     //				}, ...
     //			]
     //		objects: [
     //				{
     //					id: $objectID
     //					name: $objectName
     //					link: http://...?...&video=urlencoded(URL)&...
     //				},
     //				{
     //					id: $objectID
     //					name: $objectName
     //					link: http://...?...&host=megavideo&video=urlencoded(MEGAVIDEOURL)&...
     //				},
     //			]
     //		...
     // }
     foreach ($decoded->folders as $folder) {
         $_stack = $lStack;
         $_stack[] = $folder->id;
         $item = new X_Page_Item_PItem("opfitalia-folder-{$folder->id}", urldecode($folder->name));
         $item->setType(X_Page_Item_PItem::TYPE_CONTAINER)->setGenerator(__CLASS__)->setCustom(__CLASS__ . ':location', implode(':', $_stack))->setLink(array('l' => X_Env::encode(implode(':', $_stack))), 'default', false);
         $items->append($item);
     }
     foreach ($decoded->objects as $object) {
         $item = new X_Page_Item_PItem("opfitalia-video-{$object->id}", urldecode($object->name));
         $item->setType(X_Page_Item_PItem::TYPE_ELEMENT)->setGenerator(__CLASS__);
         // time to decode the link arg
         // file: index.php?page=show_streaming&video=http:\/\/www.dbforever.net\/strm\/onepiece\/one_piece_459.mp4&width=704&height=430
         // megavideo: index.php?page=show_streaming&host=megavideo&video=http:\/\/www.megavideo.com\/v\/GIV2R76V038221ac298ceb332a9cad75288c318b&width=640&height=480
         $link = explode('&', $object->link);
         $type = 'file';
         $href = '';
         foreach ($link as $sublink) {
             list($arg, $value) = @explode('=', $sublink, 2);
             if ($arg == 'host') {
                 if ($value == 'megavideo') {
                     $type = 'megavideo';
                 }
             }
             if ($arg == 'video') {
                 $href = str_replace('\\/', '/', urldecode($value));
             }
         }
         if ($type == 'megavideo') {
             // i gave to split the /v/ param only
             $splitted = explode('/v/', $href, 2);
             if (count($splitted) == 2) {
                 $href = $splitted[1];
             } else {
                 // try to decode it
                 // as ?v=
                 preg_match('#\\?v=(.+?)$#', $href, $id);
                 if (count($id) >= 2) {
                     $href = $id[1];
                 } else {
                     // if even this fail
                     // i have to skip thi entry
                     continue;
                 }
             }
             $item->setLabel($item->getLabel() . " [Megavideo]");
         }
         $item->setCustom(__CLASS__ . ':location', implode(':', $lStack) . "/{$type}/{$href}")->setLink(array('action' => 'mode', 'l' => X_Env::encode(implode(':', $lStack) . "/{$type}/{$href}")), 'default', false);
         $items->append($item);
     }
 }
Example #19
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;
 }
 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);
     }
 }
Example #21
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);
     }
     */
 }
 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");
     }
 }
 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;
 }
Example #24
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;
             }
         }
     }
 }
 public function browseAction()
 {
     /* @var $request Zend_Controller_Request_Http */
     $request = $this->getRequest();
     $path = X_Env::decode($request->getParam('p', ''));
     $filter = $request->getParam('f', 'file');
     $callback = $request->getParam('c', 'void');
     $return = array();
     // i can't browse inside a file :)
     if (!is_dir($path)) {
         $path = dirname($path);
     }
     $path = realpath($path);
     if (is_dir($path) && is_readable($path)) {
         $objects = scandir($path);
         foreach ($objects as $object) {
             if ($object != ".") {
                 if (@filetype($path . "/" . $object) == "dir" && is_readable($path . "/" . $object)) {
                     $return[] = array('type' => 'folder', 'path' => $path . "/" . $object . '/', 'label' => $object . '/', 'href' => $this->_helper->url('browse', 'configs', 'default', array('f' => $filter, 'p' => X_Env::encode($path . "/" . $object), 'c' => $callback)));
                 } elseif ($filter == 'file') {
                     //$array["/".$dir."/".$object] = md5_file($dir."/".$object);
                     $return[] = array('type' => 'file', 'path' => realpath($path . "/" . $object), 'label' => $object, 'c' => $callback);
                 }
             }
         }
         reset($objects);
     }
     usort($return, array(__CLASS__, 'sortFolderBased'));
     $return = array('path' => $path, 'filter' => $filter, 'items' => $return);
     if ($request->isXmlHttpRequest()) {
         $this->_helper->json($return);
     } else {
         $this->_helper->layout()->disableLayout();
         $this->view->callback = $callback;
         $this->view->path = $return['path'];
         $this->view->filter = $return['filter'];
         $this->view->items = $return['items'];
     }
 }
 function confirmAction()
 {
     $path = X_Env::decode($this->getRequest()->getParam('path', null));
     $type = $this->getRequest()->getParam('type', null);
     $form = new X_Form();
     $form->setMethod(Zend_Form::METHOD_POST)->setAction($this->_helper->url('delete', 'fsthumbs'));
     $form->addElement('hash', 'csrf', array('salt' => __CLASS__, 'ignore' => true, 'required' => false));
     $form->addElement('hidden', 'path', array('ignore' => true, 'required' => false));
     $form->addElement('hidden', 'type', array('ignore' => true, 'required' => false));
     $form->addElement('submit', 'submit', array('ignore' => true, 'label' => X_Env::_('confirm')));
     $form->addDisplayGroup(array('submit', 'csrf', 'id'), 'buttons', array('decorators' => $form->getDefaultButtonsDisplayGroupDecorators()));
     $form->setDefault('path', X_Env::encode($path))->setDefault('type', $type);
     $this->view->type = $type;
     $this->view->path = $path;
     $this->view->form = $form;
     $this->view->messages = $this->_helper->flashMessenger->getMessages();
 }
 private function _getParent(Zend_Controller_Request_Http $request)
 {
     $controller = $request->getControllerName();
     $action = $request->getActionName();
     if ($controller == 'index' && $action == 'collections') {
         // we don't need to know anything: we are in the root
         return '0';
     }
     if ($controller == 'browse') {
         // we are in mode selection
         // parent is the same, but action = share
         if ($action == 'mode') {
             // rebuild the query, keep only location and provider
             $parent = array('controller' => 'browse', 'action' => 'share', 'p' => $request->getParam('p'), 'l' => $request->getParam('l'));
             return X_Env::encode(http_build_query($parent));
             //$request->getParams();
         }
         //
         if ($action == 'share') {
             // we need the providerObj to know the parent :(
             $location = $request->getParam('l', false);
             if ($location === false) {
                 // NICE, parent is the ROOT
                 return '0';
             }
             $providerId = $request->getParam('p');
             $providerObj = X_VlcShares_Plugins::broker()->getPlugins($providerId);
             if ($providerObj instanceof X_VlcShares_Plugins_ResolverInterface) {
                 // easy: provider will give us the parent
                 $location = X_Env::decode($location);
                 return X_Env::encode($providerObj->getParentLocation($location));
             }
             // so providerObj is not Resolver.... f**k
             // rude way?
             return '0';
         }
         if ($action == 'selection') {
             // same as 'controls' Q_Q
             return '0';
         }
     }
     if ($controller == 'controls') {
         // f**k: how can i manage this?
         return '0';
     }
     $data = array('controller' => $controller, 'action' => $action);
     $data = array_merge($data, $request->getParams());
     return X_Env::encode(http_build_query($data));
 }
 public function menuLinks(X_Page_ItemList_PItem $items, $type, $filter, $title, $season, $episode, $pageN = 1)
 {
     $pageN = X_VlcShares_Plugins_Utils::isset_or($pageN, 1);
     if ($type == 'documentaries') {
         $page = X_PageParser_Page::getPage(sprintf(self::URL_INDEX_LINKS_DOCUMENTARIES, $type, $title, $pageN), new X_PageParser_Parser_TvLinks(X_PageParser_Parser_TvLinks::MODE_LINKS, $type, $filter, $title, $season, $episode, $pageN));
     } else {
         $page = X_PageParser_Page::getPage(sprintf(self::URL_INDEX_LINKS, $type, $title, $season, $episode, $pageN), new X_PageParser_Parser_TvLinks(X_PageParser_Parser_TvLinks::MODE_LINKS, $type, $filter, $title, $season, $episode, $pageN));
     }
     $this->preparePageLoader($page);
     $parsed = $page->getParsed();
     if ($pageN > 1) {
         // add -previous-page-
         $previousPage = $pageN - 1;
         $items->append(X_VlcShares_Plugins_Utils::getPreviousPage("{$type}/{$filter}/{$title}/{$season}/{$episode}/{$previousPage}", $previousPage));
     }
     foreach ($parsed as $match) {
         $id = $match['id'];
         $hoster = $match['hoster'];
         $label = X_Env::_('p_tvlinks_watchon', ucfirst($hoster));
         $thumbnail = array_key_exists('thumbnail', $match) ? $match['thumbnail'] : null;
         $item = new X_Page_Item_PItem($this->getId() . "-{$type}-{$filter}-{$title}-{$season}-{$episode}-{$id}", $label);
         if (file_exists(APPLICATION_PATH . '/../public/images/icons/hosters/' . $hoster . '.png')) {
             $item->setIcon("/images/icons/hosters/{$hoster}.png");
         } else {
             if (X_VlcShares::VERSION == "0.5.4") {
                 $item->setIcon("/images/icons/file_32.png");
             } else {
                 // icons exists only in vlc-shares > 0.5.4
                 $item->setIcon("/images/icons/unknown-hoster.png");
             }
         }
         $item->setType(X_Page_Item_PItem::TYPE_ELEMENT)->setCustom(__CLASS__ . ':location', "{$type}/{$filter}/{$title}/{$season}/{$episode}/{$pageN}/{$id}")->setDescription(APPLICATION_ENV == 'development' ? "{$type}/{$filter}/{$title}/{$season}/{$episode}/{$pageN}/{$id}" : null)->setLink(array('action' => 'mode', 'l' => X_Env::encode("{$type}/{$filter}/{$title}/{$season}/{$episode}/{$pageN}/{$id}")), 'default', false);
         if ($thumbnail) {
             $item->setThumbnail($thumbnail);
         }
         $items->append($item);
     }
     if ($page->getParsed(new X_PageParser_Parser_TvLinks(X_PageParser_Parser_TvLinks::MODE_NEXTPAGE, $type, $filter, $title, $season, $episode, $pageN))) {
         $nextPage = $pageN + 1;
         $items->append(X_VlcShares_Plugins_Utils::getNextPage("{$type}/{$filter}/{$title}/{$season}/{$episode}/{$nextPage}", $nextPage));
     }
 }
 /**
  * Get category/video list
  * @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
     }
     $urlHelper = $controller->getHelper('url');
     $items = new X_Page_ItemList_PItem();
     if ($location != '') {
         //list($shareType, $linkId) = explode(':', $location, 2);
         // $location is the categoryName
         $videos = Application_Model_MegavideoMapper::i()->fetchByCategory($location);
         foreach ($videos as $video) {
             /* @var $video Application_Model_Megavideo */
             $item = new X_Page_Item_PItem($this->getId() . '-' . $video->getId(), $video->getLabel());
             $item->setIcon('/images/icons/file_32.png')->setType(X_Page_Item_PItem::TYPE_ELEMENT)->setCustom(__CLASS__ . ':location', $video->getId())->setLink(array('action' => 'mode', 'l' => X_Env::encode($video->getId())), 'default', false);
             $items->append($item);
         }
     } else {
         // if location is not specified,
         // show collections
         $categories = Application_Model_MegavideoMapper::i()->fetchCategories();
         foreach ($categories as $share) {
             /* @var $share Application_Model_FilesystemShare */
             $item = new X_Page_Item_PItem($this->getId() . '-' . $share['category'], "{$share['category']} ({$share['links']})");
             $item->setIcon('/images/icons/folder_32.png')->setType(X_Page_Item_PItem::TYPE_CONTAINER)->setCustom(__CLASS__ . ':location', $share['category'])->setLink(array('l' => X_Env::encode($share['category'])), 'default', false);
             $items->append($item);
         }
     }
     return $items;
 }
 private function _fetchVideos(X_Page_ItemList_PItem $items, $sortType, $subType, $page, $thread)
 {
     X_Debug::i("Fetching videos for {$sortType}/{$subType}/{$page}/{$thread}");
     $url = $this->config('index.video.url', 'http://www.gogocinema.com/movie.php?movie_id=') . $thread;
     $htmlString = $this->_loadPage($url);
     $htmlString = str_replace(array("\n", "\r", "\t", chr(0xc2), chr(0xa0), chr(157)), '', $htmlString);
     //X_Debug::i($htmlString);
     //$megavideoPattern = '/href\=\"http:\/\/megavideo\.com\/\?([^\"]+)\" /';
     //$megavideoPattern = '/<tr bgcolor\=\"#043F6E\"><td>\# ([^\"]+)\<\/td><\/tr><tr><td align\=\"center\"><a style\=\"color\:\#FFFFFF\;\" href\=\"http:\/\/megavideo\.com\/\?([^\"]+)\" target\=\"\_blank\">/';
     //$youtubePattern = '/<tr bgcolor\=\"#043F6E\"><td>\# ([^\"]+)\<\/td><\/tr><tr><td align\=\"center\"><a style\=\"color\:\#FFFFFF\;\" href\=\"http\:\/\/youtube\.com\/watch\?v\=([^\"]+)\" target\=\"\_blank\">/';
     $globalPattern = '/<tr bgcolor\\=\\"#043F6E\\"><td>\\# (?P<label>[^\\"]+)\\<\\/td><\\/tr><tr><td align\\=\\"center\\"><a style\\=\\"color\\:\\#FFFFFF\\;\\" href\\=\\"(?P<link>[^\\"]+)\\" target\\=\\"\\_blank\\">/';
     $movietitlePattern = '/<td class\\=\\"movietitle\\" colspan \\= \\"3\\"><a href\\=\\"movie\\.php\\?movie_id=([^\\"]+)\\" style=\\"color\\:\\#E95C24\\;\\">([^\\"]+)<\\/a>/';
     $matches = array();
     if (preg_match($movietitlePattern, $htmlString, $matches)) {
         $movieTitle = "{$matches[2]}: ";
     } else {
         $movieTitle = '';
     }
     $matches = array();
     if (preg_match_all($globalPattern, $htmlString, $matches, PREG_SET_ORDER)) {
         X_Debug::i("Megavideo videos found: " . count($matches));
         X_Debug::i(var_export($matches, true));
         foreach ($matches as $video) {
             //@list(,$label, $videoId) = $video;
             $label = $video['label'];
             $link = $video['link'];
             try {
                 $hoster = $this->helpers()->hoster()->findHoster($link);
                 $label = strip_tags($label) . " [" . ucfirst($hoster->getId()) . "]";
                 //$videoId = self::TYPE_MEGAVIDEO.":$videoId";
                 $videoId = "{$hoster->getId()}:{$hoster->getResourceId($link)}";
                 $item = new X_Page_Item_PItem($this->getId() . "-{$hoster->getId()}", "{$movieTitle}{$label}");
                 $item->setIcon('/images/icons/file_32.png')->setType(X_Page_Item_PItem::TYPE_ELEMENT)->setCustom(__CLASS__ . ':location', "{$sortType}/{$subType}/{$page}/{$thread}/{$videoId}")->setLink(array('action' => 'mode', 'l' => X_Env::encode("{$sortType}/{$subType}/{$page}/{$thread}/{$videoId}")), 'default', false);
                 if (APPLICATION_ENV == 'development') {
                     $item->setDescription("{$sortType}/{$subType}/{$page}/{$thread}/{$videoId}");
                 }
                 $items->append($item);
             } catch (Exception $e) {
                 // no valid hoster for this link
             }
         }
     } else {
         X_Debug::i("Megavideo videos NOT found: " . var_export($matches, true));
         X_Debug::i("No megavideo links found");
     }
     /*
     $matches = array();
     if ( preg_match_all($youtubePattern, $htmlString, $matches, PREG_SET_ORDER) ) {
     	X_Debug::i("Youtube videos found: ".count($matches));
     	
     	foreach ($matches as $video) {
     		
     		@list(,$label,$videoId) = $video;
     		
     		$label = strip_tags($label);
     		$videoId = self::TYPE_YOUTUBE.":$videoId";
     		
     		$item = new X_Page_Item_PItem($this->getId()."-youtube", "$movieTitle$label");
     		$item->setIcon('/images/icons/file_32.png')
     			->setType(X_Page_Item_PItem::TYPE_ELEMENT)
     			->setCustom(__CLASS__.':location', "$sortType/$subType/$page/$thread/$videoId")
     			->setLink(array(
     				'action'	=> 'mode',
     				'l'	=>	X_Env::encode("$sortType/$subType/$page/$thread/$videoId")
     			), 'default', false);
     			
     		if ( APPLICATION_ENV == 'development' ) {
     			$item->setDescription("$sortType/$subType/$page/$thread/$videoId");
     		}
     			
     		$items->append($item);
     		
     	}
     	
     }
     */
 }