/**
  * 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);
     }
     // TODO find alternative
     return X_Env::routeLink('veoh', 'video', array('id' => $url));
 }
 public function bmscriptAction()
 {
     $linkAll = X_Env::routeLink('megavideo', 'bookmarklets', array('type' => 'list'));
     $linkSingle = X_Env::routeLink('megavideo', 'bookmarklets', array('type' => 'video'));
     $linkSingleCategoryRequest = X_Env::_('megavideo_bookmarklets_category_selection');
     $paginationRequest = X_Env::_('megavideo_bookmarklets_lotoflinks');
     $allpagesearchRequest = X_Env::_('megavideo_bookmarklets_nolinksinselectioncontinue');
     $statusWindowLink = X_Env::routeLink('megavideo', 'status');
     $this->getResponse()->setHeader('Content-Type', 'text/javascript');
     $this->_helper->layout()->disableLayout();
     $this->view->linkAll = $linkAll;
     $this->view->linkSingle = $linkSingle;
     $this->view->linkSingleCategoryRequest = $linkSingleCategoryRequest;
     $this->view->paginationRequest = $paginationRequest;
     $this->view->allpagesearchRequest = $allpagesearchRequest;
     $this->view->statusWindowLink = $statusWindowLink;
 }
 public function getUrl()
 {
     $this->_fetch();
     if ($this->options->premium && $this->options->username != '' && $this->options->password != '') {
         // i have to check here for quality mode
         $quality = Zend_Controller_Front::getInstance()->getRequest()->getParam('megavideo:quality', 'normal');
         switch ($quality) {
             case self::QUALITY_NOPREMIUM:
                 return $this->_fetched->get('URL');
             case self::QUALITY_NORMAL:
                 return X_Env::routeLink('megavideo', 'premium', array('v' => $this->_fetched->id));
             case self::QUALITY_FULL:
             default:
                 return X_Env::routeLink('megavideo', 'premium', array('v' => $this->_fetched->id, 'q' => $quality));
         }
     } else {
         return $this->_fetched->get('URL');
     }
 }
 /**
  * @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;
 }
 /**
  * @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 (array_key_exists($location, $this->cachedLocation)) {
         return $this->cachedLocation[$location];
     }
     X_Debug::i("Requested location: {$location}");
     @(list($type, $letter, $thread, $href) = explode('/', $location, 4));
     X_Debug::i("Type: {$type}, Letter: {$letter}, Thread: {$thread}, Ep: {$href}");
     if ($href == null || $thread == null || $type == null) {
         $this->cachedLocation[$location] = false;
         return false;
     }
     $return = false;
     if ($type == self::TYPE_SERIES_PERGENRE || $type == self::TYPE_SERIES_PERLETTER) {
         if ($this->helpers()->devices()->isWiimc() || $this->config('proxy.enabled', true)) {
             // X_Env::routeLink should be deprecated, but now is the best option
             $return = X_Env::routeLink('animeftw', 'proxy2', array('id' => X_Env::encode($href)));
         } else {
             // $href is the video id
             try {
                 /* @var $helper X_VlcShares_Plugins_Helper_AnimeFTW */
                 $helper = $this->helpers('animeftw');
                 $episode = $helper->getEpisode($href);
                 if (@$episode['url'] != '') {
                     $return = $episode['url'];
                 }
             } catch (Exception $e) {
             }
         }
     } else {
         // i have to fetch the streaming page :(
         $baseUrl = $this->config('base.url', self::BASE_URL);
         $baseUrl .= "{$type}/{$thread}/{$href}";
         $htmlString = $this->_loadPage($baseUrl, true);
         // <param name=\"src\" value=\"([^\"]*)\" \/>
         if (preg_match('/<param name=\\"src\\" value=\\"([^\\"]*)\\" \\/>/', $htmlString, $match)) {
             // link = match[1]
             $linkUrl = $match[1];
             if (strpos($linkUrl, 'megavideo') !== false) {
                 @(list(, $megavideoID) = explode('/v/', $linkUrl, 2));
                 X_Debug::i("Megavideo ID: {$megavideoID}");
                 try {
                     /* @var $megavideo X_VlcShares_Plugins_Helper_Megavideo */
                     $megavideo = $this->helpers('megavideo');
                     // if server isn't specified, there is no video
                     //$megavideo->setLocation($megavideoID);
                     if ($megavideo->setLocation($megavideoID)->getServer()) {
                         $return = $megavideo->getUrl();
                     }
                 } catch (Exception $e) {
                     X_Debug::e($e->getMessage());
                 }
             } else {
                 // files in videos2.animeftw.tv require a valid referer page to be watched
                 // and animeftw controller does the magic trick
                 if ($this->config('proxy.enabled', true)) {
                     // X_Env::routeLink should be deprecated, but now is the best option
                     $linkUrl = X_Env::routeLink('animeftw', 'proxy', array('v' => X_Env::encode($linkUrl), 'r' => X_Env::encode($baseUrl)));
                 }
                 $return = $linkUrl;
             }
         }
     }
     $this->cachedLocation[$location] = $return;
     return $return;
 }