From 3fed12af1db4364c646c80ca85697a7a57e3a329 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Pierre=20Mazi=C3=A8re?= Date: Sun, 28 Aug 2016 01:54:17 +0200 Subject: [PATCH] [BandcampBridge] fix parameter 'tag' required status and fix the rest MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Pierre Mazière --- bridges/BandcampBridge.php | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/bridges/BandcampBridge.php b/bridges/BandcampBridge.php index 5434cb5..4e11091 100644 --- a/bridges/BandcampBridge.php +++ b/bridges/BandcampBridge.php @@ -8,18 +8,14 @@ class BandcampBridge extends BridgeAbstract{ public $parameters = array( array( 'tag'=>array( 'name'=>'tag', - 'type'=>'text' + 'type'=>'text', + 'required'=>true ) )); public function collectData(){ - $html = ''; - if (isset($this->getInput('tag'))) { - $html = $this->getSimpleHTMLDOM('http://bandcamp.com/tag/'.urlencode($this->getInput('tag')).'?sort_field=date') or $this->returnServerError('No results for this query.'); - } - else { - $this->returnClientError('You must specify tag (/tag/...)'); - } + $html = $this->getSimpleHTMLDOM($this->getURI()) + or $this->returnServerError('No results for this query.'); foreach($html->find('li.item') as $release) { $script = $release->find('div.art', 0)->getAttribute('onclick'); @@ -36,9 +32,12 @@ class BandcampBridge extends BridgeAbstract{ } } - public function getName(){ + public function getURI(){ + return $this->uri.'tag/'.urlencode($this->getInput('tag')).'?sort_field=date'; + } - return (!empty($this->getInput('tag')) ? $this->getInput('tag') .' - ' : '') .'Bandcamp Tag'; + public function getName(){ + return $this->getInput('tag') .' - '.'Bandcamp Tag'; } public function getCacheDuration(){