From 468aa28a67fc34bc2cd68433b1947b5a79bdd141 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre=20Mazi=C3=A8re?= Date: Tue, 30 Aug 2016 00:16:21 +0200 Subject: [PATCH] [YandereBridge] code simplification MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Pierre Mazière --- bridges/YandereBridge.php | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/bridges/YandereBridge.php b/bridges/YandereBridge.php index 8bea06a..a26f228 100644 --- a/bridges/YandereBridge.php +++ b/bridges/YandereBridge.php @@ -9,20 +9,19 @@ class YandereBridge extends BridgeAbstract{ public $parameters = array( array( 'p'=>array( 'name'=>'page', - 'type'=>'number' + 'type'=>'number', + 'defaultValue'=>1 ), 't'=>array('name'=>'tags') )); public function collectData(){ - $page = 1; $tags = ''; - if ($this->getInput('p')) { - $page = (int)preg_replace("/[^0-9]/",'', $this->getInput('p')); - } - if ($this->getInput('t')) { - $tags = urlencode($this->getInput('t')); - } - $html = $this->getSimpleHTMLDOM("https://yande.re/post?page=$page&tags=$tags") or $this->returnServerError('Could not request Yandere.'); + $html = $this->getSimpleHTMLDOM( + $this->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); @@ -31,7 +30,7 @@ class YandereBridge extends BridgeAbstract{ foreach($data as $datai) { $json = json_decode($datai, TRUE); $item = array(); - $item['uri'] = 'http://yande.re/post/show/'.$json['id']; + $item['uri'] = $this->uri.'post/show/'.$json['id']; $item['postid'] = $json['id']; $item['timestamp'] = $json['created_at']; $item['imageUri'] = $json['file_url'];