public function executeAction()
 {
     $request = $this->getRequest();
     //X_VlcShares_Plugins::broker()->gen_preProviderSelection($this);
     /*
     $provider = $request->getParam('p', false);
     if ( $provider === false || !X_VlcShares_Plugins::broker()->isRegistered($provider) ) {
     	throw new Exception("Invalid provider");
     }
     $location = X_Env::decode($request->getParam('l', ''));
     */
     $pid = $request->getParam('pid', false);
     $a = $request->getParam('a', false);
     $engineId = X_Streamer::i()->getStreamingEngineId();
     $engine = X_VlcShares_Plugins::helpers()->streamer()->get($engineId);
     X_VlcShares_Plugins::broker()->preExecute($engine, $pid, $a, $this);
     X_VlcShares_Plugins::broker()->execute($engine, $pid, $a, $this);
     X_VlcShares_Plugins::broker()->postExecute($engine, $pid, $a, $this);
     $pageItems = new X_Page_ItemList_PItem();
     $done = new X_Page_Item_PItem('core-opdone', X_Env::_('controls_done'));
     $done->setCustom('vlc_still_alive', $this->vlc->isRunning())->setType(X_Page_Item_PItem::TYPE_ELEMENT)->setLink(array('controller' => 'controls', 'action' => 'control', 'pid' => null, 'a' => null, 'param' => null), 'default', false);
     $pageItems->append($done);
     // links on top
     $pageItems->merge(X_VlcShares_Plugins::broker()->preGetExecuteItems($pid, $a, $this));
     // add separator between play items and options items
     $separator = new X_Page_Item_PItem('core-separator', X_Env::_('_____options_separator_____'));
     $separator->setType(X_Page_Item_PItem::TYPE_ELEMENT)->setLink(array('controller' => 'controls', 'action' => 'control', 'pid' => null, 'a' => null, 'param' => null), 'default', false);
     $pageItems->append($separator);
     // normal links
     $pageItems->merge(X_VlcShares_Plugins::broker()->getExecuteItems($pid, $a, $this));
     // bottom links
     $pageItems->merge(X_VlcShares_Plugins::broker()->postGetExecuteItems($pid, $a, $this));
     // trigger for page creation
     X_VlcShares_Plugins::broker()->gen_afterPageBuild($pageItems, $this);
 }
 public function 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");
     }
 }
 function proxyAction()
 {
     // time to get params from get
     /* @var $request Zend_Controller_Request_Http */
     $request = $this->getRequest();
     if (!$this->plugin->config('proxy.enabled', true) && !X_VlcShares_Plugins::helpers()->devices()->isWiimc()) {
         throw new Exception(X_Env::_('p_animeftw_err_proxydisabled'));
     }
     // this action is so special.... no layout or viewRenderer
     $this->_helper->viewRenderer->setNoRender();
     $this->_helper->layout->disableLayout();
     $videoUrl = $request->getParam('v', false);
     // video file url
     $refererUrl = $request->getParam('r', false);
     // referer page needed
     if ($videoUrl === false || $refererUrl === false) {
         // invalid request
         throw new Exception(X_Env::_('p_animeftw_err_invalidrequest'));
         return;
     }
     $videoUrl = X_Env::decode($videoUrl);
     $refererUrl = X_Env::decode($refererUrl);
     // if user abort request (vlc/wii stop playing, this process ends
     ignore_user_abort(false);
     // close and clean the output buffer, everything will be read and send to device
     ob_end_clean();
     //$userAgent = $this->plugin->config('hide.useragent', true) ? 'User-Agent: vlc-shares/'.X_VlcShares::VERSION : 'User-Agent: Mozilla/5.0 (X11; Linux i686; rv:2.0.1) Gecko/20101019 Firefox/4.0.1';
     $userAgent = 'User-Agent: vlc-shares/' . X_VlcShares::VERSION . ' animeftw/' . X_VlcShares_Plugins_AnimeFTW::VERSION;
     $opts = array('http' => array('header' => array("Referer: {$refererUrl}", "User-Agent: {$userAgent}")));
     $context = stream_context_create($opts);
     // readfile open a file and send it directly to output buffer
     readfile($videoUrl, false, $context);
 }
 /**
  * Inizialize translator for this plugin
  * @param Zend_Controller_Action $controller
  */
 function gen_beforeInit(Zend_Controller_Action $controller)
 {
     $this->helpers()->language()->addTranslation(__CLASS__);
     // redirect support in wiimc exists only from 1.1.0
     if ($this->helpers()->devices()->isWiimc() && !X_VlcShares_Plugins::helpers()->devices()->isWiimcBeforeVersion('1.0.9') && $this->config('direct.enabled', true)) {
         $this->setPriority('preGetModeItems');
     }
 }
 function preDispatch()
 {
     // uses the device helper for wiimc recognition
     if (X_VlcShares_Plugins::helpers()->devices()->isWiimc()) {
         // wiimc 1.0.9 e inferiori nn accetta redirect
         //$this->_forward('collections', 'index');
         $this->getRequest()->setControllerName('index')->setActionName('collections')->setDispatched(false);
     } else {
         $this->_helper->redirector('index', 'index');
     }
 }
 public function indexAction()
 {
     // uses the device helper for wiimc recognition
     // maybe i will add a trigger here
     if (X_VlcShares_Plugins::helpers()->devices()->isWiimc()) {
         // wiimc 1.0.9 e inferiori nn accetta redirect
         X_Debug::i("Forwarding...");
         $this->_forward('collections', 'index');
     } else {
         $this->_helper->redirector('index', 'manage');
     }
 }
 /**
  * get an array with standard information about the playable
  * @param string $url the hoster page or resource ID
  * @param boolean $isId
  * @return array format:
  * 		array(
  * 			'title' => TITLE
  * 			'description' => DESCRIPTION
  * 			'length' => LENGTH
  * 			...
  * 		)
  */
 function getPlayableInfos($url, $isId = true)
 {
     if (!$isId) {
         $url = $this->getResourceId($url);
     }
     // $url is an id now for sure
     /* @var $megavideoHelper X_VlcShares_Plugins_Helper_Megavideo */
     $megavideoHelper = X_VlcShares_Plugins::helpers()->helper('megavideo');
     if ($megavideoHelper->setLocation($url)->getServer() == '') {
         throw new Exception("Invalid video", self::E_ID_INVALID);
     }
     // use cached values
     $infos = array('title' => $megavideoHelper->getTitle(), 'description' => $megavideoHelper->getDescription(), 'length' => $megavideoHelper->getDuration());
     return $infos;
 }
 public function run($params = array(), X_Threads_Thread $thread)
 {
     $this->thread = $thread;
     $streamerId = X_Env::isset_or($params['streamerId'], false);
     $streamerClass = X_Env::isset_or($params['streamerClass'], false);
     $params = X_Env::isset_or($params['params'], array());
     if (!$streamerId) {
         $thread->log("Sorry dude, no streamerId submitted. Can't do anything");
         return X_Threads_Thread::RETURN_INVALID_PARAMS;
     }
     /* @var $streamer X_Streamer_Engine_Vlc */
     $streamer = X_VlcShares_Plugins::helpers()->streamer()->get($streamerId);
     $streamer->setParams($params);
     $streamer->startEngine($thread);
     return self::RETURN_NORMAL;
 }
 function proxyAction()
 {
     // time to get params from get
     /* @var $request Zend_Controller_Request_Http */
     $request = $this->getRequest();
     // this action is so special.... no layout or viewRenderer
     $this->_helper->viewRenderer->setNoRender();
     $this->_helper->layout->disableLayout();
     $videoUrl = $request->getParam('v', false);
     // video file url
     //$refererUrl = $request->getParam('r', false); // referer page needed
     if ($videoUrl === false) {
         // invalid request
         throw new Exception(X_Env::_('p_direttarai_err_invalidrequest'));
     }
     $videoUrl = X_Env::decode($videoUrl);
     //$refererUrl = X_Env::decode($refererUrl);
     if (!defined("X_VlcShares_Plugins_DirettaRai::C_{$videoUrl}")) {
         throw new Exception(X_Env::_('p_direttarai_err_invalidchannel'));
     }
     $videoUrl = constant("X_VlcShares_Plugins_DirettaRai::C_{$videoUrl}");
     //$userAgent = $this->plugin->config('hide.useragent', true) ? 'User-Agent: vlc-shares/'.X_VlcShares::VERSION.' direttarai/'.X_VlcShares_Plugins_DirettaRai::VERSION : 'User-Agent: Mozilla/5.0 (X11; Linux i686; rv:2.0.1) Gecko/20101019 Firefox/4.0.1';
     //$userAgent = 'User-Agent: vlc-shares/'.X_VlcShares::VERSION.' direttarai/'.X_VlcShares_Plugins_DirettaRai::VERSION;
     $opts = array('http' => array('header' => array('viaurl: www.rai.tv')));
     $context = stream_context_create($opts);
     // redirect support in wiimc exists only from 1.1.0
     if (!X_VlcShares_Plugins::helpers()->devices()->isWiimc() && $this->plugin->config('direct.enabled', true)) {
         $match = array();
         $xml = file_get_contents($videoUrl, false, $context);
         if (preg_match('/<REF HREF=\\"([^\\"]*)\\"\\/>/', $xml, $match)) {
             $this->_helper->redirector->gotoUrlAndExit($match[1]);
         } else {
             throw new Exception(X_Env::_('p_direttarai_err_invalidchannel'));
         }
     } else {
         // if user abort request (vlc/wii stop playing, this process ends)
         ignore_user_abort(false);
         // close and clean the output buffer, everything will be read and send to device
         ob_end_clean();
         // readfile open a file and send it directly to output buffer
         readfile($videoUrl, false, $context);
     }
 }
 /**
  * (non-PHPdoc)
  * @see X_PageParser_Parser::parse()
  */
 public function parse($string)
 {
     switch ($this->mode) {
         case self::MODE_TITLES:
             return $this->parseTitles($string);
         case self::MODE_EPISODES:
             return $this->parseEpisodes($string);
         case self::MODE_LINKS:
             return $this->parseLinks($string);
         case self::MODE_NEXTPAGE:
             return $this->parseNextPage($string);
         default:
             throw new Exception("Invalid mode: {" . $this->mode . "}");
     }
     // dead code
     // first, find the thumb url:
     $match = array();
     $thumb = false;
     preg_match(self::PATTERN_THUMBNAIL, $string, $match);
     // avoid relative thumbnails
     if (count($match) > 0 && X_Env::startWith($match['image'], 'http://')) {
         $thumb = $match['image'];
         X_Debug::i("Thumbnail found: {$thumb}");
     }
     /* @var $hosterHelper X_VlcShares_Plugins_Helper_Hoster */
     $hosterHelper = X_VlcShares_Plugins::helpers()->hoster();
     $subparser = X_PageParser_Parser_HosterLinks::factory($hosterHelper, X_PageParser_Parser_Preg::factory(self::PATTERN_LINKS, X_PageParser_Parser_Preg::PREG_MATCH_ALL, PREG_SET_ORDER));
     $links = $subparser->parse($string);
     X_Debug::i("Valid hosters link found: " . count($links));
     // clean results and reformat them
     $cleanedLinks = array();
     foreach ($links as $link) {
         $cLink = array();
         $cLink['hosterId'] = $link['hoster']->getId();
         $cLink['videoId'] = $link['hoster']->getResourceId($link['url']);
         $cLink['label'] = strip_tags($link['label']);
         $cLink['link'] = "{$cLink['hosterId']}:{$cLink['videoId']}";
         $cLink['thumbnail'] = $thumb;
         $cleanedLinks[] = $cLink;
     }
     return $cleanedLinks;
 }
 public function startEngine(X_Threads_Thread $thread)
 {
     // assume all parameters are ready
     $thread->log("Spawning RTMPDump (rtmpdump | vlc)...");
     $source = $this->getParam('source');
     if (X_VlcShares_Plugins::helpers()->streamer()->isRegistered('vlc')) {
         $command = (string) X_RtmpDump::getInstance()->parseUri($source);
         $streamPort = X_VlcShares_Plugins::helpers()->rtmpdump()->getStreamPort();
         // try to get reference to vlc-streamer
         /* @var $vlcStreamer X_Streamer_Engine_Vlc */
         $vlcStreamer = X_VlcShares_Plugins::helpers()->streamer()->get('vlc');
         $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:{$streamPort}/}");
         //X_Env::execute($command, X_Env::EXECUTE_OUT_NONE, X_Env::EXECUTE_PS_WAIT);
         $vlcStreamer->getVlcWrapper()->spawn();
         //$this->vlc->spawn();
         $thread->log("RTMPDump execution finished");
     } else {
         $thread->log("RTMPDump cannot be started without vlc streamer");
     }
 }
 /**
  * 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));
 }
Example #13
0
 private function getChannelsListRaw()
 {
     try {
         /* @var $cacheHelper X_VlcShares_Plugins_Helper_Cache */
         $cacheHelper = X_VlcShares_Plugins::helpers()->helper('cache');
         $response = $cacheHelper->retrieveItem("own3d::channelslist");
         X_Debug::i("Valid cache entry found: {$response}");
         return $response;
     } catch (Exception $e) {
         // no cache plugin or no entry in cache, it's the same
         X_Debug::i("Cache disabled or no valid entry found");
     }
     $http = new Zend_Http_Client($this->config('source', self::URL_SOURCE), array('timeout' => $this->config('request.timeout', 25)));
     $http->setHeaders(array($this->config('hide.useragent', false) ? 'User-Agent: vlc-shares/' . X_VlcShares::VERSION . ' own3d/' . self::VERSION : 'User-Agent: Mozilla'));
     X_Debug::i("Fetching: " . $this->config('source', self::URL_SOURCE));
     $list = $http->request()->getBody();
     try {
         /* @var $cacheHelper X_VlcShares_Plugins_Helper_Cache */
         $cacheHelper = X_VlcShares_Plugins::helpers()->helper('cache');
         $cacheHelper->storeItem("own3d::channelslist", $list, 15);
         // store for the next 15 min
         X_Debug::i("Value stored in cache for 15 min: {key = own3d::channelslist, value = %OMISSIS%}");
     } catch (Exception $e) {
         // no cache plugin, next time i have to repeat the request
     }
     return $list;
 }
 public function streamAction()
 {
     $request = $this->getRequest();
     X_VlcShares_Plugins::broker()->gen_preProviderSelection($this);
     $provider = $request->getParam('p', false);
     if ($provider === false || !X_VlcShares_Plugins::broker()->isRegistered($provider)) {
         throw new Exception("Invalid provider");
     }
     $location = X_Env::decode($request->getParam('l', ''));
     $providerObj = X_VlcShares_Plugins::broker()->getPlugins($provider);
     // if provider is a resolver, i can use new streamer api
     if (X_VlcShares_Plugins::helpers()->streamer()->isEnabled() && $providerObj instanceof X_VlcShares_Plugins_ResolverInterface) {
         $url = $providerObj->resolveLocation($location);
         X_Debug::i("Resolved location: {{$url}}");
         // check if url is valid (resolver give null or false on error)
         if (!$url) {
             X_Debug::e("Invalid location: {$location}");
             throw new Exception("Stream location is invalid: {$url}");
         }
         $engine = X_VlcShares_Plugins::helpers()->streamer()->find($url);
         X_Debug::i("Streamer engine found: {{$engine->getId()}}");
         // automatically set the url as source param in the engine
         $engine->setSource($url);
         // NEW APIS
         // each arg is stored as in a LIFO stack. If i put top priority as first,
         // low priority args could override it. So i use an inverse priority insertion
         // register low priority args
         X_VlcShares_Plugins::broker()->preRegisterStreamerArgs($engine, $url, $provider, $location, $this);
         // register normal priority args
         X_VlcShares_Plugins::broker()->registerStreamerArgs($engine, $url, $provider, $location, $this);
         // register top priority args
         X_VlcShares_Plugins::broker()->postRegisterStreamerArgs($engine, $url, $provider, $location, $this);
         X_VlcShares_Plugins::broker()->preStartStreamer($engine, $url, $provider, $location, $this);
         $results = X_VlcShares_Plugins::broker()->canStartStreamer($engine, $url, $provider, $location, $this);
         $started = false;
         if (is_null($results) || !in_array(false, $results)) {
             X_Debug::i("Starting streamer {{$engine->getId()}}: {$engine}");
             $started = true;
             X_Streamer::i()->start($engine);
         } else {
             $pluginId = array_search(false, $results, true);
             X_Debug::f("Plugin {{$pluginId}} prevented streamer from starting...");
             //throw new Exception("Plugin {{$pluginId}} prevented streamer from starting");
         }
         X_VlcShares_Plugins::broker()->postStartStreamer($started, $engine, $url, $provider, $location, $this);
     } else {
         // otherwise i'm forced to fallback to old api
         //{{{ THIS CODE BLOCK WILL IS DEPRECATED AND WILL BE REMOVED IN 0.5.6 or 0.6
         //TODO remove in 0.5.6 or 0.6
         // each arg is stored as in a LIFO stack. If i put top priority as first,
         // low priority args could override it. So i use an inverse priority insertion
         // register low priority args
         X_VlcShares_Plugins::broker()->preRegisterVlcArgs($this->vlc, $provider, $location, $this);
         // register normal priority args
         X_VlcShares_Plugins::broker()->registerVlcArgs($this->vlc, $provider, $location, $this);
         // register top priority args
         X_VlcShares_Plugins::broker()->postRegisterVlcArgs($this->vlc, $provider, $location, $this);
         X_VlcShares_Plugins::broker()->preSpawnVlc($this->vlc, $provider, $location, $this);
         $this->vlc->spawn();
         X_VlcShares_Plugins::broker()->postSpawnVlc($this->vlc, $provider, $location, $this);
         try {
             $engine = X_VlcShares_Plugins::helpers()->streamer()->get('vlc');
         } catch (Exception $e) {
             X_Debug::w('No vlc streamer available');
             $engine = new X_Streamer_Engine_Vlc($this->vlc);
         }
         $url = $this->vlc->getArg('source');
         //}}}
     }
     $pageItems = new X_Page_ItemList_PItem();
     // i can't add here the go to play button
     // because i don't know the output type
     // i need to leave this to the plugins, too
     // i hope that an output manager plugin
     // will be always enabled
     // top links
     $pageItems->merge(X_VlcShares_Plugins::broker()->preGetStreamItems($engine, $url, $provider, $location, $this));
     // normal links
     $pageItems->merge(X_VlcShares_Plugins::broker()->getStreamItems($engine, $url, $provider, $location, $this));
     // bottom links
     $pageItems->merge(X_VlcShares_Plugins::broker()->postGetStreamItems($engine, $url, $provider, $location, $this));
     // trigger for page creation
     X_VlcShares_Plugins::broker()->gen_afterPageBuild($pageItems, $this);
 }
 public function modifyAction()
 {
     $request = $this->getRequest();
     $id = $request->getParam('id', null);
     if (is_null($id)) {
         $this->_helper->redirector('index', 'onlinelibrary');
     } else {
         $video = new Application_Model_Video();
         Application_Model_VideosMapper::i()->find($id, $video);
         if ($video->getId() == $id) {
             $form = new Application_Form_Video();
             $form->setAction($this->_helper->url('add'));
             try {
                 $_hosters = X_VlcShares_Plugins::helpers()->hoster()->getHosters();
                 $hosters = array('direct-url' => 'direct-url');
                 foreach ($_hosters as $idHoster => $pattern) {
                     $hosters[$idHoster] = $idHoster;
                 }
                 $form->hoster->setMultiOptions($hosters);
             } catch (Exception $e) {
             }
             $form->addElement('hidden', 'id');
             $form->setDefaults(array('id' => $video->getId(), 'title' => $video->getTitle(), 'idVideo' => $video->getIdVideo(), 'hoster' => $video->getHoster(), 'category' => $video->getCategory(), 'description' => $video->getDescription(), 'thumbnail' => $video->getThumbnail()));
             $this->view->video = $video;
             $this->view->form = $form;
             $this->render('add');
         } else {
             $this->_helper->redirector('index', 'onlinelibrary');
         }
     }
 }
 function editAction()
 {
     $id = $this->getRequest()->getParam('id', false);
     if ($id === false) {
         $this->_helper->flashMessenger(X_Env::_('gen_err_invaliddata'));
         $this->_helper->redirector('index', 'devices');
         return;
     }
     $device = new Application_Model_Device();
     Application_Model_DevicesMapper::i()->find($id, $device);
     if (is_null($device->getId())) {
         $this->_helper->flashMessenger(X_Env::_('gen_err_invaliddata'));
         $this->_helper->redirector('index', 'devices');
         return;
     }
     $lastdevices = false;
     try {
         /* @var $cacheHelper X_VlcShares_Plugins_Helper_Cache  */
         $cacheHelper = X_VlcShares_Plugins::helpers()->helper('cache');
         $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]);
         }
     }
     $lastdevices = array_keys($lastdevices);
     $defaults = array('id' => $device->getId(), 'label' => $device->getLabel(), 'pattern' => $device->getPattern(), 'exact' => (int) $device->isExact(), 'profile' => $device->getIdProfile(), 'gui' => $device->getGuiClass(), 'priority' => $device->getPriority(), 'profiles' => $device->getExtra('alt-profiles'));
     $form = $this->initForm();
     $form->setAction($this->_helper->url('save', 'devices'));
     $form->setDefaults($defaults);
     $this->view->lastdevices = $lastdevices;
     /*
     $this->view->outputs = $outputs;
     $this->view->profiles = $profiles;
     $this->view->guis = $guis;
     */
     $this->view->device = $device;
     $this->view->form = $form;
 }
 /**
  * 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->getHosterUrl($url);
     }
     // $url is an URL for sure now
     /* @var $realdebridHelper X_VlcShares_Plugins_Helper_RealDebrid */
     $realdebridHelper = X_VlcShares_Plugins::helpers()->helper('realdebrid');
     if ($realdebridHelper->setLocation($url)->isValid()) {
         return $realdebridHelper->getUrl();
     }
     throw new Exception("Invalid video", self::E_ID_INVALID);
 }
 /**
  * Show an error message if one of the plugin dependencies is missing
  * @param Zend_Controller_Action $this
  * @return X_Page_ItemList_Message
  */
 public function getIndexMessages(Zend_Controller_Action $controller)
 {
     $messages = new X_Page_ItemList_Message();
     if (class_exists("X_VlcShares_Plugins_Utils", true)) {
         if (count(X_VlcShares_Plugins::helpers()->hoster()->getHosters()) < 1) {
             $messages->append(X_VlcShares_Plugins_Utils::getMessageEntry($this->getId(), 'p_streamingonline_warning_nohosters', X_Page_Item_Message::TYPE_ERROR));
         }
     } else {
         $message = new X_Page_Item_Message($this->getId(), "PageParser API is required from Streaming-Online. Please, install PageParserLib plugin (alpha version)");
         $message->setType(X_Page_Item_Message::TYPE_FATAL);
         $messages->append($message);
     }
     return $messages;
 }
