|
1
|
|
|
<?php declare(strict_types=1); defined('BASEPATH') OR exit('No direct script access allowed'); |
|
2
|
|
|
|
|
3
|
|
|
class FallenAngelsScans extends Base_Site_Model { |
|
4
|
|
|
public $titleFormat = '/^[a-zA-Z0-9_-]+$/'; |
|
5
|
|
|
public $chapterFormat = '/^[0-9\.]+$/'; |
|
6
|
|
|
|
|
7
|
|
|
public function getFullTitleURL(string $title_url) : string { |
|
8
|
|
|
return "https://manga.fascans.com/manga/{$title_url}"; |
|
9
|
|
|
} |
|
10
|
|
|
|
|
11
|
|
|
public function getChapterData(string $title_url, string $chapter) : array { |
|
12
|
|
|
$chapter_parts = explode('/', $chapter); |
|
|
|
|
|
|
13
|
|
|
return [ |
|
14
|
|
|
'url' => $this->getFullTitleURL($title_url).'/'.$chapter, |
|
15
|
|
|
'number' => "c{$chapter}" |
|
16
|
|
|
]; |
|
17
|
|
|
} |
|
18
|
|
|
|
|
19
|
|
|
public function getTitleData(string $title_url, bool $firstGet = FALSE) : ?array { |
|
20
|
|
|
$titleData = []; |
|
21
|
|
|
|
|
22
|
|
|
$fullURL = $this->getFullTitleURL($title_url); |
|
23
|
|
|
|
|
24
|
|
|
$content = $this->get_content($fullURL); |
|
25
|
|
|
|
|
26
|
|
|
$data = $this->parseTitleDataDOM( |
|
27
|
|
|
$content, |
|
|
|
|
|
|
28
|
|
|
$title_url, |
|
29
|
|
|
"//h2[@class='widget-title']", |
|
30
|
|
|
"//ul[contains(@class, 'chapters')]/li[1]/h5/a[1]", |
|
31
|
|
|
"div[@class='date-chapter-title-rtl']", |
|
32
|
|
|
"", |
|
33
|
|
|
"Whoops, looks like something went wrong." |
|
34
|
|
|
); |
|
35
|
|
|
if($data) { |
|
36
|
|
|
$titleData['title'] = trim($data['nodes_title']->textContent); |
|
37
|
|
|
|
|
38
|
|
|
$titleData['latest_chapter'] = preg_replace('/^.*\/([0-9\.]+)$/', '$1', (string) $data['nodes_chapter']->getAttribute('href')); |
|
39
|
|
|
|
|
40
|
|
|
$dateString = $data['nodes_latest']->nodeValue; |
|
41
|
|
|
$titleData['last_updated'] = date("Y-m-d H:i:s", strtotime(preg_replace('/ (-|\[A\]).*$/', '', $dateString))); |
|
42
|
|
|
} |
|
43
|
|
|
|
|
44
|
|
|
return (!empty($titleData) ? $titleData : NULL); |
|
45
|
|
|
} |
|
46
|
|
|
} |
|
47
|
|
|
|
This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.
Both the
$myVarassignment in line 1 and the$higherassignment in line 2 are dead. The first because$myVaris never used and the second because$higheris always overwritten for every possible time line.