From 41e85bd4a684550d7baa5f50d1435dc495ca6151 Mon Sep 17 00:00:00 2001 From: niawag Date: Thu, 6 Oct 2016 15:43:04 +0200 Subject: [PATCH 1/3] Create ReadComicsBridge.php Hi, I created a Bridge for ReadComics.tv website, I put myself as "maintainer" but I'm not sure if this is the way you're doing it! If there is a need to improve/change things, please tell me! --- bridges/ReadComicsBridge.php | 43 ++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 bridges/ReadComicsBridge.php diff --git a/bridges/ReadComicsBridge.php b/bridges/ReadComicsBridge.php new file mode 100644 index 00000000..c1380d1a --- /dev/null +++ b/bridges/ReadComicsBridge.php @@ -0,0 +1,43 @@ +array( + 'name'=>'keywords, separated by semicolons', + 'exampleValue'=>'first list;second list;...', + 'required'=>true + ), + )); + + public function collectData(){ + + function parseDateTimestamp($element){ + $guessedDate = $element->find('span',0)->plaintext; + $guessedDate = strptime($guessedDate, '%d/%m/%Y'); + $timestamp = mktime(0, 0, 0, $guessedDate['tm_mon'] + 1, $guessedDate['tm_mday'], date('Y')); + + return $timestamp; + } + + $keywordsList = explode(";",$this->getInput('q')); + foreach($keywordsList as $keywords){ + $html = $this->getSimpleHTMLDOM(self::URI.'comic/'.rawurlencode($keywords)) + or $this->returnServerError('Could not request RCO.'); + + foreach($html->find('li') as $element) { + $item = array(); + $item['uri'] = $element->find('a.ch-name',0)->href; + $item['id'] = $item['uri']; + $item['timestamp'] = parseDateTimestamp($element); + $item['title'] = $element->find('a.ch-name',0)->plaintext; + if(isset($item['title'])) + $this->items[] = $item; + } + } + } +} From 952bde0425f3750c6c9921691d0c6f9ce411a2d4 Mon Sep 17 00:00:00 2001 From: niawag Date: Thu, 6 Oct 2016 16:22:39 +0200 Subject: [PATCH 2/3] Update ReadComicsBridge.php --- bridges/ReadComicsBridge.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bridges/ReadComicsBridge.php b/bridges/ReadComicsBridge.php index c1380d1a..0cc8a7a2 100644 --- a/bridges/ReadComicsBridge.php +++ b/bridges/ReadComicsBridge.php @@ -27,7 +27,7 @@ class ReadComicsBridge extends BridgeAbstract{ $keywordsList = explode(";",$this->getInput('q')); foreach($keywordsList as $keywords){ $html = $this->getSimpleHTMLDOM(self::URI.'comic/'.rawurlencode($keywords)) - or $this->returnServerError('Could not request RCO.'); + or $this->returnServerError('Could not request readcomics.tv.'); foreach($html->find('li') as $element) { $item = array(); From f8dafe6b10a6c1124ca7e913e0a5986bf90a61b5 Mon Sep 17 00:00:00 2001 From: niawag Date: Thu, 6 Oct 2016 16:39:18 +0200 Subject: [PATCH 3/3] Update ReadComicsBridge.php --- bridges/ReadComicsBridge.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bridges/ReadComicsBridge.php b/bridges/ReadComicsBridge.php index 0cc8a7a2..59f48d3c 100644 --- a/bridges/ReadComicsBridge.php +++ b/bridges/ReadComicsBridge.php @@ -18,7 +18,7 @@ class ReadComicsBridge extends BridgeAbstract{ function parseDateTimestamp($element){ $guessedDate = $element->find('span',0)->plaintext; - $guessedDate = strptime($guessedDate, '%d/%m/%Y'); + $guessedDate = strptime($guessedDate, '%m/%d/%Y'); $timestamp = mktime(0, 0, 0, $guessedDate['tm_mon'] + 1, $guessedDate['tm_mday'], date('Y')); return $timestamp;