Exemplo n.º 1
0
 /**
  * Fill $items of links in page
  * @param X_Page_ItemList_PItem $items
  */
 public function menuLinks(X_Page_ItemList_PItem $items, $id)
 {
     $bookmark = new Application_Model_Bookmark();
     Application_Model_BookmarksMapper::i()->find($id, $bookmark);
     // invalid pageid!
     if ($bookmark->isNew()) {
         return;
     }
     $page = X_PageParser_Page::getPage($bookmark->getUrl(), new X_PageParser_Parser_HosterLinks($this->helpers()->hoster()));
     $loader = $page->getLoader();
     if ($loader instanceof X_PageParser_Loader_Http || $loader instanceof X_PageParser_Loader_HttpAuthRequired) {
         $http = $loader->getHttpClient()->setConfig(array('maxredirects' => $this->config('request.maxredirects', 10), 'timeout' => $this->config('request.timeout', 25)));
         if ($bookmark->getUa()) {
             X_Debug::i("Setting User-Agent...");
             $http->setHeaders(array("User-Agent: {$bookmark->getUa()}"));
         }
         if ($bookmark->getCookies()) {
             X_Debug::i("Setting Cookies...");
             $http->setHeaders("Cookie", $bookmark->getCookies());
         }
     }
     $links = $page->getParsed();
     foreach ($links as $i => $link) {
         /* @var $bookmark Application_Model_Bookmark */
         $item = new X_Page_Item_PItem("{$this->getId()}-{$bookmark->getId()}-{$i}", "{$link['label']} [{$link['hoster']->getId()}]");
         $item->setIcon("/images/icons/hosters/{$link['hoster']->getId()}.png")->setType(X_Page_Item_PItem::TYPE_ELEMENT)->setCustom(__CLASS__ . ':location', "{$bookmark->getId()}/{$link['url']}")->setLink(array('l' => X_Env::encode("{$bookmark->getId()}/{$link['url']}"), 'action' => 'mode'), 'default', false);
         $items->append($item);
     }
 }
Exemplo n.º 2
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;
 }
