[SoundcloudBridge] Fix bridge not returning tracks (#1757)

+ Use artwork for enclosure
This commit is contained in:
Joseph 2020-09-25 07:43:12 +01:00 committed by GitHub
parent 2bb99c4448
commit 80cc88ba78
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -23,6 +23,7 @@ class SoundCloudBridge extends BridgeAbstract {
) )
)); ));
private $feedTitle = null;
private $feedIcon = null; private $feedIcon = null;
private $clientIDCache = null; private $clientIDCache = null;
@ -31,33 +32,36 @@ class SoundCloudBridge extends BridgeAbstract {
'url' => 'https://soundcloud.com/' . $this->getInput('u') 'url' => 'https://soundcloud.com/' . $this->getInput('u')
)) or returnServerError('No results for this query'); )) or returnServerError('No results for this query');
$this->feedTitle = $res->username;
$this->feedIcon = $res->avatar_url; $this->feedIcon = $res->avatar_url;
$tracks = $this->apiGet('users/' . urlencode($res->id) . '/' . $this->getInput('t'))->collection $tracks = $this->apiGet(
or returnServerError('No results for this user/playlist'); 'users/' . urlencode($res->id) . '/' . $this->getInput('t'),
array('limit' => 31)
) or returnServerError('No results for this user/playlist');
$numTracks = min(count($tracks), 10); foreach ($tracks->collection as $index => $track) {
for($i = 0; $i < $numTracks; $i++) {
$item = array(); $item = array();
$item['author'] = $tracks[$i]->user->username; $item['author'] = $track->user->username;
$item['title'] = $tracks[$i]->user->username . ' - ' . $tracks[$i]->title; $item['title'] = $track->user->username . ' - ' . $track->title;
$item['timestamp'] = strtotime($tracks[$i]->created_at); $item['timestamp'] = strtotime($track->created_at);
$item['content'] = nl2br($tracks[$i]->description); $item['content'] = nl2br($track->description);
$item['enclosures'] = array($tracks[$i]->uri $item['enclosures'][] = $track->artwork_url;
. '/stream?client_id='
. $this->getClientID());
$item['id'] = self::URI $item['id'] = self::URI
. urlencode($this->getInput('u')) . urlencode($this->getInput('u'))
. '/' . '/'
. urlencode($tracks[$i]->permalink); . urlencode($track->permalink);
$item['uri'] = self::URI $item['uri'] = self::URI
. urlencode($this->getInput('u')) . urlencode($this->getInput('u'))
. '/' . '/'
. urlencode($tracks[$i]->permalink); . urlencode($track->permalink);
$this->items[] = $item; $this->items[] = $item;
}
if (count($this->items) >= 10) {
break;
}
}
} }
public function getIcon(){ public function getIcon(){
@ -73,8 +77,8 @@ class SoundCloudBridge extends BridgeAbstract {
} }
public function getName(){ public function getName(){
if(!is_null($this->getInput('u'))) { if($this->feedTitle) {
return $this->getInput('u') . ' - ' . self::NAME; return $this->feedTitle . ' - ' . self::NAME;
} }
return parent::getName(); return parent::getName();
@ -132,7 +136,7 @@ class SoundCloudBridge extends BridgeAbstract {
. http_build_query($parameters); . http_build_query($parameters);
} }
private function apiGet($endpoint, $parameters = array()){ private function apiGet($endpoint, $parameters = array()) {
$parameters['client_id'] = $this->getClientID(); $parameters['client_id'] = $this->getClientID();
try { try {