function getChapters($url = '') { $chapters_url = $this->_mangaInfo->getUrl(); if ($chapters_url == '') { return false; } $content = Url::curlFetch($chapters_url); if (!$content) { return false; } $slug = $this->_mangaInfo->getSlug(); preg_match_all('%<a.*?href="(/' . $slug . '/[^"]+)".*?>(.*?)</a>%sim', $content, $result, PREG_PATTERN_ORDER); $urls = $result[1]; $titles = $result[2]; $chapters = array(); $objChapterTitles = ChapterTitles::getInstance(); for ($i = 0; $i < count($urls); $i += 1) { $url = $urls[$i]; if (preg_match('%^/' . $slug . '/(.*?)$%sim', $url, $regs)) { $chapter_id = $regs[1]; $existingTitle = $objChapterTitles->getChapterTitle($chapter_id); $title = $titles[$i]; if ($existingTitle != '') { $title = $existingTitle; } $c = new ChapterInfo(['number' => $chapter_id, 'url' => 'http://www.mangapanda.com' . $url, 'title' => $title, 'mangaInfo' => $this->_mangaInfo]); $chapters[$chapter_id] = $c; } } ksort($chapters, SORT_NUMERIC); return $chapters; }
function getChapters($url = '') { $chapters_url = $this->_mangaInfo->getUrl(); if ($chapters_url == '') { return false; } $content = Url::curlFetch($chapters_url); if (!$content) { return false; } $chapterListFragments = $this->_getLists($content); if (!$chapterListFragments) { consoleLineError('Unable to fetch chapters info from: ' . $url); exit; } $chapters = array(); foreach ($chapterListFragments as $cf) { $chapterInfo = $this->_getChapterInfo($cf); if (!$chapterInfo) { consoleLineError('Unable to fetch chapters info from: ' . $url); exit; } $chapters[$chapterInfo['number']] = new ChapterInfo($chapterInfo); } return $chapters; }