[BandcampBridge] fix parameter 'tag' required status and fix the rest

Signed-off-by: Pierre Mazière <pierre.maziere@gmx.com>
This commit is contained in:
Pierre Mazière 2016-08-28 01:54:17 +02:00
parent e9ff7b32f1
commit 3fed12af1d

View file

@ -8,18 +8,14 @@ class BandcampBridge extends BridgeAbstract{
public $parameters = array( array( public $parameters = array( array(
'tag'=>array( 'tag'=>array(
'name'=>'tag', 'name'=>'tag',
'type'=>'text' 'type'=>'text',
'required'=>true
) )
)); ));
public function collectData(){ public function collectData(){
$html = ''; $html = $this->getSimpleHTMLDOM($this->getURI())
if (isset($this->getInput('tag'))) { or $this->returnServerError('No results for this query.');
$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/...)');
}
foreach($html->find('li.item') as $release) { foreach($html->find('li.item') as $release) {
$script = $release->find('div.art', 0)->getAttribute('onclick'); $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(){ public function getCacheDuration(){