1
0
Fork 0
forked from blallo/rss-bridge

Fix Soundcloud bridge (change client key, URI now use HTTPS and change URI according with soundcloud API)

This commit is contained in:
Damien Calesse 2015-09-09 00:13:56 +02:00
parent f7a7acfde4
commit 8edddcd97f

View file

@ -7,7 +7,7 @@
* @homepage http://www.soundcloud.com/ * @homepage http://www.soundcloud.com/
* @description Returns 10 newest music from user profile * @description Returns 10 newest music from user profile
* @maintainer kranack * @maintainer kranack
* @update 2014-07-24 * @update 2015-09-08
* @use1(u="username") * @use1(u="username")
* *
*/ */
@ -15,6 +15,7 @@ class SoundCloudBridge extends BridgeAbstract{
private $request; private $request;
private $name; private $name;
const CLIENT_ID = '0aca19eae3843844e4053c6d8fdb7875';
public function collectData(array $param){ public function collectData(array $param){
@ -22,8 +23,8 @@ class SoundCloudBridge extends BridgeAbstract{
{ {
$this->request = $param['u']; $this->request = $param['u'];
$res = json_decode(file_get_contents('http://api.soundcloud.com/resolve.json?url=http://www.soundcloud.com/'. urlencode($this->request) .'&consumer_key=apigee')) or $this->returnError('No results for this query', 404); $res = json_decode(file_get_contents('https://api.soundcloud.com/resolve?url=http://www.soundcloud.com/'. urlencode($this->request) .'&client_id=' . self::CLIENT_ID)) or $this->returnError('No results for this query', 404);
$tracks = json_decode(file_get_contents('http://api.soundcloud.com/users/'. urlencode($res->id) .'/tracks.json?consumer_key=apigee')) or $this->returnError('No results for this user', 404); $tracks = json_decode(file_get_contents('https://api.soundcloud.com/users/'. urlencode($res->id) .'/tracks?client_id=' . self::CLIENT_ID)) or $this->returnError('No results for this user', 404);
} }
else else
{ {
@ -34,10 +35,11 @@ class SoundCloudBridge extends BridgeAbstract{
$item = new \Item(); $item = new \Item();
$item->name = $tracks[$i]->user->username .' - '. $tracks[$i]->title; $item->name = $tracks[$i]->user->username .' - '. $tracks[$i]->title;
$item->title = $tracks[$i]->user->username .' - '. $tracks[$i]->title; $item->title = $tracks[$i]->user->username .' - '. $tracks[$i]->title;
$item->content = '<audio src="'. $tracks[$i]->uri .'/stream?consumer_key=apigee">'; $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->id = 'https://soundcloud.com/'. urlencode($this->request) .'/'. urlencode($tracks[$i]->permalink);
$item->uri = 'https://soundcloud.com/'. urlencode($this->request) .'/'. urlencode($tracks[$i]->permalink); $item->uri = 'https://soundcloud.com/'. urlencode($this->request) .'/'. urlencode($tracks[$i]->permalink);
$this->items[] = $item; $this->items[] = $item;
var_dump($item);
} }
} }
@ -46,10 +48,10 @@ class SoundCloudBridge extends BridgeAbstract{
} }
public function getURI(){ public function getURI(){
return 'http://www.soundcloud.com/'; return 'https://www.soundcloud.com/';
} }
public function getCacheDuration(){ public function getCacheDuration(){
return 600; // 10 minutes return 0; // 10 minutes
} }
} }