|
1
|
|
|
<?php declare(strict_types=1); defined('BASEPATH') OR exit('No direct script access allowed'); |
|
2
|
|
|
|
|
3
|
|
|
class MangaHere extends Base_Site_Model { |
|
4
|
|
|
public $titleFormat = '/^[a-z0-9_]+$/'; |
|
5
|
|
|
public $chapterFormat = '/^(?:v[0-9]+\/)?c[0-9]+(?:\.[0-9]+)?$/'; |
|
6
|
|
|
|
|
7
|
|
|
public function getFullTitleURL(string $title_url) : string { |
|
8
|
|
|
return "http://www.mangahere.cc/manga/{$title_url}/"; |
|
9
|
|
|
} |
|
10
|
|
|
|
|
11
|
|
|
public function getChapterData(string $title, string $chapter) : array { |
|
12
|
|
|
return [ |
|
13
|
|
|
'url' => "http://www.mangahere.cc/manga/{$title}/{$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
|
|
|
"//meta[@property='og:title']/@content", |
|
28
|
|
|
"//body/section/article/div/div[@class='manga_detail']/div[@class='detail_list']/ul[1]/li[1]", |
|
29
|
|
|
"span[@class='right']", |
|
30
|
|
|
"span[@class='left']/a", |
|
31
|
|
|
"<div class=\"error_text\">Sorry, the page you have requested can’t be found." |
|
32
|
|
|
); |
|
33
|
|
|
if($data) { |
|
34
|
|
|
$titleData['title'] = $data['nodes_title']->textContent; |
|
35
|
|
|
|
|
36
|
|
|
$link = preg_replace('/^(.*\/)(?:[0-9]+\.html)?$/', '$1', (string) $data['nodes_chapter']->getAttribute('href')); |
|
37
|
|
|
$chapterURLSegments = explode('/', $link); |
|
38
|
|
|
$titleData['latest_chapter'] = $chapterURLSegments[5] . (isset($chapterURLSegments[6]) && !empty($chapterURLSegments[6]) ? "/{$chapterURLSegments[6]}" : ""); |
|
39
|
|
|
$titleData['last_updated'] = date("Y-m-d H:i:s", strtotime((string) $data['nodes_latest']->nodeValue)); |
|
40
|
|
|
} |
|
41
|
|
|
|
|
42
|
|
|
return (!empty($titleData) ? $titleData : NULL); |
|
43
|
|
|
} |
|
44
|
|
|
} |
|
45
|
|
|
|