Example #19
0
 /**
  * Redirect fetch to MPlayer helper
  */
 private function fetchByFFMpeg()
 {
     return X_VlcShares_Plugins::helpers()->ffmpeg()->setLocation($this->_location)->getInfos();
 }
Example #20
0
 /**
  * get an array with standard information about the playable
  * @param string $url the hoster page or resource ID
  * @param boolean $isId
  * @return array format:
  * 		array(
  * 			'title' => TITLE
  * 			'description' => DESCRIPTION
  * 			'length' => LENGTH
  * 			...
  * 		)
  */
 function getPlayableInfos($url, $isId = true)
 {
     if (!$isId) {
         $url = $this->getResourceId($url);
     }
     // use cached values
     if (array_key_exists($url, $this->info_cache)) {
         return $this->info_cache[$url];
     }
     try {
         $helper = X_VlcShares_Plugins::helpers('hulu');
         /* @var $helper X_VlcShares_Plugins_Helper_Hulu */
         $infos = $helper->setLocation($url)->fetch(true);
     } catch (Exception $e) {
         throw new Exception("Hulu helper not found", self::E_URL_INVALID);
     }
     // add in cache
     $this->info_cache[$url] = $infos;
     return $infos;
 }
Example #21
0
 public function getLinkParams($linkId)
 {
     $channelParams = false;
     try {
         /* @var $cacheHelper X_VlcShares_Plugins_Helper_Cache */
         $cacheHelper = X_VlcShares_Plugins::helpers()->helper('cache');
         $channelParams = unserialize($cacheHelper->retrieveItem("weebtv::{$linkId}"));
         X_Debug::i("Valid cache entry found: " . print_r($channelParams, true));
     } catch (Exception $e) {
         // no cache plugin or no entry in cache, it's the same
         X_Debug::i("Cache disabled or no valid entry found");
     }
     if (!$channelParams) {
         // get the cid from the page
         X_Debug::i("Fetching channel params for: {{$linkId}}");
         $page = X_PageParser_Page::getPage(sprintf(self::URL_CHANNEL, $linkId), new X_PageParser_Parser_Preg('%<param name="movie" value="(?P<swf>.+?)" />.*?<param name="flashvars" value="&cid=(?P<cid>.+?)" />%s', X_PageParser_Parser_Preg::PREG_MATCH));
         $this->preparePageLoader($page);
         $_channelParams = $page->getParsed();
         $channelParams = array();
         // clean params from useless keys
         foreach ($_channelParams as $key => $value) {
             if ($key == 'cid' || $key == 'swf') {
                 $channelParams[$key] = $value;
             }
         }
         X_Debug::i("Params: " . print_r($channelParams, true));
         unset($page);
     }
     $cid = @$channelParams['cid'];
     $swfUrl = @$channelParams['swf'];
     if (!$cid) {
         X_Debug::e("Cid not found for channel {{$linkId}}");
         throw new Exception("Cid not found for channel {{$linkId}}");
     }
     // store in cache if possible
     try {
         /* @var $cacheHelper X_VlcShares_Plugins_Helper_Cache */
         $cacheHelper = X_VlcShares_Plugins::helpers()->helper('cache');
         $cacheHelper->storeItem("weebtv::{$linkId}", serialize($channelParams), 60);
         // store for the next 15 min
         X_Debug::i("Value stored in cache for 60 min: {key = weebtv::{$linkId}}");
     } catch (Exception $e) {
         // no cache plugin, next time i have to repeat the request
     }
     // first get the playlist url from the page
     $authEnabled = $this->config('auth.enabled', false);
     $username = rawurlencode($this->config('auth.username', ''));
     $password = rawurlencode($this->config('auth.password', ''));
     $authString = '';
     if ($authEnabled) {
         $authString = "&username={$username}&userpassword={$password}";
     }
     // without encode
     $username = $this->config('auth.username', '');
     $password = $this->config('auth.password', '');
     $http = new Zend_Http_Client(self::URL_PARAMS . $authString, array('headers' => array('User-Agent' => 'Mozilla/5.0 (X11; Linux i686) AppleWebKit/535.11 (KHTML, like Gecko) Chrome/17.0.963.56 Safari/535.11')));
     $http->setParameterPost('firstConnect', '1');
     $http->setParameterPost('watchTime', '0');
     $http->setParameterPost('cid', $cid);
     $http->setParameterPost('ip', 'NaN');
     if ($authEnabled) {
         $http->setParameterPost('username', $username);
         $http->setParameterPost('password', $password);
     }
     $str = $http->request('POST')->getBody();
     $params = array();
     parse_str($str, $params);
     $rtmpParams = array();
     $check = array('ticket' => 73, 'rtmp' => 10, 'time' => 16, 'playPath' => 11);
     foreach ($check as $label => $key) {
         if (isset($params[$key])) {
             $rtmpParams[$label] = $params[$key];
         }
     }
     X_Debug::i("Fetched stream params for channel {{$linkId}}: " . print_r($rtmpParams, true));
     $ticket = $rtmpParams['ticket'];
     if ($authEnabled) {
         $ticket .= ";{$username};{$password}";
     }
     $hosterLocation = X_RtmpDumpWeebTv::buildUri(array('rtmp' => $rtmpParams['rtmp'] . '/' . $rtmpParams['playPath'], 'swfUrl' => rawurldecode($swfUrl), 'weeb' => $ticket, 'live' => '1'));
     X_Debug::i("Hoster location resolved: {$hosterLocation}");
     return $hosterLocation;
 }
 /**
  * Shortcut for X_VlcShares_Plugins::helpers()
  * @see X_VlcShares_Plugins::helpers()
  * @return X_VlcShares_Plugins_Helper_Broker
  */
 public function helpers($helperName = null)
 {
     return X_VlcShares_Plugins::helpers($helperName);
 }
 function saveAction()
 {
     if (!$this->getRequest()->isPost()) {
         $this->_helper->flashMessenger(array('type' => 'error', 'text' => X_Env::_('p_auth_err_invalidrequest')));
         $this->_helper->redirector('accounts', 'auth');
         return;
     }
     $form = new Application_Form_AuthAccount();
     if ($this->getRequest()->getPost('id', false)) {
         $form->password->setAttrib('allowEmpty', true);
         $form->password->setRequired(false);
         $form->username->setRequired(false);
         $form->username->setAttrib('disabled', true);
     }
     $_permissions = X_VlcShares_Plugins::helpers()->acl()->getClasses();
     $permissions = array();
     $permissionsDefault = array();
     foreach ($_permissions as $perm) {
         /* @var $perm Application_Model_AclClass */
         $description = X_Env::_($perm->getDescription());
         $permissions[$perm->getName()] = "{$perm->getName()} - <i>{$description}</i>";
         //if ( in_array($perm->getName(), X_VlcShares_Plugins::helpers()->acl()->getPermissions($account->getUsername())) ) {
         //$permissionsDefault[] = $perm->getName();
         //}
     }
     $form->permissions->setMultiOptions($permissions);
     if ($form->isValid($this->getRequest()->getPost())) {
         $account = new Application_Model_AuthAccount();
         $id = $form->getValue('id');
         if ($id) {
             Application_Model_AuthAccountsMapper::i()->find($id, $account);
             if (is_null($account->getId())) {
                 $this->_helper->flashMessenger(array('type' => 'error', 'text' => X_Env::_('p_auth_err_invalidaccount')));
                 $this->_helper->redirector('accounts', 'auth');
                 return;
             }
             // empty passwords are ignored: empty = do not change
             if (strlen($form->getValue('password')) > 0) {
                 $account->setPassword(md5("{$account->getUsername()}:{$form->getValue('password')}"))->setPassphrase(md5("{$account->getUsername()}:{$form->getValue('password')}:" . rand(10000, 99999) . time()));
             }
         } else {
             $account->setUsername($form->getValue('username'));
             $account->setPassword(md5("{$form->getValue('username')}:{$form->getValue('password')}"))->setPassphrase(md5("{$form->getValue('username')}:{$form->getValue('password')}:" . rand(10000, 99999) . time()));
         }
         $account->setEnabled((bool) $form->getValue('enabled'))->setAltAllowed((bool) $form->getValue('altallowed'));
         try {
             Application_Model_AuthAccountsMapper::i()->save($account);
             // if is a new account, grant browse permission to the new account
             /*
             if ( !$id ) {
             	X_VlcShares_Plugins::helpers()->acl()->grantPermission($account->getUsername(), Application_Model_AclClass::CLASS_BROWSE);
             }
             */
             $acl = X_VlcShares_Plugins::helpers()->acl();
             $prevPermissions = array();
             if ($id) {
                 $prevPermissions = $acl->getPermissions($account->getUsername());
             }
             $newPermissions = $form->getValue('permissions');
             // first remove all old permissions that are not available anymore
             foreach ($prevPermissions as $pPerm) {
                 if (!in_array($pPerm, $newPermissions)) {
                     $acl->revokePermission($account->getUsername(), $pPerm);
                 }
             }
             // add new granted not in old permissions
             foreach ($newPermissions as $nPerm) {
                 if (!in_array($nPerm, $prevPermissions)) {
                     $acl->grantPermission($account->getUsername(), $nPerm);
                 }
             }
             $this->_helper->flashMessenger(array('type' => 'success', 'text' => X_Env::_('p_auth_accountstored')));
             $this->_helper->redirector('accounts', 'auth');
         } catch (Exception $e) {
             $this->_helper->flashMessenger(array('type' => 'error', 'text' => X_Env::_('p_auth_dberror', $e->getMessage())));
             $this->_helper->redirector('accounts', 'auth');
         }
     } else {
         $form->setAction($this->_helper->url('save', 'auth'));
         $form->setDefaults($this->getRequest()->getPost());
         $this->view->form = $form;
         $this->_helper->viewRenderer->setScriptAction('edit');
     }
 }
 public function cleanCurrentCacheEntry()
 {
     if ($this->lastUrl == null) {
         X_Debug::e("No location available");
     }
     try {
         /* @var $cacheHelper X_VlcShares_Plugins_Helper_Cache */
         $cacheHelper = X_VlcShares_Plugins::helpers()->helper('cache');
         $cacheHelper->storeItem("realdebrid::{$this->lastUrl}", '', 0);
     } catch (Exception $e) {
         X_Debug::w("Cache disabled, clean is useless");
     }
 }
 private function _getRealId($fakeId, $t)
 {
     try {
         /* @var $cacheHelper X_VlcShares_Plugins_Helper_Cache */
         $cacheHelper = X_VlcShares_Plugins::helpers()->helper('cache');
         $response = $cacheHelper->retrieveItem("icefilms::{$t},{$fakeId}");
         X_Debug::i("Valid cache entry found: {$response}");
         return $response;
     } catch (Exception $e) {
         // no cache plugin or no entry in cache, it's the same
         X_Debug::i("Cache disabled or no valid entry found");
     }
     // hover check
     $m = rand(100, 300) * -1;
     // time check
     $s = rand(5, 50);
     $http = new Zend_Http_Client("http://www.icefilms.info/membersonly/components/com_iceplayer/video.php?h=374&w=631&vid={$t}&img=", array('maxredirects' => $this->config('request.maxredirects', 10), 'timeout' => $this->config('request.timeout', 25)));
     // first request, set the cookies
     $htmlString = $http->setCookieJar(true)->request()->getBody();
     //$captchaPattern = '/name\=captcha value\=([^\>]+)/';
     //$secretPattern = '/name\=secret value\=([^\>]+)/';
     $secretPattern = '/f\\.lastChild\\.value=\\"([^\']+)\\",a/';
     //$iqsPattern = '/name\=iqs value\=([^\>]+)/';
     $sec = array();
     if (preg_match($secretPattern, $htmlString, $sec)) {
         if (count($sec)) {
             $sec = $sec[1];
         } else {
             X_Debug::w("Secret string not found");
             $sec = '';
         }
     } else {
         X_Debug::e("Secret pattern failed {{$secretPattern}}");
         $sec = '';
     }
     $http->setUri('http://www.icefilms.info/membersonly/components/com_iceplayer/video.phpAjaxResp.php');
     $http->setHeaders(array('User-Agent: Mozilla/5.0 (X11; Linux i686) AppleWebKit/535.1 (KHTML, like Gecko) Chrome/13.0.782.215 Safari/535.1', 'Content-type:application/x-www-form-urlencoded', 'Origin: http://www.icefilms.info', "Referer: http://www.icefilms.info/membersonly/components/com_iceplayer/video.php?h=374&w=631&vid={$t}&img="));
     $http->setMethod(Zend_Http_Client::POST)->setParameterPost('id', $fakeId)->setParameterPost('s', $s)->setParameterPost('iqs', '')->setParameterPost('url', '')->setParameterPost('m', $m)->setParameterPost('cap', '')->setParameterPost('sec', $sec)->setParameterPost('t', $t);
     //X_Debug::i("Cookies: ".$http->getCookieJar()->getAllCookies(Zend_Http_CookieJar::COOKIE_STRING_CONCAT));
     $response = $http->request()->getBody();
     //X_Debug::i("Request: ".$http->getLastRequest());
     //X_Debug::i("Response: ".$http->getLastResponse()->getBody());
     X_Debug::i("Raw: {$response}");
     $response = trim(urldecode(substr($response, strlen('/membersonly/components/com_iceplayer/GMorBMlet.php?url='))), '&');
     X_Debug::i("Filtered: {$response}");
     try {
         /* @var $cacheHelper X_VlcShares_Plugins_Helper_Cache */
         $cacheHelper = X_VlcShares_Plugins::helpers()->helper('cache');
         $cacheHelper->storeItem("icefilms::{$t},{$fakeId}", $response, 15);
         // store for the next 15 min
         X_Debug::i("Value stored in cache for 15 min: {key = icefilms::{$t},{$fakeId}, value = {$response}}");
     } catch (Exception $e) {
         // no cache plugin, next time i have to repeat the request
     }
     return $response;
 }
 function thumbAction()
 {
     // time to get params from get
     /* @var $request Zend_Controller_Request_Http */
     $request = $this->getRequest();
     if (!is_writable(APPLICATION_PATH . "/../public/images/fsthumbs/thumbs/")) {
         throw new Exception('"/public/images/fsthumbs/thumbs/" must be writable');
     }
     $l = $request->getParam('l', false);
     if ($l == false) {
         throw new Exception(X_Env::_('p_fsthumbs_invalidlocation'));
     }
     $ldec = X_Env::decode($l);
     $itemRealPath = $this->fsPlugin->resolveLocation($ldec);
     if ($itemRealPath == false) {
         throw new Exception(X_Env::_('p_fsthumbs_invalidlocation'));
     }
     // cache check and redirect if possible
     $imagePath = "/images/fsthumbs/thumbs/{$l}.jpg";
     // else thumb creation and then redirect
     if (!file_exists(APPLICATION_PATH . "/../public{$imagePath}")) {
         if (X_VlcShares_Plugins::helpers()->ffmpeg()->isEnabled()) {
             // create the thumb
             $ffmpegPath = $this->options->helpers->ffmpeg->path;
             $destPath = APPLICATION_PATH . "/../public{$imagePath}";
             $secOffset = intval($this->plugin->config('capture.seconds', '2')) + (int) rand(0, 10) - 5;
             if ($secOffset < 1) {
                 $secOffset = 1;
             }
             $imageDim = $this->plugin->config('thumbs.size', '320x240');
             if (!preg_match('/(\\d{3})x(\\d{3})/', $imageDim)) {
                 X_Debug::e("Thumb size is not a valid value (IIIxIII): {$imageDim}");
                 $imageDim = '320x240';
             }
             // thumb creation should be always completed
             ignore_user_abort(true);
             // semaphore is needed for folders with lots files and low-end cpus
             $lockFile = fopen(__FILE__, 'r+');
             flock($lockFile, LOCK_EX);
             $exec = "{$ffmpegPath} -itsoffset -{$secOffset} -i \"{$itemRealPath}\" -vcodec mjpeg -vframes 1 -an -f rawvideo -s {$imageDim} \"{$destPath}\"";
             $return = X_Env::execute($exec);
             // remove lock
             flock($lockFile, LOCK_UN);
             fclose($lockFile);
             $filesize = @filesize($destPath);
             if ($filesize == 0) {
                 // it's better to replace the thumbs created with
                 // a placeholder file to prevent a new creation
                 @copy(APPLICATION_PATH . "/../public/images/fsthumbs/nothumbs.jpg", $destPath);
                 clearstatcache(true, $destPath);
                 $filesize = @filesize($destPath);
             }
             $thumb = new Application_Model_FsThumb();
             // try to load an old entry in db, this prevent error when files are removed but not the reference in db
             Application_Model_FsThumbsMapper::i()->fetchByPath($itemRealPath, $thumb);
             $thumb->setCreated(time())->setPath($itemRealPath)->setUrl($imagePath)->setSize(@filesize($destPath));
             try {
                 Application_Model_FsThumbsMapper::i()->save($thumb);
                 X_Debug::i('Thumb stored');
             } catch (Exception $e) {
                 X_Debug::e("Error while storing thumb data: {$e->getMessage()}");
             }
             //X_Debug::i(var_export($return, true));
             // -itsoffset -30  -i test.avi -vcodec mjpeg -vframes 1 -an -f rawvideo -s 320x240 test.jpg
         } else {
             $imagePath = "/images/fsthumbs/nothumbs.jpg";
         }
     }
     // if it is wiimc i have to return here the image directly, not a redirect
     if (X_VlcShares_Plugins::helpers()->devices()->isWiimc()) {
         $this->getResponse()->clearAllHeaders();
         ob_end_clean();
         $this->getResponse()->setHeader('Content-Type', 'image/jpeg')->setHeader('Content-Length', @filesize(APPLICATION_PATH . "/../public{$imagePath}"));
         $this->getResponse()->sendHeaders();
         readfile(APPLICATION_PATH . "/../public{$imagePath}");
     } else {
         $this->_helper->redirector->gotoUrlAndExit($imagePath, array('prependBase' => true, 'code' => 302));
     }
 }
 public function addAction()
 {
     $csrf = new Zend_Form_Element_Hash('csrf', array('salt' => __CLASS__));
     $validCheck = $csrf->isValid($this->getRequest()->getParam('csrf', false));
     $csrf->initCsrfToken();
     $hash = $csrf->getHash();
     $return = array('success' => true, 'api' => array('resolver' => $this->_helper->url->url(array('controller' => 'bookmarklets', 'action' => 'resolver', 'csrf' => $hash)), 'adder' => $this->_helper->url->url(array('controller' => 'bookmarklets', 'action' => 'add', 'csrf' => $hash)), 'bookmark' => $this->_helper->url->url(array('controller' => 'bookmarklets', 'action' => 'bookmark', 'csrf' => $hash))), 'links' => array());
     if ($validCheck) {
         $links = $this->getRequest()->getParam("links", array());
         $category = $this->getRequest()->getParam("category", false);
         $added = 0;
         $ignored = 0;
         $total = count($links);
         if ($category) {
             $hosterHelper = X_VlcShares_Plugins::helpers()->hoster();
             foreach ($links as $link) {
                 $href = isset($link['href']) ? $link['href'] : false;
                 $title = isset($link['title']) ? $link['title'] : false;
                 $description = isset($link['description']) ? $link['description'] : false;
                 $thumbnail = isset($link['thumbnail']) ? $link['thumbnail'] : false;
                 if (!$href || !$title) {
                     $ignored++;
                     continue;
                 }
                 try {
                     $hoster = $hosterHelper->findHoster($href);
                     $id = $hoster->getResourceId($href);
                     $video = new Application_Model_Video();
                     $video->setHoster($hoster->getId())->setIdVideo($id)->setTitle($title)->setCategory($category);
                     if ($thumbnail) {
                         $video->setThumbnail($thumbnail);
                     }
                     if ($description) {
                         $video->setDescription($description);
                     }
                     try {
                         Application_Model_VideosMapper::i()->save($video);
                         $added++;
                     } catch (Exception $e) {
                         $ignored++;
                     }
                 } catch (Exception $e) {
                     X_Debug::w("No hoster found: {{$e->getMessage()}}");
                     $ignored++;
                 }
             }
             $return['links'] = array('total' => $total, 'ignored' => $ignored, 'added' => $added);
         } else {
             X_Debug::e("No category selected");
             $return['success'] = false;
         }
     } else {
         X_Debug::e("Invalid CSRF");
         $return['success'] = false;
     }
     $this->_helper->json($return, true, false);
 }
 /**
  * get an array with standard information about the playable
  * @param string $url the hoster page or resource ID
  * @param boolean $isId
  * @return array format:
  * 		array(
  * 			'title' => TITLE
  * 			'description' => DESCRIPTION
  * 			'length' => LENGTH
  * 			...
  * 		)
  */
 function getPlayableInfos($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');
     try {
         $videoEntry = $youtubeHelper->getVideo($url);
         $thumb = $videoEntry->getVideoThumbnails();
         $thumb = @$thumb[0]['url'];
         $thumb = str_replace('default', '0', $thumb);
         // use cached values
         $infos = array('title' => $videoEntry->getVideoTitle(), 'description' => $videoEntry->getVideoDescription(), 'length' => X_Env::formatTime($videoEntry->getVideoDuration()), 'thumbnail' => $thumb);
         return $infos;
     } catch (Exception $e) {
         throw new Exception("Invalid video", self::E_ID_INVALID);
     }
 }
 function convertAction()
 {
     // time to get params from get
     /* @var $request Zend_Controller_Request_Http */
     $request = $this->getRequest();
     // this action is so special.... no layout or viewRenderer
     $this->_helper->viewRenderer->setNoRender();
     $this->_helper->layout->disableLayout();
     $videoId = $request->getParam('v', false);
     // youtube video id
     $format = $request->getParam('f', false);
     // convert to format
     $lcode = $request->getParam('l', false);
     // language code
     if ($videoId === false || $format === false || !array_key_exists($format, $this->cFormats) || $lcode === false) {
         // invalid request
         echo 'Invalid Request';
         return;
     }
     // $lcode need to be decoded
     $lcode = X_Env::decode($lcode);
     /* @var $helper X_VlcShares_Plugins_Helper_Youtube */
     $helper = X_VlcShares_Plugins::helpers('youtube');
     try {
         $sub = $helper->getSubtitleNOAPI($videoId, $lcode);
     } catch (Exception $e) {
         echo 'Invalid Language Code';
         return;
     }
     // $sub format:
     /*
     $sub = array(
     	'id' => $current->getAttribute('id'),
     	'name' => $current->getAttribute('name'),
     	'lang_code' => $current->getAttribute('lang_code'),
     	'lang_original' => $current->getAttribute('lang_original'),
     	'lang_translated' => $current->getAttribute('lang_translated'),
     	'lang_default' => $current->getAttribute('lang_default'),
     	'xml_url'	=> 'http://video.google.com/timedtext?type=track&' 
     						.'lang='.utf8_encode($sub['lang_code']).'&'
     						.'name='.utf8_encode($sub['name']).'&'
     						.'v='.$this->_location;
     );
     */
     $uri = $sub['xml_url'];
     $http = $helper->getHttpClient($uri);
     $xml = $http->request(Zend_Http_Client::GET)->getBody();
     $dom = new Zend_Dom_Query($xml);
     $method = $this->cFormats[$format];
     $string = $this->{$method}($dom);
     echo $string;
 }
 public function stop()
 {
     if (!$this->isStreaming()) {
         return;
     }
     $thread = X_Threads_Manager::instance()->getThreadInfo(self::THREAD_ID);
     $infos = $thread->getInfo();
     if (isset($infos['message_params']) && isset($infos['message_params']['streamerId'])) {
         $engineId = $infos['message_params']['streamerId'];
         $engine = X_VlcShares_Plugins::helpers()->streamer()->get($engineId);
         //$engine = new $engineClass();
         if ($engine instanceof X_Streamer_StopperEngine) {
             $engine->doStop($infos);
         }
     } else {
         X_Debug::e("Invalid streamer");
     }
     X_Threads_Manager::instance()->halt($thread);
 }