mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2025-04-04 16:49:35 +00:00
[GoComics] Update to new website structure.
Added `detectParameters()` method.
This commit is contained in:
parent
a19b63e840
commit
161b3b8ed0
@ -18,27 +18,29 @@ class GoComicsBridge extends BridgeAbstract
|
||||
|
||||
public function collectData()
|
||||
{
|
||||
$html = getSimpleHTMLDOM($this->getURI());
|
||||
|
||||
//Get info from first page
|
||||
$author = preg_replace('/By /', '', $html->find('.media-subheading', 0)->plaintext);
|
||||
|
||||
$link = self::URI . $html->find('.gc-deck--cta-0', 0)->find('a', 0)->href;
|
||||
for ($i = 0; $i < 5; $i++) {
|
||||
if (isset($dateObj)) {
|
||||
$dateObj->modify('-1 day');
|
||||
$publishedUri = $dateObj->format('/Y/m/d');
|
||||
} else {
|
||||
$publishedUri = '';
|
||||
}
|
||||
|
||||
$html = getSimpleHTMLDOM($this->getURI() . $publishedUri);
|
||||
$page = $html->find('div[class^="ComicViewer_comicViewer__comic__"] script[type="application/ld+json"]', 0);
|
||||
$json = Json::decode($page->innertext);
|
||||
|
||||
$dateObj = DateTime::createFromFormat('F j, Y', $json['datePublished']);
|
||||
|
||||
$item = [];
|
||||
$item['id'] = $json['contentUrl'];
|
||||
$item['uri'] = $this->getURI() . $dateObj->format('/Y/m/d');
|
||||
$item['author'] = $json['author']['name'];
|
||||
$item['title'] = 'GoComics ' . $json['name'];
|
||||
$item['timestamp'] = $dateObj->getTimestamp();
|
||||
$item['enclosures'][] = $json['contentUrl'];
|
||||
$item['content'] = '<img src="' . $json['contentUrl'] . '" alt="">';
|
||||
|
||||
$page = getSimpleHTMLDOM($link);
|
||||
$imagelink = $page->find('.comic.container', 0)->getAttribute('data-image');
|
||||
$date = explode('/', $link);
|
||||
|
||||
$item['id'] = $imagelink;
|
||||
$item['uri'] = $link;
|
||||
$item['author'] = $author;
|
||||
$item['title'] = 'GoComics ' . $this->getInput('comicname');
|
||||
$item['timestamp'] = DateTime::createFromFormat('Ymd', $date[5] . $date[6] . $date[7])->getTimestamp();
|
||||
$item['content'] = '<img src="' . $imagelink . '" />';
|
||||
|
||||
$link = self::URI . $page->find('.js-previous-comic', 0)->href;
|
||||
$this->items[] = $item;
|
||||
}
|
||||
}
|
||||
@ -60,4 +62,11 @@ class GoComicsBridge extends BridgeAbstract
|
||||
|
||||
return parent::getName();
|
||||
}
|
||||
|
||||
public function detectParameters($url)
|
||||
{
|
||||
if (preg_match('#^' . self::URI . '([-a-z0-9]+)$#i', $url, $matches)) {
|
||||
return ['comicname' => $matches[1]];
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user