Improve Soundcloud bridge (#1500)
* [SoundcloudBridge] Add playlist support, migrate to `api-v2`
This commit is contained in:
parent
3ad126cdf2
commit
976445b490
1 changed files with 18 additions and 9 deletions
|
@ -11,6 +11,15 @@ class SoundCloudBridge extends BridgeAbstract {
|
|||
'u' => array(
|
||||
'name' => 'username',
|
||||
'required' => true
|
||||
),
|
||||
't' => array(
|
||||
'name' => 'type',
|
||||
'type' => 'list',
|
||||
'defaultValue' => 'tracks',
|
||||
'values' => array(
|
||||
'Tracks' => 'tracks',
|
||||
'Playlists' => 'playlists'
|
||||
)
|
||||
)
|
||||
));
|
||||
|
||||
|
@ -19,13 +28,13 @@ class SoundCloudBridge extends BridgeAbstract {
|
|||
|
||||
public function collectData(){
|
||||
$res = $this->apiGet('resolve', array(
|
||||
'url' => 'http://www.soundcloud.com/' . $this->getInput('u')
|
||||
'url' => 'https://soundcloud.com/' . $this->getInput('u')
|
||||
)) or returnServerError('No results for this query');
|
||||
|
||||
$this->feedIcon = $res->avatar_url;
|
||||
|
||||
$tracks = $this->apiGet('users/' . urlencode($res->id) . '/tracks')
|
||||
or returnServerError('No results for this user');
|
||||
$tracks = $this->apiGet('users/' . urlencode($res->id) . '/' . $this->getInput('t'))->collection
|
||||
or returnServerError('No results for this user/playlist');
|
||||
|
||||
$numTracks = min(count($tracks), 10);
|
||||
for($i = 0; $i < $numTracks; $i++) {
|
||||
|
@ -33,7 +42,7 @@ class SoundCloudBridge extends BridgeAbstract {
|
|||
$item['author'] = $tracks[$i]->user->username;
|
||||
$item['title'] = $tracks[$i]->user->username . ' - ' . $tracks[$i]->title;
|
||||
$item['timestamp'] = strtotime($tracks[$i]->created_at);
|
||||
$item['content'] = $tracks[$i]->description;
|
||||
$item['content'] = nl2br($tracks[$i]->description);
|
||||
$item['enclosures'] = array($tracks[$i]->uri
|
||||
. '/stream?client_id='
|
||||
. $this->getClientID());
|
||||
|
@ -117,7 +126,7 @@ class SoundCloudBridge extends BridgeAbstract {
|
|||
}
|
||||
|
||||
private function buildAPIURL($endpoint, $parameters){
|
||||
return 'https://api.soundcloud.com/'
|
||||
return 'https://api-v2.soundcloud.com/'
|
||||
. $endpoint
|
||||
. '?'
|
||||
. http_build_query($parameters);
|
||||
|
|
Loading…
Reference in a new issue