private function _fetchGroupAnime(X_Page_ItemList_PItem $items, $resourceType, $pageN = 1) { $page = X_PageParser_Page::getPage(sprintf(self::URL_ANIME_INDEX_AZ, $pageN), X_PageParser_Parser_Preg::factory(self::PATTERN_MOVIESINCATEGORY, X_PageParser_Parser_Preg::PREG_MATCH_ALL, PREG_SET_ORDER)); $this->preparePageLoader($page); $parsed = $page->getParsed(); if ($pageN > 1) { // append "back" as first $prevPage = $pageN - 1; $items->append(X_VlcShares_Plugins_Utils::getPreviousPage("{$resourceType}/{$prevPage}", $prevPage)); } // $parsed format = array(array('image', 'category', 'id', 'label'),..) foreach ($parsed as $pItem) { $label = trim($pItem['label']); $subtype = $pageN; $group = @$pItem['category'] ? "/{$pItem['category']}" : ''; $id = @$pItem['id'] ? "/{$pItem['id']}" : ''; X_Debug::i("Parsed items: " . var_export(array($id, $subtype, $group, $label), true)); $item = new X_Page_Item_PItem($this->getId() . "-{$resourceType}-{$subtype}-{$group}-{$id}", $label); $item->setIcon('/images/icons/folder_32.png')->setType(X_Page_Item_PItem::TYPE_CONTAINER)->setCustom(__CLASS__ . ':location', "{$resourceType}/{$group}")->setDescription(APPLICATION_ENV == 'development' ? "{$resourceType}/{$subtype}{$group}{$id}" : null)->setLink(array('l' => X_Env::encode("{$resourceType}/{$subtype}{$group}{$id}")), 'default', false); $items->append($item); } if (count($page->getParsed(X_PageParser_Parser_Preg::factory(self::PATTERN_MOVIESINCATEGORY_NEXTPAGE, X_PageParser_Parser_Preg::PREG_MATCH)))) { // append "next" as last $nextPage = $pageN + 1; $items->append(X_VlcShares_Plugins_Utils::getNextPage("{$resourceType}/{$nextPage}", $nextPage)); } }
public function menuShows(X_Page_ItemList_PItem $items, $type, $filter, $pageN = '1') { if ($type == 'plus') { $page = X_PageParser_Page::getPage(sprintf(self::URL_PROVIDER_PLUS, $filter, $pageN, 'tv'), new X_PageParser_Parser_Preg('/<td width="25%".*?<a href="https?:\\/\\/(www|secure).hulu.com\\/(?P<href>.*?)".*?<img alt="(?P<label>.*?)".*?src="(?P<thumbnail>.*?)".*?<div style="margin-top:0;">(?P<description>.*?)<\\/div>/is', X_PageParser_Parser_Preg::PREG_MATCH_ALL, PREG_SET_ORDER)); } else { // hulu free $page = X_PageParser_Page::getPage(sprintf(self::URL_PROVIDER_FREE, $filter == '#' ? '%23' : strtoupper($filter), $pageN - 1), new X_PageParser_Parser_HuluFree()); } $this->preparePageLoader($page); $parsed = $page->getParsed(); if ($type == 'plus') { $nextResult = $page->getParsed(new X_PageParser_Parser_Preg('/<form.*?current_page="(?P<current>.*?)".*?total_pages="(?P<total>.*?)"/si', X_PageParser_Parser_Preg::PREG_MATCH)); } else { $nextResult = $page->getParsed(new X_PageParser_Parser_Preg('/browse-lazy-load/', X_PageParser_Parser_Preg::PREG_MATCH)); } if ($pageN != '1') { $previousPage = $pageN - 1; $items->append(X_VlcShares_Plugins_Utils::getPreviousPage("{$type}/{$filter}/{$previousPage}", $previousPage, isset($nextResult['total']) ? $nextResult['total'] : '???')); } foreach ($parsed as $match) { $label = $match['label']; $href = $match['href']; $thumbnail = $match['thumbnail']; $description = str_replace(array("\n", "\r"), '', trim($match['description'])); $item = new X_Page_Item_PItem($this->getId() . "-{$href}", $label); $item->setIcon('/images/icons/folder_32.png')->setThumbnail($thumbnail)->setType(X_Page_Item_PItem::TYPE_CONTAINER)->setCustom(__CLASS__ . ':location', "{$type}/{$filter}/{$pageN}/{$href}")->setDescription(APPLICATION_ENV == 'development' ? "{$type}/{$filter}/{$pageN}/{$href}\t{$description}" : $description)->setLink(array('l' => X_Env::encode("{$type}/{$filter}/{$pageN}/{$href}")), 'default', false); $items->append($item); } if ($type == 'plus' && $nextResult && $nextResult['current'] != $nextResult['total'] || $type == 'free' && count($parsed) && count($nextResult)) { $nextPage = $pageN + 1; $items->append(X_VlcShares_Plugins_Utils::getNextPage("{$type}/{$filter}/{$nextPage}", $nextPage, isset($nextResult['total']) ? $nextResult['total'] : '???')); } }
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)); } }