From 5b4ba621ee76d9f40b3455b06916c35303b21007 Mon Sep 17 00:00:00 2001 From: Luc Didry Date: Sat, 14 Jan 2017 09:29:53 +0100 Subject: [PATCH] Add GoComicsBridge --- bridges/GoComicsBridge.php | 51 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 bridges/GoComicsBridge.php diff --git a/bridges/GoComicsBridge.php b/bridges/GoComicsBridge.php new file mode 100644 index 00000000..87c30df0 --- /dev/null +++ b/bridges/GoComicsBridge.php @@ -0,0 +1,51 @@ + array( + 'name' => 'comicname', + 'type' => 'text', + 'required' => true + ) + )); + + public function collectData() { + $html = getSimpleHTMLDOM($this->getURI()) or returnServerError('Could not request GoComics: '.$this->getURI()); + + foreach ($html->find('div.item-comic-container') as $element) { + + $img = $element->find('img', 0); + $link = $element->find('a.item-comic-link', 0); + $comic = $img->src; + $title = $link->title; + $url = $html->find('input.js-copy-link', 0)->value; + $date = substr($title, -10); + if (empty($title)) + $title = 'GoComics '.$this->getInput('comicname').' on '.$date; + $date = strtotime($date); + + $item = array(); + $item['id'] = $url; + $item['uri'] = $url; + $item['title'] = $title; + $item['author'] = preg_replace('/by /', '', $element->find('a.link-blended small', 0)->plaintext); + $item['timestamp'] = $date; + $item['content'] = ''.$title.''; + $this->items[] = $item; + } + } + + public function getURI() { + return self::URI.urlencode($this->getInput('comicname')); + } + + public function getName() { + return $this->getInput('comicname') .' - '.'GoComics'; + } +} +?>