From fd6bcbbafe70c2e753cede65d2116d543ad7f6ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre=20Mazi=C3=A8re?= Date: Sun, 4 Sep 2016 01:23:34 +0200 Subject: [PATCH] [Bridges] Moebooru and MyImouto based imageboards derive from MoebooruBridge MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Pierre Mazière --- bridges/KonachanBridge.php | 41 +++------------------------------ bridges/LolibooruBridge.php | 43 ++++------------------------------- bridges/SakugabooruBridge.php | 41 +++------------------------------ bridges/YandereBridge.php | 41 +++------------------------------ 4 files changed, 13 insertions(+), 153 deletions(-) diff --git a/bridges/KonachanBridge.php b/bridges/KonachanBridge.php index 0a213fec..6d170312 100644 --- a/bridges/KonachanBridge.php +++ b/bridges/KonachanBridge.php @@ -1,46 +1,11 @@ array( - 'name'=>'page', - 'defaultValue'=>1, - 'type'=>'number' - ), - 't'=>array('name'=>'tags') - )); - - public function collectData(){ - $html = $this->getSimpleHTMLDOM( - self::URI.'/post?' - .'&page='.$this->getInput('p') - .'&tags='.urlencode($this->getInput('t')) - ) or $this->returnServerError('Could not request Konachan.'); - - $input_json = explode('Post.register(', $html); - foreach($input_json as $element) - $data[] = preg_replace('/}\)(.*)/', '}', $element); - unset($data[0]); - - foreach($data as $datai) { - $json = json_decode($datai, TRUE); - $item = array(); - $item['uri'] = self::URI.'/post/show/'.$json['id']; - $item['postid'] = $json['id']; - $item['timestamp'] = $json['created_at']; - $item['imageUri'] = $json['file_url']; - $item['title'] = 'Konachan | '.$json['id']; - $item['content'] = '
Tags: '.$json['tags']; - $this->items[] = $item; - } - } - - public function getCacheDuration(){ - return 1800; // 30 minutes - } } diff --git a/bridges/LolibooruBridge.php b/bridges/LolibooruBridge.php index d2f90668..781bc238 100644 --- a/bridges/LolibooruBridge.php +++ b/bridges/LolibooruBridge.php @@ -1,46 +1,11 @@ array( - 'name'=>'page', - 'defaultValue'=>1, - 'type'=>'number' - ), - 't'=>array('name'=>'tags') - )); - - public function collectData(){ - $html = $this->getSimpleHTMLDOM( - self::URI.'post?' - .'&page='.$this->getInput('p') - .'&tags='.urlencode($this->getInput('t')) - ) or $this->returnServerError('Could not request Lolibooru.'); - - $input_json = explode('Post.register(', $html); - foreach($input_json as $element) - $data[] = preg_replace('/}\)(.*)/', '}', $element); - unset($data[0]); - - foreach($data as $datai) { - $json = json_decode($datai, TRUE); - $item = array(); - $item['uri'] = self::URI.'post/show/'.$json['id']; - $item['postid'] = $json['id']; - $item['timestamp'] = $json['created_at']; - $item['imageUri'] = $json['file_url']; - $item['title'] = 'Lolibooru | '.$json['id']; - $item['content'] = '
Tags: '.$json['tags']; - $this->items[] = $item; - } - } - - public function getCacheDuration(){ - return 1800; // 30 minutes - } } diff --git a/bridges/SakugabooruBridge.php b/bridges/SakugabooruBridge.php index 86ffa5d6..11c56036 100644 --- a/bridges/SakugabooruBridge.php +++ b/bridges/SakugabooruBridge.php @@ -1,46 +1,11 @@ array( - 'name'=>'page', - 'defaultValue'=>1, - 'type'=>'number' - ), - 't'=>array('name'=>'tags') - )); - - public function collectData(){ - $html = $this->getSimpleHTMLDOM( - self::URI.'post?' - .'&page='.$this->getInput('p') - .'&tags='.urlencode($this->getInput('t')) - ) or $this->returnServerError('Could not request Sakugabooru.'); - - $input_json = explode('Post.register(', $html); - foreach($input_json as $element) - $data[] = preg_replace('/}\)(.*)/', '}', $element); - unset($data[0]); - - foreach($data as $datai) { - $json = json_decode($datai, TRUE); - $item = array(); - $item['uri'] = self::URI.'/post/show/'.$json['id']; - $item['postid'] = $json['id']; - $item['timestamp'] = $json['created_at']; - $item['imageUri'] = $json['file_url']; - $item['title'] = 'Sakugabooru | '.$json['id']; - $item['content'] = '
Tags: '.$json['tags']; - $this->items[] = $item; - } - } - - public function getCacheDuration(){ - return 1800; // 30 minutes - } } diff --git a/bridges/YandereBridge.php b/bridges/YandereBridge.php index 44a6ca12..61b59620 100644 --- a/bridges/YandereBridge.php +++ b/bridges/YandereBridge.php @@ -1,46 +1,11 @@ array( - 'name'=>'page', - 'type'=>'number', - 'defaultValue'=>1 - ), - 't'=>array('name'=>'tags') - )); - - public function collectData(){ - $html = $this->getSimpleHTMLDOM( - self::URI.'post?' - .'&page='.$this->getInput('p') - .'&tags='.urlencode($this->getInput('t')) - ) or $this->returnServerError('Could not request Yander.'); - - $input_json = explode('Post.register(', $html); - foreach($input_json as $element) - $data[] = preg_replace('/}\)(.*)/', '}', $element); - unset($data[0]); - - foreach($data as $datai) { - $json = json_decode($datai, TRUE); - $item = array(); - $item['uri'] = self::URI.'post/show/'.$json['id']; - $item['postid'] = $json['id']; - $item['timestamp'] = $json['created_at']; - $item['imageUri'] = $json['file_url']; - $item['title'] = 'Yandere | '.$json['id']; - $item['content'] = '
Tags: '.$json['tags']; - $this->items[] = $item; - } - } - - public function getCacheDuration(){ - return 1800; // 30 minutes - } }