/** * 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'); //$baseUrl = $this->config('base.url', 'http://www.jigoku.net/mediacenter/index.php?page=ajax_show_folder&id='); $items = new X_Page_ItemList_PItem(); X_Debug::i("Requested location: {$location}"); $split = $location != '' ? @explode('/', $location, 4) : array(); @(list($letter, $thread, $video) = $split); X_Debug::i("Exploded location: " . var_export($split, true)); switch (count($split)) { // i should not be here, so i fallback to video case case 3: // show the list of video in the page // show the list of video in the page case 2: $this->_fetchVideos($items, $letter, $thread); break; // fetch the list of anime in group // fetch the list of anime in group case 1: $this->_fetchThreads($items, $letter); break; // fetch the list of groups // fetch the list of groups default: $this->_fetchClassification($items); } return $items; }
/** * Get device features * * @return Application_Model_Device */ public function getDevice() { if ($this->device == null) { $this->device = false; $devices = Application_Model_DevicesMapper::i()->fetchAll(); /* @var Application_Model_Device $device */ foreach ($devices as $device) { // if exact do an == comparison if ($device->isExact() && $device->getPattern() == $_SERVER['HTTP_USER_AGENT'] || !$device->isExact() && preg_match($device->getPattern(), $_SERVER['HTTP_USER_AGENT']) > 0) { // valid $device found; $this->device = $device; break; } } if ($this->device == false) { // load things from default $this->device = new Application_Model_Device(); if (X_VlcShares_Plugins::broker()->isRegistered('wiimc')) { $this->device->setGuiClass($this->options->get('gui', 'X_VlcShares_Plugins_WiimcPlxRenderer')); } else { $this->device->setGuiClass($this->options->get('gui', 'X_VlcShares_Plugins_WebkitRenderer')); } $this->device->setIdProfile($this->options->get('profile', 1))->setLabel("Unknown device"); } } return $this->device; }
public function startEngine(X_Threads_Thread $thread) { // assume all parameters are ready $thread->log("Spawning RTMPDump (rtmpdump-weebtv | vlc)..."); $source = $this->getParam('source'); // set the path if (X_Env::isWindows()) { X_RtmpDumpWeebTv::getInstance()->setPath(APPLICATION_PATH . '/../bin/rtmpdump-weebtv-win/rtmpdump-weebtv.exe'); } else { X_RtmpDumpWeebTv::getInstance()->setPath(APPLICATION_PATH . '/../bin/rtmpdump-weebtv-linux/rtmpdump-weebtv'); } $weebPlugin = X_VlcShares_Plugins::broker()->getPlugins('weebtv'); if ($weebPlugin instanceof X_VlcShares_Plugins_WeebTv && X_VlcShares_Plugins::helpers()->streamer()->isRegistered('vlc')) { // try to get reference to vlc-streamer /* @var $vlcStreamer X_Streamer_Engine_Vlc */ $vlcStreamer = X_VlcShares_Plugins::helpers()->streamer()->get('vlc'); // get the channel id $source = substr($source, strlen('rtmpdump-weebtv://')); // make the plugin to parse params from server and build a rtmpdump-weebtv uri $source = $weebPlugin->getLinkParams($source); // always live $command = (string) X_RtmpDumpWeebTv::getInstance()->parseUri($source); $vlcStreamer->getVlcWrapper()->setPipe($command); $vlcStreamer->setSource('-'); $vlcStreamer->setParam('profile', "#std{access=http{mime=video/x-flv},mux=ffmpeg{mux=flv},dst=0.0.0.0:{$weebPlugin->getStreamingPort()}/stream}"); // redirect std error to null // and force quite //X_Env::execute("$command -q 2> /dev/null", X_Env::EXECUTE_OUT_NONE, X_Env::EXECUTE_PS_WAIT); //X_Env::execute($command, X_Env::EXECUTE_OUT_NONE, X_Env::EXECUTE_PS_WAIT); $vlcStreamer->getVlcWrapper()->spawn(); $thread->log("RTMPDump execution finished"); } else { $thread->log("RTMPDump-weebtv cannot be started without weebtv plugin and vlc streamer"); } }
/** * 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'); $baseUrl = $this->config('base.url', 'http://www.opfitalia.net/mediacenter/index.php?page=ajax_show_folder&id='); $items = new X_Page_ItemList_PItem(); try { if ($location != '') { @(list($path, $type, $link) = explode('/', $location)); $lStack = explode(':', $path); $last = count($lStack) > 0 ? $lStack[count($lStack) - 1] : 0; $decoded = $this->_loadPage($baseUrl . $last); $this->_fillPlaylist($items, $decoded, $lStack); } else { // show the index $indexCategory = $this->config('index.category', 0); $decoded = $this->_loadPage($baseUrl . $indexCategory); $this->_fillPlaylist($items, $decoded, array()); } } catch (Exception $e) { // auth problems $item = new X_Page_Item_PItem('opf-autherror', X_Env::_('p_opfitalia_br_error') . ": {$e->getMessage()}"); $item->setIcon('/images/msg_error.png')->setType(X_Page_Item_PItem::TYPE_ELEMENT)->setDescription($e->getMessage())->setLink(array('controller' => 'index', 'action' => 'collections'), 'default', true); $items->append($item); } return $items; }
public function init() { parent::init(); if (!X_VlcShares_Plugins::broker()->isRegistered('veoh')) { throw new Exception(X_Env::_('err_pluginnotregistered') . ": veoh"); } }
/** * 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; }
function init() { parent::init(); if (!X_VlcShares_Plugins::broker()->isRegistered('youtube')) { $this->_helper->flashMessenger(X_Env::_('err_pluginnotregistered') . ": youtube"); $this->_helper->redirector('index', 'manage'); } }
public function getSelectionItems($provider, $location, $pid, Zend_Controller_Action $controller) { // we want to expose items only if pid is this plugin if ($this->getId() != $pid) { return; } // check for resolvable $location // this plugin is useless if i haven't an access // to the real location (url for stream or path for file) $provider = X_VlcShares_Plugins::broker()->getPlugins($provider); if (!$provider instanceof X_VlcShares_Plugins_ResolverInterface) { return; } $providerClass = get_class($provider); X_Debug::i('Plugin triggered'); $urlHelper = $controller->getHelper('url'); // i try to mark current selected sub based on $this->getId() param // in $currentSub i get the name of the current profile $currentSub = $controller->getRequest()->getParam($this->getId(), false); if ($currentSub !== false) { $currentSub = X_Env::decode($currentSub); } $return = new X_Page_ItemList_PItem(); $item = new X_Page_Item_PItem($this->getId() . '-none', X_Env::_('p_audioswitcher_selection_none')); $item->setType(X_Page_Item_PItem::TYPE_ELEMENT)->setLink(array('action' => 'mode', $this->getId() => null, 'pid' => null), 'default', false)->setHighlight($currentSub === false); $return->append($item); // i do the check for this on top // location param come in a plugin encoded way $location = $provider->resolveLocation($location); // check if infile support is enabled // by default infile.enabled is true if ($this->config('infile.enabled', true)) { // check for infile tracks $infileTracks = $this->helpers()->stream()->setLocation($location)->getAudiosInfo(); //X_Debug::i(var_export($infileSubs, true)); foreach ($infileTracks as $streamId => $track) { X_Debug::i("Valid infile-sub: [{$streamId}] {$track['language']} ({$track['format']})"); $item = new X_Page_Item_PItem($this->getId() . '-stream-' . $streamId, X_Env::_("p_audioswitcher_subtype_" . self::STREAM) . " {$streamId} {$track['language']} {$track['format']}"); $item->setType(X_Page_Item_PItem::TYPE_ELEMENT)->setCustom(__CLASS__ . ':sub', self::STREAM . ":{$streamId}")->setLink(array('action' => 'mode', 'pid' => null, $this->getId() => X_Env::encode(self::STREAM . ":{$streamId}")), 'default', false)->setHighlight($currentSub == self::STREAM . ":{$streamId}"); $return->append($item); } } // for file system source i will search for subs in filename notation // by default file.enabled is true if ($this->config('file.enabled', true) && is_a($provider, 'X_VlcShares_Plugins_FileSystem')) { $dirname = pathinfo($location, PATHINFO_DIRNAME); $filename = pathinfo($location, PATHINFO_FILENAME); $extTracks = $this->getFSTracks($dirname, $filename); foreach ($extTracks as $streamId => $track) { X_Debug::i("Valid extfile-sub: {$track['language']} ({$track['format']})"); $item = new X_Page_Item_PItem($this->getId() . '-file-' . $streamId, X_Env::_("p_audioswitcher_subtype_" . self::FILE) . " {$track['language']} ({$track['format']})"); $item->setType(X_Page_Item_PItem::TYPE_ELEMENT)->setCustom(__CLASS__ . ':sub', self::FILE . ":{$streamId}")->setLink(array('action' => 'mode', 'pid' => null, $this->getId() => X_Env::encode(self::FILE . ":{$streamId}")), 'default', false)->setHighlight($currentSub == self::FILE . ":{$streamId}"); $return->append($item); } } // general profiles are in the bottom of array return $return; }
public function init() { parent::init(); if (!X_VlcShares_Plugins::broker()->isRegistered('upnprenderer')) { throw new Exception(X_Env::_('err_pluginnotregistered') . ": upnprenderer"); } else { $this->plugin = X_VlcShares_Plugins::broker()->getPlugins('upnprenderer'); } }
public function preDispatch() { X_Debug::i("Required action: [" . $this->getRequest()->getControllerName() . '/' . $this->getRequest()->getActionName() . ']'); parent::preDispatch(); // call plugins trigger // TODO check if plugin broker should be called before parent::preDispatch X_VlcShares_Plugins::broker()->gen_beforePageBuild($this); //$this->_helper->url->url() }
public function frameAction() { $this->_helper->layout->disableLayout(); $csrf = new Zend_Form_Element_Hash('csrf', array('salt' => __CLASS__)); $csrf->initCsrfToken(); $this->view->bookmarks_enabled = X_VlcShares_Plugins::broker()->isRegistered('bookmarks'); $this->view->onlinelibrary_enabled = X_VlcShares_Plugins::broker()->isRegistered('onlinelibrary'); $this->view->categories = Application_Model_VideosMapper::i()->fetchCategories(); $this->view->csrf = $csrf->getHash(); $this->view->hosters = X_VlcShares_Plugins::helpers()->hoster()->getHosters(); }
public function init() { parent::init(); if (!X_VlcShares_Plugins::broker()->isRegistered('onlinelibrary')) { throw new Exception(X_Env::_('err_pluginnotregistered') . ": onlinelibrary"); } else { $this->pluginLibrary = X_VlcShares_Plugins::broker()->getPlugins('onlinelibrary'); } if (X_VlcShares_Plugins::broker()->isRegistered('bookmarklets')) { $this->pluginBookmarklets = X_VlcShares_Plugins::broker()->getPlugins('bookmarklets'); } }
function init() { // call parent init, always parent::init(); if (!X_VlcShares_Plugins::broker()->isRegistered('spainradio')) { /* $this->_helper->flashMessenger(X_Env::_('err_pluginnotregistered') . ": youtube"); $this->_helper->redirector('index', 'manage'); */ throw new Exception(X_Env::_('err_pluginnotregistered') . ": spainradio"); } else { $this->plugin = X_VlcShares_Plugins::broker()->getPlugins('spainradio'); } }
/** * 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; }
function init() { // call parent init, always parent::init(); if (!X_VlcShares_Plugins::broker()->isRegistered('fsthumbs')) { throw new Exception(X_Env::_('err_pluginnotregistered') . ": fsthumbs"); } else { $this->plugin = X_VlcShares_Plugins::broker()->getPlugins('fsthumbs'); } if (!X_VlcShares_Plugins::broker()->isRegistered('fileSystem')) { throw new Exception(X_Env::_('err_pluginnotregistered') . ": fileSystem"); } else { $this->fsPlugin = X_VlcShares_Plugins::broker()->getPlugins('fileSystem'); } }
public function gen_afterPageBuild(X_Page_ItemList_PItem $items, Zend_Controller_Action $controller) { /* if ( !$this->_forceRendering ) { // even if forced.enabled, don't build the page if the device is wiimc if ( $this->helpers()->devices()->isWiimc() || ( !((bool) $this->config('forced.enabled', false)) && !$this->helpers()->devices()->isAndroid() )) return; } */ if (!$this->isDefaultRenderer()) { return; } X_Debug::i("Plugin triggered"); $request = $controller->getRequest(); $urlHelper = $controller->getHelper('url'); /* @var $view Zend_Controller_Action_Helper_ViewRenderer */ $view = $controller->getHelper('viewRenderer'); /* @var $layout Zend_Layout_Controller_Action_Helper_Layout */ $layout = $controller->getHelper('layout'); $view->setViewSuffix('mobile.phtml'); $layout->getLayoutInstance()->setLayout('mobile', true); if ($request instanceof Zend_Controller_Request_Http) { if ($request->isXmlHttpRequest()) { $layout->getLayoutInstance()->disableLayout(); } } try { $providerObj = X_VlcShares_Plugins::broker()->getPlugins($request->getParam('p', '')); $view->view->providerName = strtolower($providerObj->getId()); if ($providerObj instanceof X_VlcShares_Plugins_ResolverDisplayableInterface) { // location in request obj are X_Env::encoded $view->view->location = $providerObj->resolveLocation(X_Env::decode($request->getParam('l', ''))); } if ($providerObj instanceof X_VlcShares_Plugins_ResolverInterface) { // location in request obj are X_Env::encoded $view->view->locationRaw = $providerObj->resolveLocation(X_Env::decode($request->getParam('l', ''))); $view->view->parentLocation = $providerObj->getParentLocation(X_Env::decode($request->getParam('l', ''))); } } catch (Exception $e) { //die('No provider'); X_Debug::i('No provider O_o'); } // set some vars for view $view->view->provider = $request->getParam('p', ''); $view->view->items = $items; $view->view->actionName = $request->getActionName(); $view->view->controllerName = $request->getControllerName(); $view->view->coverflowEnabled = $this->config('coverflow.enabled', true); }
function init() { // call parent init, always parent::init(); if (!X_VlcShares_Plugins::broker()->isRegistered('animeftw')) { /* $this->_helper->flashMessenger(X_Env::_('err_pluginnotregistered') . ": youtube"); $this->_helper->redirector('index', 'manage'); */ throw new Exception(X_Env::_('err_pluginnotregistered') . ": animeftw"); } else { $this->plugin = X_VlcShares_Plugins::broker()->getPlugins('animeftw'); } $this->getFrontController()->setParam('disableOutputBuffering', true); $this->getFrontController()->returnResponse(false); }
/** * 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; }
/** * Get category/video list * @param string $provider * @param string $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'); X_VlcShares_Plugins::broker()->unregisterPluginClass('X_VlcShares_Plugins_SortItems'); $items = new X_Page_ItemList_PItem(); // location format: // $catPage/X_Env::encode($category)/$itemPage/$item $locParts = $location != '' ? explode('/', $location, 4) : array(); @(list($catPage, $category, $itemPage, $item) = $locParts); $locCount = count($locParts); // category is double encoded so we need an extra decode $category = X_Env::decode($category); switch ($locCount) { case 2: $itemPage = 1; case 4: // we shouldn't be here, $locCount = 4 means that we have a // selected video in location. We should be in browse/mode // we shouldn't be here, $locCount = 4 means that we have a // selected video in location. We should be in browse/mode case 3: $this->fetchVideos($items, $catPage, $category, $itemPage); break; default: case 0: $catPage = 1; case 1: $this->fetchCategories($items, $catPage); break; } return $items; }
/** * Sorts items: * if provider is FileSystem uses a folder/file sort * else alphabetical one * @param array &$items array of X_Page_Item_PItem * @param string $provider id of the plugin the handle the request * @param Zend_Controller_Action $controller */ public function orderShareItems(&$items, $provider, Zend_Controller_Action $controller) { X_Debug::i('Plugin triggered'); try { $plugin = X_VlcShares_Plugins::broker()->getPlugins($provider); // TODO check for problem if i always use sortFolderBased if (true || is_a($plugin, 'X_VlcShares_Plugins_FileSystem')) { X_Debug::i('Sort sortFolderBased'); usort($items, array(__CLASS__, 'sortFolderBased')); } else { X_Debug::i('Sort generic'); usort($items, array(__CLASS__, 'sortAlphabetically')); } } catch (Exception $e) { X_Debug::w("Problem while sorting: {$e->getMessage()}"); } }
/** * get a playable resource url * from an $url (or a resource id if $isId = true) * @param string $url the hoster page or resource ID * @param boolean $isId * @return string a playable url */ function getPlayable($url, $isId = true) { if (!$isId) { $url = $this->getResourceId($url); } // $url is an id now for sure /* @var $youtubeHelper X_VlcShares_Plugins_Helper_Youtube */ $youtubeHelper = X_VlcShares_Plugins::helpers()->helper('youtube'); /* @var $youtubePlugin X_VlcShares_Plugins_Youtube */ $youtubePlugin = X_VlcShares_Plugins::broker()->getPlugins('youtube'); X_Debug::i("Youtube ID: {$url}"); // THIS CODE HAVE TO BE MOVED IN YOUTUBE HELPER // FIXME $formats = $youtubeHelper->getFormatsNOAPI($url); $returned = null; $qualityPriority = explode('|', $youtubePlugin->config('quality.priority', '5|34|18|35')); foreach ($qualityPriority as $quality) { if (array_key_exists($quality, $formats)) { $returned = $formats[$quality]; X_Debug::i('Video format selected: ' . $quality); break; } } if ($returned === null) { // for valid video id but video with restrictions // alternatives formats can't be fetched by youtube page. // i have to fallback to standard api url $apiVideo = $youtubeHelper->getVideo($url); foreach ($apiVideo->mediaGroup->content as $content) { if ($content->type === "video/3gpp") { $returned = $content->url; X_Debug::w('Content restricted video, fallback to api url:' . $returned); break; } } if ($returned === null) { $returned = false; } } if ($returned !== false && $returned !== null) { // valid return return $returned; } throw new Exception("Invalid video", self::E_ID_INVALID); }
public function gen_beforePageBuild(Zend_Controller_Action $controller) { X_Debug::i("Tuning options"); try { /* @var $cacheHelper X_VlcShares_Plugins_Helper_Cache */ $cacheHelper = $this->helpers()->helper('cache'); $lastdevices = false; try { $lastdevices = $cacheHelper->retrieveItem('devices::lastdevices'); } catch (Exception $e) { /* key missing */ } if ($lastdevices) { $lastdevices = @unserialize($lastdevices); } if (!is_array($lastdevices)) { $lastdevices = array(); } foreach ($lastdevices as $key => $time) { if ($time < time()) { unset($lastdevices[$key]); } } if (!array_key_exists($_SERVER['HTTP_USER_AGENT'], $lastdevices)) { $lastdevices[$_SERVER['HTTP_USER_AGENT']] = time() + 15 * 60; } // clear the cache entry every 60 min if untouched $cacheHelper->storeItem('devices::lastdevices', serialize($lastdevices), 60); } catch (Exception $e) { X_Debug::i("User agent cannot be added to the cache"); } $guiClass = $this->helpers()->devices()->getDefaultDeviceGuiClass(); X_Debug::i("Device configs: {{label: {$this->helpers()->devices()->getDeviceLabel()}, guiClass: {$guiClass}}"); foreach (X_VlcShares_Plugins::broker()->getPlugins() as $pluginKey => $pluginObj) { if ($pluginObj instanceof X_VlcShares_Plugins_RendererInterface) { if ($guiClass == get_class($pluginObj)) { /* @var $pluginObj X_VlcShares_Plugins_RendererInterface */ $pluginObj->setDefaultRenderer(true); } } } // disable this trigger, prevent double initialization $this->setPriority('gen_beforePageBuild', -1); }
/** * This hook can be used check vlc status just before * spawn is called * * @param X_Vlc $vlc vlc wrapper object * @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 */ public function preSpawnVlc(X_Vlc $vlc, $provider, $location, Zend_Controller_Action $controller) { // TODO port to newer api when ready // when newer X_Vlc's api will be ready // i will need change this to // $source = $vlc->getSource(); // and double quote removal will be automatic $source = $vlc->getArg('source'); $provider = X_VlcShares_Plugins::broker()->getPlugins($provider); //if ( X_Env::isWindows() && !X_Env::startWith($source, 'http://') && !X_Env::startWith($source, 'https://') ) { if (X_Env::isWindows() && is_a($provider, 'X_VlcShares_Plugins_FileSystem')) { // with newer api this will be useless $source = realpath(trim($source, '"')); // when newer X_Vlc's api will be ready // i will need change this to // $vlc->setSource($source); // and double quotation will be automatic $vlc->registerArg('source', "\"{$source}\""); } }
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); }
public function init() { parent::init(); if (!X_VlcShares_Plugins::broker()->isRegistered('megavideo')) { /* $this->_helper->flashMessenger(X_Env::_('err_pluginnotregistered') . ": youtube"); $this->_helper->redirector('index', 'manage'); */ throw new Exception(X_Env::_('err_pluginnotregistered') . ": megavideo"); } else { $this->plugin = X_VlcShares_Plugins::broker()->getPlugins('megavideo'); } $action = $this->getRequest()->getActionName(); if ($action == 'premium') { // disabling outbuffering // and response return $this->getFrontController()->setParam('disableOutputBuffering', true); $this->getFrontController()->returnResponse(false); } }
/** * 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; }
/** * 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; }
/** * 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(); //try to disable SortItems plugin, so link are listed as in html page X_VlcShares_Plugins::broker()->unregisterPluginClass('X_VlcShares_Plugins_SortItems'); X_Debug::i("Requested location: {$location}"); $split = $location != '' ? @explode('/', $location, 4) : array(); X_Debug::i("Exploded location: " . var_export($split, true)); switch (count($split)) { // i should not be here, so i fallback to video case case 4: // show the list of video in the page // here authentication is required if it's possibile // show the list of video in the page // here authentication is required if it's possibile case 3: $this->_fetchVideos($items, $split[0], $split[1], $split[2]); break; // show the list of thread in category by letter // show the list of thread in category by letter case 2: $this->_fetchThreads($items, $split[0], $split[1]); break; // show the list of A-B-C.... if an area is selected // show the list of A-B-C.... if an area is selected case 1: $this->_fetchClassification($items, $split[0]); break; default: $this->_fetchLists($items); } 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; }
/** * Retrieve core statistics * @param Zend_Controller_Action $this * @return X_Page_ItemList_Statistic */ public function getIndexStatistics(Zend_Controller_Action $controller) { $plugins = count(X_VlcShares_Plugins::broker()->getPlugins()); $helpers = count(X_VlcShares_Plugins::helpers()->getHelpers()); $pluginsList = '<div class="scrollable" style="max-height: 75px;"><ol>'; foreach (X_VlcShares_Plugins::broker()->getPlugins() as $pluginName => $pluginObj) { $explodedClass = explode('_', get_class($pluginObj)); $formattedPluginClass = array_pop($explodedClass); $pluginsList .= "<li style=\"font-weight: normal;\">{$formattedPluginClass}</li>\n"; } $pluginsList .= "</ol></div>"; $helpersList = '<div class="scrollable" style="max-height: 75px;"><ol>'; foreach (X_VlcShares_Plugins::helpers()->getHelpers() as $pluginName => $pluginObj) { $explodedClass = explode('_', get_class($pluginObj)); $formattedPluginClass = array_pop($explodedClass); $helpersList .= "<li style=\"font-weight: normal;\">{$formattedPluginClass}</li>\n"; } $helpersList .= "</ol></div>"; $vlc = X_Vlc::getLastInstance()->isRunning() ? X_Env::_('p_corestats_vlcrunning_yes') : X_Env::_('p_corestats_vlcrunning_no'); $stat = new X_Page_Item_Statistic($this->getId(), X_Env::_('p_corestats_statstitle')); $stat->setTitle(X_Env::_('p_corestats_statstitle'))->appendStat(X_Env::_('p_corestats_vlcrunning') . ": {$vlc}")->appendStat(X_Env::_('p_corestats_pluginnumber') . ": {$plugins}")->appendStat(X_Env::_('p_corestats_helpernumber') . ": {$helpers}")->appendStat(X_Env::_('p_corestats_pluginslist') . ": {$pluginsList}")->appendStat(X_Env::_('p_corestats_helperlist') . ": {$helpersList}"); return new X_Page_ItemList_Statistic(array($stat)); }