Exemplo n.º 3
0
 public function menuEpisodes(X_Page_ItemList_PItem $items, $type, $filter, $pageN, $show, $season, $showType)
 {
     $page = X_PageParser_Page::getPage(sprintf(self::URL_BASE, $show), new X_PageParser_Parser_Preg('/new VideoSlider\\("' . $showType . '",(?P<json>.*?)\\)\\s+\\/\\/]]>/si', X_PageParser_Parser_Preg::PREG_MATCH));
     $this->preparePageLoader($page);
     $parsed = $page->getParsed();
     if ($parsed) {
         $json = Zend_Json::decode($parsed['json']);
         $url = "{$json['url']}?";
         foreach ($json['urlOptions'] as $key => $value) {
             if ($key == 'season') {
                 $value = $season;
             }
             if ($key == 'page') {
                 $value = "%s";
             }
             $url .= "{$key}={$value}&";
         }
         $url = rtrim($url, "&");
         $i = 1;
         while (true) {
             $page = X_PageParser_Page::getPage(sprintf($url, $i++), new X_PageParser_Parser_Preg('/<li.*?<a href=".*?watch\\/(?P<epid>.*?)\\/(?P<epname>.*?)".*?<img src="(?P<thumbnail>.*?)".*?alt="(?P<label>.*?)"(?P<extra>.*?)<\\/li>/s', X_PageParser_Parser_Preg::PREG_MATCH_ALL, PREG_SET_ORDER));
             $this->preparePageLoader($page);
             $parsed = $page->getParsed();
             // exit first time no item found
             if (!count($parsed)) {
                 return;
             }
             foreach ($parsed as $match) {
                 $label = $match['label'];
                 $href = "{$match['epid']}:{$match['epname']}";
                 $thumbnail = $match['thumbnail'];
                 if (strpos($match['extra'], 'class="hplus-sticker') !== false) {
                     // can ignore plus content
                     if (!$this->config('show.plus', true)) {
                         continue;
                     }
                     $label = "[Hulu+] {$label}";
                 }
                 $item = new X_Page_Item_PItem($this->getId() . "-{$show}-{$season}-{$href}", $label);
                 $item->setIcon("/images/icons/file_32.png");
                 $item->setType(X_Page_Item_PItem::TYPE_ELEMENT)->setCustom(__CLASS__ . ':location', "{$type}/{$filter}/{$pageN}/{$show}/{$season}:{$showType}/{$href}")->setThumbnail($thumbnail)->setDescription(APPLICATION_ENV == 'development' ? "{$type}/{$filter}/{$pageN}/{$show}/{$season}:{$showType}/{$href}" : null)->setLink(array('action' => 'mode', 'l' => X_Env::encode("{$type}/{$filter}/{$pageN}/{$show}/{$season}:{$showType}/{$href}")), 'default', false);
                 $items->append($item);
             }
             // if parsed < per-page, i know there are no more videos
             if (count($parsed) < 5) {
                 break;
             }
         }
     }
 }
 private function _fetchVideos(X_Page_ItemList_PItem $items, $resourceType, $pageN, $resourceGroup, $resourceId)
 {
     X_Debug::i("Fetching videos for {$resourceType}, {$pageN}, {$resourceGroup}, {$resourceId}");
     // as first thing we have to recreate the resource url from resourceId
     $url = sprintf(self::URL_BASE, $resourceId);
     $page = X_PageParser_Page::getPage($url, X_PageParser_Parser_StreamingOnlineVideos::instance());
     $this->preparePageLoader($page);
     foreach ($page->getParsed() as $link) {
         $videoId = $link['videoId'];
         $hosterId = $link['hosterId'];
         $videoCode = $link['link'];
         $videoLabel = trim("{$link['label']} [{$link['hosterId']}]");
         //$videoThumb = $link['thumbnail'];
         $item = new X_Page_Item_PItem("{$this->getId()}-hoster-{$hosterId}-{$videoId}", $videoLabel);
         $item->setIcon('/images/icons/file_32.png')->setType(X_Page_Item_PItem::TYPE_ELEMENT)->setCustom(__CLASS__ . ':location', "{$resourceType}/{$pageN}/{$resourceGroup}/{$resourceId}/{$videoCode}")->setLink(array('action' => 'mode', 'l' => X_Env::encode("{$resourceType}/{$pageN}/{$resourceGroup}/{$resourceId}/{$videoCode}")), 'default', false);
         if (APPLICATION_ENV == 'development') {
             $item->setDescription("{$resourceType}/{$pageN}/{$resourceGroup}/{$resourceId}/{$videoCode}");
         }
         /*
         if ( $videoThumb ) {
         	$item->setThumbnail($videoThumb);
         }
         */
         $items->append($item);
     }
 }
Exemplo n.º 5
0
 private function getLinkHosterUrl($linkId)
 {
     try {
         /* @var $cacheHelper X_VlcShares_Plugins_Helper_Cache */
         $cacheHelper = X_VlcShares_Plugins::helpers()->helper('cache');
         $response = $cacheHelper->retrieveItem("raiclick::{$linkId}");
         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");
     }
     // first get the playlist url from the page
     $page = X_PageParser_Page::getPage(sprintf(self::URL_PLAYABLE, $linkId), new X_PageParser_Parser_Preg('/videoURL = \\"(?P<url>.*?)\\"/', X_PageParser_Parser_Preg::PREG_MATCH));
     $this->preparePageLoader($page);
     $parsed = $page->getParsed();
     $url = $parsed['url'];
     $hosterLocation = false;
     if ($url) {
         // check if url schema is mms
         if (X_Env::startWith($url, 'mms://')) {
             $hosterLocation = $url;
         } else {
             // the get the video url from the playlist
             $page = X_PageParser_Page::getPage($url, new X_PageParser_Parser_Preg('/HREF="(?P<url>.*?)\\"/', X_PageParser_Parser_Preg::PREG_MATCH));
             $this->preparePageLoader($page);
             $parsed = $page->getParsed();
             $hosterLocation = $parsed['url'];
         }
     }
     X_Debug::i("Hoster location resolved: {$hosterLocation}");
     try {
         /* @var $cacheHelper X_VlcShares_Plugins_Helper_Cache */
         $cacheHelper = X_VlcShares_Plugins::helpers()->helper('cache');
         $cacheHelper->storeItem("raiclick::{$linkId}", $hosterLocation, 15);
         // store for the next 15 min
         X_Debug::i("Value stored in cache for 15 min: {key = raiclick::{$linkId}, value = {$hosterLocation}}");
     } catch (Exception $e) {
         // no cache plugin, next time i have to repeat the request
     }
     return $hosterLocation;
 }
