2017-01-14 11:29:53 +03:00
|
|
|
<?php
|
2022-07-01 16:10:30 +03:00
|
|
|
|
2017-01-14 11:29:53 +03:00
|
|
|
class GoComicsBridge extends BridgeAbstract
|
|
|
|
{
|
2017-02-11 18:16:56 +03:00
|
|
|
const MAINTAINER = 'sky';
|
|
|
|
const NAME = 'GoComics Unofficial RSS';
|
2018-04-14 20:15:44 +03:00
|
|
|
const URI = 'https://www.gocomics.com/';
|
2017-02-11 18:16:56 +03:00
|
|
|
const CACHE_TIMEOUT = 21600; // 6h
|
|
|
|
const DESCRIPTION = 'The Unofficial GoComics RSS';
|
|
|
|
const PARAMETERS = [ [
|
|
|
|
'comicname' => [
|
|
|
|
'name' => 'comicname',
|
|
|
|
'type' => 'text',
|
2022-03-24 13:59:34 +03:00
|
|
|
'exampleValue' => 'heartofthecity',
|
2017-02-11 18:16:56 +03:00
|
|
|
'required' => true
|
2022-07-01 16:10:30 +03:00
|
|
|
]
|
2017-02-11 18:16:56 +03:00
|
|
|
]];
|
2022-07-01 16:10:30 +03:00
|
|
|
|
2017-02-11 18:16:56 +03:00
|
|
|
public function collectData()
|
|
|
|
{
|
2022-01-02 12:36:09 +03:00
|
|
|
$html = getSimpleHTMLDOM($this->getURI());
|
2022-07-01 16:10:30 +03:00
|
|
|
|
2018-04-14 20:15:44 +03:00
|
|
|
//Get info from first page
|
2018-06-30 00:55:33 +03:00
|
|
|
$author = preg_replace('/By /', '', $html->find('.media-subheading', 0)->plaintext);
|
2022-07-01 16:10:30 +03:00
|
|
|
|
2018-06-30 00:55:33 +03:00
|
|
|
$link = self::URI . $html->find('.gc-deck--cta-0', 0)->find('a', 0)->href;
|
2018-04-14 20:15:44 +03:00
|
|
|
for ($i = 0; $i < 5; $i++) {
|
2017-02-11 18:16:56 +03:00
|
|
|
$item = [];
|
2022-07-01 16:10:30 +03:00
|
|
|
|
2022-01-02 12:36:09 +03:00
|
|
|
$page = getSimpleHTMLDOM($link);
|
2020-02-26 23:56:52 +03:00
|
|
|
$imagelink = $page->find('.comic.container', 0)->getAttribute('data-image');
|
2018-06-30 00:55:33 +03:00
|
|
|
$date = explode('/', $link);
|
2022-07-01 16:10:30 +03:00
|
|
|
|
2018-04-14 20:15:44 +03:00
|
|
|
$item['id'] = $imagelink;
|
|
|
|
$item['uri'] = $link;
|
|
|
|
$item['author'] = $author;
|
|
|
|
$item['title'] = 'GoComics ' . $this->getInput('comicname');
|
2018-06-30 00:55:33 +03:00
|
|
|
$item['timestamp'] = DateTime::createFromFormat('Ymd', $date[5] . $date[6] . $date[7])->getTimestamp();
|
2018-04-14 20:15:44 +03:00
|
|
|
$item['content'] = '<img src="' . $imagelink . '" />';
|
2022-07-01 16:10:30 +03:00
|
|
|
|
2018-06-30 00:55:33 +03:00
|
|
|
$link = self::URI . $page->find('.js-previous-comic', 0)->href;
|
2017-02-11 18:16:56 +03:00
|
|
|
$this->items[] = $item;
|
2022-07-01 16:10:30 +03:00
|
|
|
}
|
2017-02-11 18:16:56 +03:00
|
|
|
}
|
2022-07-01 16:10:30 +03:00
|
|
|
|
2017-02-11 18:16:56 +03:00
|
|
|
public function getURI()
|
|
|
|
{
|
2017-07-29 20:28:00 +03:00
|
|
|
if (!is_null($this->getInput('comicname'))) {
|
2017-02-15 00:36:33 +03:00
|
|
|
return self::URI . urlencode($this->getInput('comicname'));
|
|
|
|
}
|
2022-07-01 16:10:30 +03:00
|
|
|
|
2017-02-15 00:36:33 +03:00
|
|
|
return parent::getURI();
|
2017-02-11 18:16:56 +03:00
|
|
|
}
|
2022-07-01 16:10:30 +03:00
|
|
|
|
2017-02-11 18:16:56 +03:00
|
|
|
public function getName()
|
|
|
|
{
|
2017-07-29 20:28:00 +03:00
|
|
|
if (!is_null($this->getInput('comicname'))) {
|
2017-02-15 00:20:55 +03:00
|
|
|
return $this->getInput('comicname') . ' - GoComics';
|
|
|
|
}
|
2022-07-01 16:10:30 +03:00
|
|
|
|
2017-02-15 00:20:55 +03:00
|
|
|
return parent::getName();
|
2017-02-11 18:16:56 +03:00
|
|
|
}
|
2017-01-14 11:29:53 +03:00
|
|
|
}
|