From e7f2bf19f32263f316f58137e00ed55cb7e8f8f4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre=20Mazi=C3=A8re?= Date: Sun, 4 Sep 2016 01:25:05 +0200 Subject: [PATCH] [bridges] Shimmie v2 based imageboards derive from DanbooruBridge MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Pierre Mazière --- bridges/DollbooruBridge.php | 36 +++------------------------------- bridges/MilbooruBridge.php | 32 ++---------------------------- bridges/Rule34pahealBridge.php | 35 +++------------------------------ bridges/Shimmie2Bridge.php | 31 +++++++++++++++++++++++++++++ 4 files changed, 39 insertions(+), 95 deletions(-) create mode 100644 bridges/Shimmie2Bridge.php diff --git a/bridges/DollbooruBridge.php b/bridges/DollbooruBridge.php index 4af5fb3..90da94d 100644 --- a/bridges/DollbooruBridge.php +++ b/bridges/DollbooruBridge.php @@ -1,41 +1,11 @@ array( - 'name'=>'page', - 'type'=>'number' - ), - 't'=>array('name'=>'tags') - )); - - public function collectData(){ - $page=$this->getInput('p'); - $tags = urlencode($this->getInput('t')); - $html = $this->getSimpleHTMLDOM(self::URI."post/list/$tags/$page") - or $this->returnServerError('Could not request Dollbooru.'); - - - foreach($html->find('div[class=shm-image-list] a') as $element) { - $item = array(); - $item['uri'] = self::URI.$element->href; - $item['postid'] = (int)preg_replace("/[^0-9]/",'', $element->getAttribute('data-post-id')); - $item['timestamp'] = time(); - $thumbnailUri = self::URI.$element->find('img', 0)->src; - $item['tags'] = $element->getAttribute('data-tags'); - $item['title'] = 'Dollbooru | '.$item['postid']; - $item['content'] = '
Tags: '.$item['tags']; - $this->items[] = $item; - } - } - - public function getCacheDuration(){ - return 1800; // 30 minutes - } } diff --git a/bridges/MilbooruBridge.php b/bridges/MilbooruBridge.php index 43799df..bc10c3f 100644 --- a/bridges/MilbooruBridge.php +++ b/bridges/MilbooruBridge.php @@ -1,39 +1,11 @@ array( - 'name'=>'page', - 'type'=>'number' - ), - 't'=>array('name'=>'tags') - )); - - public function collectData(){ - $html = $this->getSimpleHTMLDOM( - self::URI.'?q=/post/list/'.urlencode($this->getInput('t')).'/'.$this->getInput('p') - )or $this->returnServerError('Could not request Milbooru.'); - - foreach($html->find('div[class=shm-image-list] span[class=thumb]') as $element) { - $item = array(); - $item['uri'] = self::URI.$element->find('a', 0)->href; - $item['postid'] = (int)preg_replace("/[^0-9]/",'', $element->find('a', 0)->getAttribute('data-post-id')); - $item['timestamp'] = time(); - $thumbnailUri = self::URI.$element->find('img', 0)->src; - $item['tags'] = $element->find('a', 0)->getAttribute('data-tags'); - $item['title'] = 'Milbooru | '.$item['postid']; - $item['content'] = '
Tags: '.$item['tags']; - $this->items[] = $item; - } - } - - public function getCacheDuration(){ - return 1800; // 30 minutes - } } diff --git a/bridges/Rule34pahealBridge.php b/bridges/Rule34pahealBridge.php index 54259a3..abba0b6 100644 --- a/bridges/Rule34pahealBridge.php +++ b/bridges/Rule34pahealBridge.php @@ -1,39 +1,10 @@ array( - 'name'=>'page', - 'type'=>'number' - ), - 't'=>array('name'=>'tags') - )); - - - public function collectData(){ - $html = $this->getSimpleHTMLDOM(self::URI.'post/list/'.$tags.'/'.$page) - or $this->returnServerError('Could not request Rule34paheal.'); - - - foreach($html->find('div[class=shm-image-list] div[class=shm-thumb]') as $element) { - $item = array(); - $item['uri'] = self::URI.$element->find('a', 0)->href; - $item['postid'] = (int)preg_replace("/[^0-9]/",'', $element->find('img', 0)->getAttribute('id')); - $item['timestamp'] = time(); - $thumbnailUri = $element->find('img', 0)->src; - $item['tags'] = $element->getAttribute('data-tags'); - $item['title'] = 'Rule34paheal | '.$item['postid']; - $item['content'] = '
Tags: '.$item['tags']; - $this->items[] = $item; - } - } - - public function getCacheDuration(){ - return 1800; // 30 minutes - } } diff --git a/bridges/Shimmie2Bridge.php b/bridges/Shimmie2Bridge.php new file mode 100644 index 0000000..80a242a --- /dev/null +++ b/bridges/Shimmie2Bridge.php @@ -0,0 +1,31 @@ +getURI().'post/list/' + .$this->getInput('t').'/' + .$this->getInput('p'); + } + + protected function getItemFromElement($element){ + $item = array(); + $item['uri'] = $this->getURI().$element->href; + $item['id'] = (int)preg_replace("/[^0-9]/",'', $element->getAttribute(static::IDATTRIBUTE)); + $item['timestamp'] = time(); + $thumbnailUri = $this->getURI().$element->find('img', 0)->src; + $item['tags'] = $element->getAttribute('data-tags'); + $item['title'] = $this->getName().' | '.$item['id']; + $item['content'] = '
Tags: '.$item['tags']; + return $item; + } + +}