diff --git a/src/Helper.php b/src/Helper.php index 624a37db..70d58782 100644 --- a/src/Helper.php +++ b/src/Helper.php @@ -12,6 +12,7 @@ class Helper { const TRACK_HASH = "00032020"; const ALBUM_HASH = "0004206c"; + const PLAYLIST_HASH = "0006006c"; /** * Create a mode array from the mode text value. diff --git a/src/Tracks/Factory.php b/src/Tracks/Factory.php index 0bfb58d5..341ee031 100644 --- a/src/Tracks/Factory.php +++ b/src/Tracks/Factory.php @@ -40,6 +40,7 @@ private function guessTrackClass(string $uri): string { $classes = [ Spotify::class, + SpotifyPlaylist::class, Google::class, GoogleUnlimited::class, Deezer::class, diff --git a/src/Tracks/SpotifyPlaylist.php b/src/Tracks/SpotifyPlaylist.php new file mode 100644 index 00000000..244a82a6 --- /dev/null +++ b/src/Tracks/SpotifyPlaylist.php @@ -0,0 +1,51 @@ +getUri(), strlen(self::PREFIX)); + + return Helper::createMetaDataXml($uri, "-1", [ + "dc:title" => "", + "upnp:class" => "object.container.playlistContainer", + ], static::$region); + } +} diff --git a/tests/Tracks/FactoryTest.php b/tests/Tracks/FactoryTest.php index f2b4b5ad..800ffaf8 100644 --- a/tests/Tracks/FactoryTest.php +++ b/tests/Tracks/FactoryTest.php @@ -9,6 +9,7 @@ use duncan3dc\Sonos\Tracks\Google; use duncan3dc\Sonos\Tracks\GoogleUnlimited; use duncan3dc\Sonos\Tracks\Spotify; +use duncan3dc\Sonos\Tracks\SpotifyPlaylist; use duncan3dc\Sonos\Tracks\Stream; use duncan3dc\Sonos\Tracks\Track; use duncan3dc\SonosTests\MockTest; @@ -44,6 +45,13 @@ public function testSpotifyTrackUri() } + public function testSpotifyPlaylistUri() + { + $uri = "x-rincon-cpcontainer:0006006cspotify:user:123sdfd6:playlist:123sdfd6"; + $track = $this->factory->createFromUri($uri); + $this->assertInstanceOf(SpotifyPlaylist::class, $track); + } + public function testDeezerTrackUri() { $uri = "x-sonos-http:tr:123sdfd6"; @@ -106,6 +114,14 @@ public function testSpotifyTrackXml() } + public function testSpotifyPlaylistTrackXml() + { + $xml = $this->getXml("x-rincon-cpcontainer:0006006cspotify:user:123sdfd6:playlist:123sdfd6"); + $track = $this->factory->createFromXml($xml); + $this->assertInstanceOf(SpotifyPlaylist::class, $track); + } + + public function testDeezerTrackXml() { $xml = $this->getXml("x-sonos-http:tr:123sdfd6");