|
@@ 459-519 (lines=61) @@
|
| 456 |
|
} |
| 457 |
|
} |
| 458 |
|
|
| 459 |
|
class MangaPanda extends Site_Model { |
| 460 |
|
public function getFullTitleURL(string $title_url) : string { |
| 461 |
|
return "http://www.mangapanda.com/{$title_url}"; |
| 462 |
|
} |
| 463 |
|
|
| 464 |
|
public function getChapterData(string $title_url, string $chapter) : array { |
| 465 |
|
return [ |
| 466 |
|
'url' => "http://www.mangapanda.com/{$title_url}/{$chapter}/", |
| 467 |
|
'number' => 'c'.$chapter |
| 468 |
|
]; |
| 469 |
|
} |
| 470 |
|
|
| 471 |
|
public function isValidTitleURL(string $title_url) : bool { |
| 472 |
|
$success = (bool) preg_match('/^[a-z0-9-]+$/', $title_url); |
| 473 |
|
if(!$success) log_message('error', "Invalid Title URL (MangaPanda): {$title_url}"); |
| 474 |
|
return $success; |
| 475 |
|
} |
| 476 |
|
public function isValidChapter(string $chapter) : bool { |
| 477 |
|
$success = (bool) preg_match('/^[0-9]+$/', $chapter); |
| 478 |
|
if(!$success) log_message('error', 'Invalid Chapter (MangaPanda): '.$chapter); |
| 479 |
|
return $success; |
| 480 |
|
} |
| 481 |
|
|
| 482 |
|
public function getTitleData(string $title_url) { |
| 483 |
|
$titleData = []; |
| 484 |
|
|
| 485 |
|
$fullURL = "http://www.mangapanda.com/{$title_url}"; |
| 486 |
|
|
| 487 |
|
$content = $this->get_content($fullURL); |
| 488 |
|
$data = $content['body']; |
| 489 |
|
if($data !== '<h1>404 Not Found</h1>') { |
| 490 |
|
//$data = preg_replace('/^[\S\s]*(<body id="body">[\S\s]*<\/body>)[\S\s]*$/', '$1', $data); |
| 491 |
|
|
| 492 |
|
$dom = new DOMDocument(); |
| 493 |
|
libxml_use_internal_errors(true); |
| 494 |
|
$dom->loadHTML($data); |
| 495 |
|
libxml_use_internal_errors(false); |
| 496 |
|
|
| 497 |
|
$xpath = new DOMXPath($dom); |
| 498 |
|
|
| 499 |
|
$nodes_title = $xpath->query("//h2[@class='aname']"); |
| 500 |
|
$nodes_row = $xpath->query("(//table[@id='listing']/tr)[last()]"); |
| 501 |
|
if($nodes_title->length === 1 && $nodes_row->length === 1) { |
| 502 |
|
//This seems to be be the only viable way to grab the title... |
| 503 |
|
$titleData['title'] = $nodes_title->item(0)->nodeValue; |
| 504 |
|
|
| 505 |
|
$firstRow = $nodes_row->item(0); |
| 506 |
|
$nodes_latest = $xpath->query("td[2]", $firstRow); |
| 507 |
|
$nodes_chapter = $xpath->query("td[1]/a", $firstRow); |
| 508 |
|
|
| 509 |
|
$titleData['latest_chapter'] = preg_replace('/^.*\/([0-9]+)$/', '$1', (string) $nodes_chapter->item(0)->getAttribute('href')); |
| 510 |
|
$titleData['last_updated'] = date("Y-m-d H:i:s", strtotime((string) $nodes_latest->item(0)->nodeValue)); |
| 511 |
|
} |
| 512 |
|
} else { |
| 513 |
|
log_message('error', "Series missing? (MangaPanda): {$title_url}"); |
| 514 |
|
return NULL; |
| 515 |
|
} |
| 516 |
|
|
| 517 |
|
return (!empty($titleData) ? $titleData : NULL); |
| 518 |
|
} |
| 519 |
|
} |
| 520 |
|
|
| 521 |
|
class MangaStream extends Site_Model { |
| 522 |
|
public function getFullTitleURL(string $title_url) : string { |
|
@@ 521-580 (lines=60) @@
|
| 518 |
|
} |
| 519 |
|
} |
| 520 |
|
|
| 521 |
|
class MangaStream extends Site_Model { |
| 522 |
|
public function getFullTitleURL(string $title_url) : string { |
| 523 |
|
return "https://mangastream.com/manga/{$title_url}/"; |
| 524 |
|
} |
| 525 |
|
|
| 526 |
|
public function isValidTitleURL(string $title_url) : bool { |
| 527 |
|
$success = (bool) preg_match('/^[a-z0-9_]+$/', $title_url); |
| 528 |
|
if(!$success) log_message('error', "Invalid Title URL (MangaStream): {$title_url}"); |
| 529 |
|
return $success; |
| 530 |
|
} |
| 531 |
|
public function isValidChapter(string $chapter) : bool { |
| 532 |
|
$success = (bool) preg_match('/^(.*?)\/[0-9]+$/', $chapter); |
| 533 |
|
if(!$success) log_message('error', 'Invalid Chapter (MangaStream): '.$chapter); |
| 534 |
|
return $success; |
| 535 |
|
} |
| 536 |
|
|
| 537 |
|
public function getChapterData(string $title_url, string $chapter) : array { |
| 538 |
|
return [ |
| 539 |
|
'url' => "https://mangastream.com/r/{$title_url}/{$chapter}", |
| 540 |
|
'number' => 'c'.explode('/', $chapter)[0] |
| 541 |
|
]; |
| 542 |
|
} |
| 543 |
|
|
| 544 |
|
public function getTitleData(string $title_url) { |
| 545 |
|
$titleData = []; |
| 546 |
|
|
| 547 |
|
$fullURL = $this->getFullTitleURL($title_url); |
| 548 |
|
|
| 549 |
|
$content = $this->get_content($fullURL); |
| 550 |
|
$data = $content['body']; |
| 551 |
|
if($data !== 'Can\'t find the manga series.') { //FIXME: We should check for he proper error here. |
| 552 |
|
//$data = preg_replace('/^[\S\s]*(<body id="body">[\S\s]*<\/body>)[\S\s]*$/', '$1', $data); |
| 553 |
|
|
| 554 |
|
$dom = new DOMDocument(); |
| 555 |
|
libxml_use_internal_errors(true); |
| 556 |
|
$dom->loadHTML($data); |
| 557 |
|
libxml_use_internal_errors(false); |
| 558 |
|
|
| 559 |
|
$xpath = new DOMXPath($dom); |
| 560 |
|
|
| 561 |
|
$nodes_title = $xpath->query("//div[contains(@class, 'content')]/div[1]/h1"); |
| 562 |
|
$nodes_row = $xpath->query("//div[contains(@class, 'content')]/div[1]/table/tr[2]"); //Missing tbody here.. |
| 563 |
|
if($nodes_title->length === 1 && $nodes_row->length === 1) { |
| 564 |
|
$titleData['title'] = $nodes_title->item(0)->nodeValue; |
| 565 |
|
|
| 566 |
|
$firstRow = $nodes_row->item(0); |
| 567 |
|
$nodes_latest = $xpath->query("td[2]", $firstRow); |
| 568 |
|
$nodes_chapter = $xpath->query("td[1]/a", $firstRow); |
| 569 |
|
|
| 570 |
|
$titleData['latest_chapter'] = preg_replace('/^.*\/(.*?\/[0-9]+)\/[0-9]+$/', '$1', (string) $nodes_chapter->item(0)->getAttribute('href')); |
| 571 |
|
$titleData['last_updated'] = date("Y-m-d H:i:s", strtotime((string) $nodes_latest->item(0)->nodeValue)); |
| 572 |
|
} |
| 573 |
|
} else { |
| 574 |
|
log_message('error', "Series missing? (MangaStream): {$title_url}"); |
| 575 |
|
return NULL; |
| 576 |
|
} |
| 577 |
|
|
| 578 |
|
return (!empty($titleData) ? $titleData : NULL); |
| 579 |
|
} |
| 580 |
|
} |
| 581 |
|
|
| 582 |
|
class WebToons extends Site_Model { |
| 583 |
|
/* Webtoons.com has a very weird and pointless URL format. |