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