forked from blallo/rss-bridge
[SoundcloudBridge] remove useless code
Signed-off-by: Pierre Mazière <pierre.maziere@gmx.com>
This commit is contained in:
parent
292f0f85ad
commit
05001f6b2e
1 changed files with 18 additions and 17 deletions
|
@ -1,9 +1,6 @@
|
|||
<?php
|
||||
class SoundCloudBridge extends BridgeAbstract{
|
||||
|
||||
private $request;
|
||||
public $name;
|
||||
|
||||
public function loadMetadatas() {
|
||||
|
||||
$this->maintainer = "kranack";
|
||||
|
@ -25,31 +22,35 @@ class SoundCloudBridge extends BridgeAbstract{
|
|||
public function collectData(){
|
||||
$param=$this->parameters[$this->queriedContext];
|
||||
|
||||
if (isset($param['u']['value']) && !empty($param['u']['value']))
|
||||
{
|
||||
$this->request = $param['u']['value'];
|
||||
|
||||
$res = json_decode($this->getContents('https://api.soundcloud.com/resolve?url=http://www.soundcloud.com/'. urlencode($this->request) .'&client_id=' . self::CLIENT_ID)) or $this->returnServerError('No results for this query');
|
||||
$tracks = json_decode($this->getContents('https://api.soundcloud.com/users/'. urlencode($res->id) .'/tracks?client_id=' . self::CLIENT_ID)) or $this->returnServerError('No results for this user');
|
||||
}
|
||||
else
|
||||
{
|
||||
$this->returnClientError('You must specify username');
|
||||
}
|
||||
$res = json_decode($this->getContents(
|
||||
'https://api.soundcloud.com/resolve?url=http://www.soundcloud.com/'
|
||||
. urlencode($param['u']['value'])
|
||||
.'&client_id=' . self::CLIENT_ID
|
||||
)) or $this->returnServerError('No results for this query');
|
||||
$tracks = json_decode($this->getContents(
|
||||
'https://api.soundcloud.com/users/'
|
||||
. urlencode($res->id)
|
||||
.'/tracks?client_id=' . self::CLIENT_ID
|
||||
)) or $this->returnServerError('No results for this user');
|
||||
|
||||
for ($i=0; $i < 10; $i++) {
|
||||
$item = array();
|
||||
$item['author'] = $tracks[$i]->user->username .' - '. $tracks[$i]->title;
|
||||
$item['title'] = $tracks[$i]->user->username .' - '. $tracks[$i]->title;
|
||||
$item['content'] = '<audio src="'. $tracks[$i]->uri .'/stream?client_id='. self::CLIENT_ID .'">';
|
||||
$item['id'] = 'https://soundcloud.com/'. urlencode($this->request) .'/'. urlencode($tracks[$i]->permalink);
|
||||
$item['uri'] = 'https://soundcloud.com/'. urlencode($this->request) .'/'. urlencode($tracks[$i]->permalink);
|
||||
$item['id'] = 'https://soundcloud.com/'
|
||||
. urlencode($param['u']['value']) .'/'
|
||||
. urlencode($tracks[$i]->permalink);
|
||||
$item['uri'] = 'https://soundcloud.com/'
|
||||
. urlencode($param['u']['value']) .'/'
|
||||
. urlencode($tracks[$i]->permalink);
|
||||
$this->items[] = $item;
|
||||
}
|
||||
|
||||
}
|
||||
public function getName(){
|
||||
return (!empty($this->name) ? $this->name .' - ' : '') . (!empty($this->request) ? $this->request : '');
|
||||
$param=$this->parameters[$this->queriedContext];
|
||||
return $this->name .' - '. $param['u']['value'];
|
||||
}
|
||||
|
||||
public function getCacheDuration(){
|
||||
|
|
Loading…
Reference in a new issue