Exemplo n.º 6
0
 public function menuLinks(X_Page_ItemList_PItem $items, $type, $filter, $title, $season, $episode, $pageN = 1)
 {
     $pageN = X_VlcShares_Plugins_Utils::isset_or($pageN, 1);
     if ($type == 'documentaries') {
         $page = X_PageParser_Page::getPage(sprintf(self::URL_INDEX_LINKS_DOCUMENTARIES, $type, $title, $pageN), new X_PageParser_Parser_TvLinks(X_PageParser_Parser_TvLinks::MODE_LINKS, $type, $filter, $title, $season, $episode, $pageN));
     } else {
         $page = X_PageParser_Page::getPage(sprintf(self::URL_INDEX_LINKS, $type, $title, $season, $episode, $pageN), new X_PageParser_Parser_TvLinks(X_PageParser_Parser_TvLinks::MODE_LINKS, $type, $filter, $title, $season, $episode, $pageN));
     }
     $this->preparePageLoader($page);
     $parsed = $page->getParsed();
     if ($pageN > 1) {
         // add -previous-page-
         $previousPage = $pageN - 1;
         $items->append(X_VlcShares_Plugins_Utils::getPreviousPage("{$type}/{$filter}/{$title}/{$season}/{$episode}/{$previousPage}", $previousPage));
     }
     foreach ($parsed as $match) {
         $id = $match['id'];
         $hoster = $match['hoster'];
         $label = X_Env::_('p_tvlinks_watchon', ucfirst($hoster));
         $thumbnail = array_key_exists('thumbnail', $match) ? $match['thumbnail'] : null;
         $item = new X_Page_Item_PItem($this->getId() . "-{$type}-{$filter}-{$title}-{$season}-{$episode}-{$id}", $label);
         if (file_exists(APPLICATION_PATH . '/../public/images/icons/hosters/' . $hoster . '.png')) {
             $item->setIcon("/images/icons/hosters/{$hoster}.png");
         } else {
             if (X_VlcShares::VERSION == "0.5.4") {
                 $item->setIcon("/images/icons/file_32.png");
             } else {
                 // icons exists only in vlc-shares > 0.5.4
                 $item->setIcon("/images/icons/unknown-hoster.png");
             }
         }
         $item->setType(X_Page_Item_PItem::TYPE_ELEMENT)->setCustom(__CLASS__ . ':location', "{$type}/{$filter}/{$title}/{$season}/{$episode}/{$pageN}/{$id}")->setDescription(APPLICATION_ENV == 'development' ? "{$type}/{$filter}/{$title}/{$season}/{$episode}/{$pageN}/{$id}" : null)->setLink(array('action' => 'mode', 'l' => X_Env::encode("{$type}/{$filter}/{$title}/{$season}/{$episode}/{$pageN}/{$id}")), 'default', false);
         if ($thumbnail) {
             $item->setThumbnail($thumbnail);
         }
         $items->append($item);
     }
     if ($page->getParsed(new X_PageParser_Parser_TvLinks(X_PageParser_Parser_TvLinks::MODE_NEXTPAGE, $type, $filter, $title, $season, $episode, $pageN))) {
         $nextPage = $pageN + 1;
         $items->append(X_VlcShares_Plugins_Utils::getNextPage("{$type}/{$filter}/{$title}/{$season}/{$episode}/{$nextPage}", $nextPage));
     }
 }