diff --git a/bridges/GoComicsBridge.php b/bridges/GoComicsBridge.php
index 586e2a0d..e9014ae1 100644
--- a/bridges/GoComicsBridge.php
+++ b/bridges/GoComicsBridge.php
@@ -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'] = '
';
- $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'] = '
';
-
- $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]];
+ }
+ }
}