-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
e62250f
commit df8dd1c
Showing
5 changed files
with
70 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
<?php | ||
|
||
namespace duncan3dc\Sonos\Tracks; | ||
|
||
use duncan3dc\Sonos\Helper; | ||
|
||
/** | ||
* Representation of a Spotify playlist. | ||
*/ | ||
class SpotifyPlaylist extends Track | ||
{ | ||
const PREFIX = "x-rincon-cpcontainer:" . Helper::PLAYLIST_HASH; | ||
const REGION_EU = "2311"; | ||
const REGION_US = "3079"; | ||
|
||
/** | ||
* @var string $region The region code for the Spotify service (the default is EU). | ||
*/ | ||
public static $region = self::REGION_EU; | ||
|
||
|
||
/** | ||
* Create a Spotify playlist object. | ||
* | ||
* @param string $uri The URI of the playlist or the full Spotify ID of the playlist | ||
*/ | ||
public function __construct(string $uri) | ||
{ | ||
# If this is a spotify playlist ID and not a URI then convert it to a URI now | ||
if (substr($uri, 0, strlen(self::PREFIX)) !== self::PREFIX) { | ||
$uri = self::PREFIX . urlencode($uri); | ||
} | ||
|
||
parent::__construct($uri); | ||
} | ||
|
||
/** | ||
* Get the metadata xml for this playlist. | ||
* | ||
* @return string | ||
*/ | ||
public function getMetaData(): string | ||
{ | ||
$uri = substr($this->getUri(), strlen(self::PREFIX)); | ||
|
||
return Helper::createMetaDataXml(Helper::PLAYLIST_HASH . "{$uri}", "-1", [ | ||
"dc:title" => "", | ||
"upnp:class" => "object.container.playlistContainer", | ||
], static::$region); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters