2019-11-09 20:50:08 +03:00
|
|
|
<?php
|
|
|
|
|
|
|
|
class ComicsKingdomBridge extends BridgeAbstract
|
2022-07-01 16:10:30 +03:00
|
|
|
{
|
2019-11-09 20:50:08 +03:00
|
|
|
const MAINTAINER = 'stjohnjohnson';
|
|
|
|
const NAME = 'Comics Kingdom Unofficial RSS';
|
2022-02-13 10:27:41 +03:00
|
|
|
const URI = 'https://comicskingdom.com/';
|
2019-11-09 20:50:08 +03:00
|
|
|
const CACHE_TIMEOUT = 21600; // 6h
|
|
|
|
const DESCRIPTION = 'Comics Kingdom Unofficial RSS';
|
|
|
|
const PARAMETERS = [ [
|
|
|
|
'comicname' => [
|
|
|
|
'name' => 'comicname',
|
|
|
|
'type' => 'text',
|
2022-02-13 10:27:41 +03:00
|
|
|
'exampleValue' => 'mutts',
|
|
|
|
'title' => 'The name of the comic in the URL after https://comicskingdom.com/',
|
2019-11-09 20:50:08 +03:00
|
|
|
'required' => true
|
2022-07-01 16:10:30 +03:00
|
|
|
]
|
2019-11-09 20:50:08 +03:00
|
|
|
]];
|
|
|
|
|
|
|
|
public function collectData()
|
|
|
|
{
|
2022-01-02 12:36:09 +03:00
|
|
|
$html = getSimpleHTMLDOM($this->getURI(), [], [], true, false);
|
2019-11-09 20:50:08 +03:00
|
|
|
|
|
|
|
// Get author from first page
|
2022-01-02 12:36:09 +03:00
|
|
|
$author = $html->find('div.author p', 0);
|
2022-07-01 16:10:30 +03:00
|
|
|
;
|
2019-11-09 20:50:08 +03:00
|
|
|
|
|
|
|
// Get current date/link
|
2022-03-05 21:47:04 +03:00
|
|
|
$link = $html->find('meta[property=og:url]', -1)->content;
|
2022-02-13 10:27:41 +03:00
|
|
|
for ($i = 0; $i < 3; $i++) {
|
2019-11-09 20:50:08 +03:00
|
|
|
$item = [];
|
|
|
|
|
2022-01-02 12:36:09 +03:00
|
|
|
$page = getSimpleHTMLDOM($link);
|
2019-11-09 20:50:08 +03:00
|
|
|
|
|
|
|
$imagelink = $page->find('meta[property=og:image]', 0)->content;
|
|
|
|
|
|
|
|
$date = explode('/', $link);
|
|
|
|
|
|
|
|
$item['id'] = $imagelink;
|
|
|
|
$item['uri'] = $link;
|
|
|
|
$item['author'] = $author;
|
|
|
|
$item['title'] = 'Comics Kingdom ' . $this->getInput('comicname');
|
|
|
|
$item['timestamp'] = DateTime::createFromFormat('Y-m-d', $date[count($date) - 1])->getTimestamp();
|
|
|
|
$item['content'] = '<img src="' . $imagelink . '" />';
|
|
|
|
|
|
|
|
$this->items[] = $item;
|
2022-02-13 10:27:41 +03:00
|
|
|
$link = $page->find('div.comic-viewer-inline a', 0)->href;
|
|
|
|
if (empty($link)) {
|
|
|
|
break; // allow bridge to continue if there's less than 3 comics
|
2019-11-09 20:50:08 +03:00
|
|
|
}
|
2022-07-01 16:10:30 +03:00
|
|
|
}
|
2019-11-09 20:50:08 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
public function getURI()
|
|
|
|
{
|
|
|
|
if (!is_null($this->getInput('comicname'))) {
|
|
|
|
return self::URI . urlencode($this->getInput('comicname'));
|
|
|
|
}
|
|
|
|
|
|
|
|
return parent::getURI();
|
|
|
|
}
|
|
|
|
|
|
|
|
public function getName()
|
|
|
|
{
|
|
|
|
if (!is_null($this->getInput('comicname'))) {
|
|
|
|
return $this->getInput('comicname') . ' - Comics Kingdom';
|
|
|
|
}
|
|
|
|
|
|
|
|
return parent::getName();
|
|
|
|
}
|
|
|
|
}
|