Skip to content

Commit a6a8330

Browse files
authored
Add tracks in playlist (#323)
1 parent 1126c67 commit a6a8330

2 files changed

Lines changed: 305 additions & 0 deletions

File tree

src/spotifyaio/models.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -369,6 +369,22 @@ class BasePlaylist(DataClassORJSONMixin):
369369
class Playlist(BasePlaylist):
370370
"""Playlist model."""
371371

372+
tracks: PlaylistTracks
373+
374+
375+
@dataclass
376+
class PlaylistTracks(DataClassORJSONMixin):
377+
"""PlaylistTracks model."""
378+
379+
items: list[PlaylistTrack]
380+
381+
382+
@dataclass
383+
class PlaylistTrack(DataClassORJSONMixin):
384+
"""PlaylistTrack model."""
385+
386+
track: Track
387+
372388

373389
@dataclass
374390
class PlaylistResponse(DataClassORJSONMixin):

tests/__snapshots__/test_spotify.ambr

Lines changed: 289 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4765,6 +4765,295 @@
47654765
}),
47664766
'playlist_id': '3cEYpjA9oz9GiPac4AsH4n',
47674767
'public': True,
4768+
'tracks': dict({
4769+
'items': list([
4770+
dict({
4771+
'track': dict({
4772+
'album': dict({
4773+
'album_id': '2pANdqPvxInB0YvcDiw4ko',
4774+
'album_type': <AlbumType.COMPILATION: 'compilation'>,
4775+
'artists': list([
4776+
dict({
4777+
'artist_id': '0LyfQWJT6nXafLPZqxe9Of',
4778+
'name': 'Various Artists',
4779+
'uri': 'spotify:artist:0LyfQWJT6nXafLPZqxe9Of',
4780+
}),
4781+
]),
4782+
'images': list([
4783+
dict({
4784+
'height': 640,
4785+
'url': 'https://i.scdn.co/image/ab67616d0000b273ce6d0eef0c1ce77e5f95bbbc',
4786+
'width': 640,
4787+
}),
4788+
dict({
4789+
'height': 300,
4790+
'url': 'https://i.scdn.co/image/ab67616d00001e02ce6d0eef0c1ce77e5f95bbbc',
4791+
'width': 300,
4792+
}),
4793+
dict({
4794+
'height': 64,
4795+
'url': 'https://i.scdn.co/image/ab67616d00004851ce6d0eef0c1ce77e5f95bbbc',
4796+
'width': 64,
4797+
}),
4798+
]),
4799+
'name': 'Progressive Psy Trance Picks Vol.8',
4800+
'release_date': '2012-04-02',
4801+
'release_date_precision': <ReleaseDatePrecision.DAY: 'day'>,
4802+
'total_tracks': 20,
4803+
'uri': 'spotify:album:2pANdqPvxInB0YvcDiw4ko',
4804+
}),
4805+
'artists': list([
4806+
dict({
4807+
'artist_id': '6eSdhw46riw2OUHgMwR8B5',
4808+
'name': 'Odiseo',
4809+
'uri': 'spotify:artist:6eSdhw46riw2OUHgMwR8B5',
4810+
}),
4811+
]),
4812+
'disc_number': 1,
4813+
'duration_ms': 376000,
4814+
'explicit': False,
4815+
'external_urls': dict({
4816+
'spotify': 'https://open.spotify.com/track/4rzfv0JLZfVhOhbSQ8o5jZ',
4817+
}),
4818+
'href': 'https://api.spotify.com/v1/tracks/4rzfv0JLZfVhOhbSQ8o5jZ',
4819+
'is_local': False,
4820+
'name': 'Api',
4821+
'track_id': '4rzfv0JLZfVhOhbSQ8o5jZ',
4822+
'track_number': 10,
4823+
'type': <ItemType.TRACK: 'track'>,
4824+
'uri': 'spotify:track:4rzfv0JLZfVhOhbSQ8o5jZ',
4825+
}),
4826+
}),
4827+
dict({
4828+
'track': dict({
4829+
'album': dict({
4830+
'album_id': '6nlfkk5GoXRL1nktlATNsy',
4831+
'album_type': <AlbumType.COMPILATION: 'compilation'>,
4832+
'artists': list([
4833+
dict({
4834+
'artist_id': '0LyfQWJT6nXafLPZqxe9Of',
4835+
'name': 'Various Artists',
4836+
'uri': 'spotify:artist:0LyfQWJT6nXafLPZqxe9Of',
4837+
}),
4838+
]),
4839+
'images': list([
4840+
dict({
4841+
'height': 640,
4842+
'url': 'https://i.scdn.co/image/ab67616d0000b273aa2ff29970d9a63a49dfaeb2',
4843+
'width': 640,
4844+
}),
4845+
dict({
4846+
'height': 300,
4847+
'url': 'https://i.scdn.co/image/ab67616d00001e02aa2ff29970d9a63a49dfaeb2',
4848+
'width': 300,
4849+
}),
4850+
dict({
4851+
'height': 64,
4852+
'url': 'https://i.scdn.co/image/ab67616d00004851aa2ff29970d9a63a49dfaeb2',
4853+
'width': 64,
4854+
}),
4855+
]),
4856+
'name': 'Wellness & Dreaming Source',
4857+
'release_date': '2015-01-09',
4858+
'release_date_precision': <ReleaseDatePrecision.DAY: 'day'>,
4859+
'total_tracks': 25,
4860+
'uri': 'spotify:album:6nlfkk5GoXRL1nktlATNsy',
4861+
}),
4862+
'artists': list([
4863+
dict({
4864+
'artist_id': '5VQE4WOzPu9h3HnGLuBoA6',
4865+
'name': 'Vlasta Marek',
4866+
'uri': 'spotify:artist:5VQE4WOzPu9h3HnGLuBoA6',
4867+
}),
4868+
]),
4869+
'disc_number': 1,
4870+
'duration_ms': 730066,
4871+
'explicit': False,
4872+
'external_urls': dict({
4873+
'spotify': 'https://open.spotify.com/track/5o3jMYOSbaVz3tkgwhELSV',
4874+
}),
4875+
'href': 'https://api.spotify.com/v1/tracks/5o3jMYOSbaVz3tkgwhELSV',
4876+
'is_local': False,
4877+
'name': 'Is',
4878+
'track_id': '5o3jMYOSbaVz3tkgwhELSV',
4879+
'track_number': 21,
4880+
'type': <ItemType.TRACK: 'track'>,
4881+
'uri': 'spotify:track:5o3jMYOSbaVz3tkgwhELSV',
4882+
}),
4883+
}),
4884+
dict({
4885+
'track': dict({
4886+
'album': dict({
4887+
'album_id': '4hnqM0JK4CM1phwfq1Ldyz',
4888+
'album_type': <AlbumType.ALBUM: 'album'>,
4889+
'artists': list([
4890+
dict({
4891+
'artist_id': '066X20Nz7iquqkkCW6Jxy6',
4892+
'name': 'LCD Soundsystem',
4893+
'uri': 'spotify:artist:066X20Nz7iquqkkCW6Jxy6',
4894+
}),
4895+
]),
4896+
'images': list([
4897+
dict({
4898+
'height': 640,
4899+
'url': 'https://i.scdn.co/image/ab67616d0000b273ee0d0dce888c6c8a70db6e8b',
4900+
'width': 640,
4901+
}),
4902+
dict({
4903+
'height': 300,
4904+
'url': 'https://i.scdn.co/image/ab67616d00001e02ee0d0dce888c6c8a70db6e8b',
4905+
'width': 300,
4906+
}),
4907+
dict({
4908+
'height': 64,
4909+
'url': 'https://i.scdn.co/image/ab67616d00004851ee0d0dce888c6c8a70db6e8b',
4910+
'width': 64,
4911+
}),
4912+
]),
4913+
'name': 'This Is Happening',
4914+
'release_date': '2010-05-17',
4915+
'release_date_precision': <ReleaseDatePrecision.DAY: 'day'>,
4916+
'total_tracks': 9,
4917+
'uri': 'spotify:album:4hnqM0JK4CM1phwfq1Ldyz',
4918+
}),
4919+
'artists': list([
4920+
dict({
4921+
'artist_id': '066X20Nz7iquqkkCW6Jxy6',
4922+
'name': 'LCD Soundsystem',
4923+
'uri': 'spotify:artist:066X20Nz7iquqkkCW6Jxy6',
4924+
}),
4925+
]),
4926+
'disc_number': 1,
4927+
'duration_ms': 401440,
4928+
'explicit': False,
4929+
'external_urls': dict({
4930+
'spotify': 'https://open.spotify.com/track/4Cy0NHJ8Gh0xMdwyM9RkQm',
4931+
}),
4932+
'href': 'https://api.spotify.com/v1/tracks/4Cy0NHJ8Gh0xMdwyM9RkQm',
4933+
'is_local': False,
4934+
'name': 'All I Want',
4935+
'track_id': '4Cy0NHJ8Gh0xMdwyM9RkQm',
4936+
'track_number': 4,
4937+
'type': <ItemType.TRACK: 'track'>,
4938+
'uri': 'spotify:track:4Cy0NHJ8Gh0xMdwyM9RkQm',
4939+
}),
4940+
}),
4941+
dict({
4942+
'track': dict({
4943+
'album': dict({
4944+
'album_id': '2usKFntxa98WHMcyW6xJBz',
4945+
'album_type': <AlbumType.ALBUM: 'album'>,
4946+
'artists': list([
4947+
dict({
4948+
'artist_id': '272ArH9SUAlslQqsSgPJA2',
4949+
'name': 'Glenn Horiuchi Trio',
4950+
'uri': 'spotify:artist:272ArH9SUAlslQqsSgPJA2',
4951+
}),
4952+
]),
4953+
'images': list([
4954+
dict({
4955+
'height': 640,
4956+
'url': 'https://i.scdn.co/image/ab67616d0000b2738b7447ac3daa1da18811cf7b',
4957+
'width': 640,
4958+
}),
4959+
dict({
4960+
'height': 300,
4961+
'url': 'https://i.scdn.co/image/ab67616d00001e028b7447ac3daa1da18811cf7b',
4962+
'width': 300,
4963+
}),
4964+
dict({
4965+
'height': 64,
4966+
'url': 'https://i.scdn.co/image/ab67616d000048518b7447ac3daa1da18811cf7b',
4967+
'width': 64,
4968+
}),
4969+
]),
4970+
'name': 'Glenn Horiuchi Trio / Gelenn Horiuchi Quartet: Mercy / Jump Start / Endpoints / Curl Out / Earthworks / Mind Probe / Null Set / Another Space (A)',
4971+
'release_date': '2011-04-01',
4972+
'release_date_precision': <ReleaseDatePrecision.DAY: 'day'>,
4973+
'total_tracks': 8,
4974+
'uri': 'spotify:album:2usKFntxa98WHMcyW6xJBz',
4975+
}),
4976+
'artists': list([
4977+
dict({
4978+
'artist_id': '272ArH9SUAlslQqsSgPJA2',
4979+
'name': 'Glenn Horiuchi Trio',
4980+
'uri': 'spotify:artist:272ArH9SUAlslQqsSgPJA2',
4981+
}),
4982+
]),
4983+
'disc_number': 1,
4984+
'duration_ms': 358760,
4985+
'explicit': False,
4986+
'external_urls': dict({
4987+
'spotify': 'https://open.spotify.com/track/6hvFrZNocdt2FcKGCSY5NI',
4988+
}),
4989+
'href': 'https://api.spotify.com/v1/tracks/6hvFrZNocdt2FcKGCSY5NI',
4990+
'is_local': False,
4991+
'name': 'Endpoints',
4992+
'track_id': '6hvFrZNocdt2FcKGCSY5NI',
4993+
'track_number': 2,
4994+
'type': <ItemType.TRACK: 'track'>,
4995+
'uri': 'spotify:track:6hvFrZNocdt2FcKGCSY5NI',
4996+
}),
4997+
}),
4998+
dict({
4999+
'track': dict({
5000+
'album': dict({
5001+
'album_id': '0ivM6kSawaug0j3tZVusG2',
5002+
'album_type': <AlbumType.ALBUM: 'album'>,
5003+
'artists': list([
5004+
dict({
5005+
'artist_id': '2KftmGt9sk1yLjsAoloC3M',
5006+
'name': 'Zucchero',
5007+
'uri': 'spotify:artist:2KftmGt9sk1yLjsAoloC3M',
5008+
}),
5009+
]),
5010+
'images': list([
5011+
dict({
5012+
'height': 640,
5013+
'url': 'https://i.scdn.co/image/ab67616d0000b27304e57d181ff062f8339d6c71',
5014+
'width': 640,
5015+
}),
5016+
dict({
5017+
'height': 300,
5018+
'url': 'https://i.scdn.co/image/ab67616d00001e0204e57d181ff062f8339d6c71',
5019+
'width': 300,
5020+
}),
5021+
dict({
5022+
'height': 64,
5023+
'url': 'https://i.scdn.co/image/ab67616d0000485104e57d181ff062f8339d6c71',
5024+
'width': 64,
5025+
}),
5026+
]),
5027+
'name': 'All The Best (Spanish Version)',
5028+
'release_date': '2007-01-01',
5029+
'release_date_precision': <ReleaseDatePrecision.DAY: 'day'>,
5030+
'total_tracks': 18,
5031+
'uri': 'spotify:album:0ivM6kSawaug0j3tZVusG2',
5032+
}),
5033+
'artists': list([
5034+
dict({
5035+
'artist_id': '2KftmGt9sk1yLjsAoloC3M',
5036+
'name': 'Zucchero',
5037+
'uri': 'spotify:artist:2KftmGt9sk1yLjsAoloC3M',
5038+
}),
5039+
]),
5040+
'disc_number': 1,
5041+
'duration_ms': 176093,
5042+
'explicit': False,
5043+
'external_urls': dict({
5044+
'spotify': 'https://open.spotify.com/track/2E2znCPaS8anQe21GLxcvJ',
5045+
}),
5046+
'href': 'https://api.spotify.com/v1/tracks/2E2znCPaS8anQe21GLxcvJ',
5047+
'is_local': False,
5048+
'name': 'You Are So Beautiful',
5049+
'track_id': '2E2znCPaS8anQe21GLxcvJ',
5050+
'track_number': 18,
5051+
'type': <ItemType.TRACK: 'track'>,
5052+
'uri': 'spotify:track:2E2znCPaS8anQe21GLxcvJ',
5053+
}),
5054+
}),
5055+
]),
5056+
}),
47685057
'uri': 'spotify:playlist:3cEYpjA9oz9GiPac4AsH4n',
47695058
})
47705059
# ---

0 commit comments

Comments
 (0)