/** * Gets chapter info * * @param string $listHtml * * @return array|bool */ private function _getChapterInfo($listHtml = '') { try { $chapterInfo = array('mangaInfo' => $this->_mangaInfo); $xml = @simplexml_load_string($listHtml); if ($xml && $xml->count() >= 1) { $children = $xml->children(); $info = $children[0]; $a = $info->a; if ($a) { $url = (string) $a->attributes()['href']; $chapterInfo['url'] = $url; $slug = $this->_mangaInfo->getSlug(); $parts = explode($slug, $url); if (count($parts) > 1) { $chapter = trim($parts[1], '/'); $chapterInfo['number'] = $chapter; $title = trim((string) $info); if ($title == '') { $title = $this->_mangaInfo->getName() . ' ' . $chapter; } $chapterInfo['title'] = $title; } } } else { consoleLineError('Unable to parse chapter info!'); exit; } return $chapterInfo; } catch (Exception $ex) { consoleLineError($ex->getMessage()); exit; } }