mirror of
https://github.com/RSS-Bridge/rss-bridge.git
synced 2025-06-29 18:21:07 +00:00
[GoComicsBridge] Fix for JSON being removed (#4585)
- Now redirects to first comic from landing page - Switched to meta tags
This commit is contained in:
parent
7aa54602cf
commit
514b3edf0b
@ -31,25 +31,21 @@ class GoComicsBridge extends BridgeAbstract
|
||||
public function collectData()
|
||||
{
|
||||
$link = $this->getURI();
|
||||
$landingpage = getSimpleHTMLDOM($link);
|
||||
|
||||
$link = $landingpage->find('div[data-post-url]', 0)->getAttribute('data-post-url');
|
||||
|
||||
for ($i = 0; $i < $this->getInput('limit'); $i++) {
|
||||
$html = getSimpleHTMLDOM($link);
|
||||
// get json data from the first page
|
||||
$json = $html->find('div[class^="ShowComicViewer_showComicViewer__comic__"] script[type="application/ld+json"]', 0)->innertext;
|
||||
$data = json_decode($json, false);
|
||||
|
||||
$imagelink = $html->find('meta[property="og:image"]', 0)->content;
|
||||
$parts = explode('/', $link);
|
||||
$date = DateTime::createFromFormat('Y/m/d', implode('/', array_slice($parts, -3)));
|
||||
$title = $html->find('meta[property="og:title"]', 0)->content;
|
||||
preg_match('/by (.*?) for/', $title, $authormatches);
|
||||
$author = $authormatches[1] ?? 'GoComics';
|
||||
|
||||
$item = [];
|
||||
|
||||
$author = $data->author->name;
|
||||
$imagelink = $data->contentUrl;
|
||||
$date = $data->datePublished;
|
||||
$title = $data->name . ' - GoComics';
|
||||
|
||||
// get a permlink for this day's comic if there isn't one specified
|
||||
if ($link === $this->getURI()) {
|
||||
$link = $this->getURI() . '/' . DateTime::createFromFormat('F j, Y', $date)->format('Y/m/d');
|
||||
}
|
||||
|
||||
$item['id'] = $imagelink;
|
||||
$item['uri'] = $link;
|
||||
$item['author'] = $author;
|
||||
@ -57,7 +53,7 @@ class GoComicsBridge extends BridgeAbstract
|
||||
if ($this->getInput('date-in-title') === true) {
|
||||
$item['title'] = $title;
|
||||
}
|
||||
$item['timestamp'] = DateTime::createFromFormat('F j, Y', $date)->setTime(0, 0, 0)->getTimestamp();
|
||||
$item['timestamp'] = $date->setTime(0, 0, 0)->getTimestamp();
|
||||
$item['content'] = '<img src="' . $imagelink . '" />';
|
||||
|
||||
$link = rtrim(self::URI, '/') . $html->find('a[class*="ComicNavigation_controls__button_previous__"]', 0)->href;
|
||||
|
Loading…
Reference in New Issue
Block a user