| 1 | <?php declare(strict_types=1); defined('BASEPATH') OR exit('No direct script access allowed'); |
||
| 3 | class EGScans extends Base_Site_Model { |
||
| 4 | public $titleFormat = '/^[A-Za-z0-9\-_\!,]+$/'; |
||
| 5 | public $chapterFormat = '/^Chapter_[0-9]+(?:_[E|e]xtra)?$/'; |
||
| 6 | |||
| 7 | public function getFullTitleURL(string $title_url) : string { |
||
| 8 | return "http://read.egscans.com/{$title_url}/"; |
||
| 9 | } |
||
| 10 | |||
| 11 | public function getChapterData(string $title_url, string $chapter) : array { |
||
| 12 | return [ |
||
| 13 | 'url' => "http://read.egscans.com/{$title_url}/{$chapter}", |
||
| 14 | 'number' => $chapter |
||
| 15 | ]; |
||
| 16 | } |
||
| 17 | |||
| 18 | public function getTitleData(string $title_url, bool $firstGet = FALSE) : ?array { |
||
| 19 | $titleData = []; |
||
| 20 | |||
| 21 | $fullURL = $this->getFullTitleURL($title_url); |
||
| 22 | $content = $this->get_content($fullURL); |
||
| 23 | |||
| 24 | $data = $this->parseTitleDataDOM( |
||
| 25 | $content, |
||
| 26 | $title_url, |
||
| 27 | "//select[@name='manga']/option[@selected='selected']", |
||
| 28 | "//select[@name='chapter']/option[last()]", |
||
| 29 | "//html", //FIXME: EGScans doesn't have a proper title page so we can't grab chapter time. |
||
| 30 | "", |
||
| 31 | "Select a manga title to get started!" |
||
| 32 | ); |
||
| 33 | if($data) { |
||
| 34 | $titleData['title'] = html_entity_decode($data['nodes_title']->textContent); |
||
| 35 | |||
| 36 | $titleData['latest_chapter'] = (string) $data['nodes_chapter']->getAttribute('value'); |
||
| 37 | $titleData['last_updated'] = date("Y-m-d H:i:s", now()); |
||
| 38 | } |
||
| 39 | |||
| 40 | return (!empty($titleData) ? $titleData : NULL); |
||
| 41 | } |
||
| 42 | } |
||
| 43 |