Skip to content

Commit fb58ad1

Browse files
authored
Add list of things still left and reoder (#348)
1 parent b683648 commit fb58ad1

1 file changed

Lines changed: 175 additions & 69 deletions

File tree

src/spotifyaio/spotify.py

Lines changed: 175 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -147,19 +147,96 @@ async def get_album(self, album_id: str) -> Album:
147147
response = await self._get(f"v1/albums/{identifier}")
148148
return Album.from_json(response)
149149

150+
# Get a list of albums
151+
152+
# Get an album's tracks
153+
154+
async def get_saved_albums(self) -> list[SavedAlbum]:
155+
"""Get saved albums."""
156+
params: dict[str, Any] = {"limit": 48}
157+
response = await self._get("v1/me/albums", params=params)
158+
return SavedAlbumResponse.from_json(response).items
159+
160+
# Save an album
161+
162+
# Remove an album
163+
164+
# Check if one or more albums is already saved
165+
166+
async def get_new_releases(self) -> list[SimplifiedAlbum]:
167+
"""Get new releases."""
168+
params: dict[str, Any] = {"limit": 48}
169+
response = await self._get("v1/browse/new-releases", params=params)
170+
return NewReleasesResponse.from_json(response).albums.items
171+
150172
async def get_artist(self, artist_id: str) -> Artist:
151173
"""Get artist."""
152174
identifier = artist_id.split(":")[-1]
153175
response = await self._get(f"v1/artists/{identifier}")
154176
return Artist.from_json(response)
155177

178+
# Get several artists
179+
156180
async def get_artist_albums(self, artist_id: str) -> list[SimplifiedAlbum]:
157181
"""Get artist albums."""
158182
params: dict[str, Any] = {"limit": 48}
159183
identifier = artist_id.split(":")[-1]
160184
response = await self._get(f"v1/artists/{identifier}/albums", params=params)
161185
return NewReleasesResponseInner.from_json(response).items
162186

187+
# Get an artist's top tracks
188+
189+
# Get an artist's related artists
190+
191+
# Get audiobook
192+
193+
# Get several audiobooks
194+
195+
# Get an audiobook's episodes
196+
197+
# Get saved audiobooks
198+
199+
# Save an audiobook
200+
201+
# Remove an audiobook
202+
203+
# Check if one or more audiobooks is already saved
204+
205+
async def get_categories(self) -> list[Category]:
206+
"""Get list of categories."""
207+
params: dict[str, Any] = {"limit": 48}
208+
response = await self._get("v1/browse/categories", params=params)
209+
return CategoriesResponse.from_json(response).categories.items
210+
211+
async def get_category(self, category_id: str) -> Category:
212+
"""Get category."""
213+
response = await self._get(f"v1/browse/categories/{category_id}")
214+
return Category.from_json(response)
215+
216+
# Get chapter
217+
218+
# Get several chapters
219+
220+
async def get_episode(self, episode_id: str) -> Episode:
221+
"""Get episode."""
222+
identifier = episode_id.split(":")[-1]
223+
response = await self._get(f"v1/episodes/{identifier}")
224+
return Episode.from_json(response)
225+
226+
# Get several episodes
227+
228+
# Get saved episodes
229+
230+
# Save an episode
231+
232+
# Remove an episode
233+
234+
# Check if one or more episodes is already saved
235+
236+
# Get genre seeds
237+
238+
# Get available markets
239+
163240
async def get_playback(self) -> PlaybackState | None:
164241
"""Get playback state."""
165242
response = await self._get(
@@ -169,13 +246,6 @@ async def get_playback(self) -> PlaybackState | None:
169246
return None
170247
return PlaybackState.from_json(response)
171248

172-
async def get_current_playing(self) -> CurrentPlaying | None:
173-
"""Get playback state."""
174-
response = await self._get("v1/me/player/currently-playing")
175-
if response == "":
176-
return None
177-
return CurrentPlaying.from_json(response)
178-
179249
async def transfer_playback(self, device_id: str) -> None:
180250
"""Transfer playback."""
181251
await self._put("v1/me/player", {"device_ids": [device_id]})
@@ -185,6 +255,13 @@ async def get_devices(self) -> list[Device]:
185255
response = await self._get("v1/me/player/devices")
186256
return Devices.from_json(response).devices
187257

258+
async def get_current_playing(self) -> CurrentPlaying | None:
259+
"""Get playback state."""
260+
response = await self._get("v1/me/player/currently-playing")
261+
if response == "":
262+
return None
263+
return CurrentPlaying.from_json(response)
264+
188265
async def start_playback(
189266
self,
190267
*,
@@ -261,6 +338,14 @@ async def set_shuffle(self, *, state: bool, device_id: str | None = None) -> Non
261338
params["device_id"] = device_id
262339
await self._put("v1/me/player/shuffle", params=params)
263340

341+
async def get_recently_played_tracks(self) -> list[PlayedTrack]:
342+
"""Get recently played tracks."""
343+
params: dict[str, Any] = {"limit": 48}
344+
response = await self._get("v1/me/player/recently-played", params=params)
345+
return PlayedTrackResponse.from_json(response).items
346+
347+
# Get queue
348+
264349
async def add_to_queue(self, uri: str, device_id: str | None = None) -> None:
265350
"""Add to queue."""
266351
data: dict[str, str] = {"uri": uri}
@@ -274,52 +359,52 @@ async def get_playlist(self, playlist_id: str) -> Playlist:
274359
response = await self._get(f"v1/playlists/{identifier}")
275360
return Playlist.from_json(response)
276361

362+
# Update playlist details
363+
364+
# Get a playlist items
365+
366+
# Update a playlist items
367+
368+
# Remove a playlist items
369+
277370
async def get_playlists_for_current_user(self) -> list[BasePlaylist]:
278371
"""Get playlists."""
279372
params: dict[str, Any] = {"limit": 48}
280373
response = await self._get("v1/me/playlists", params=params)
281374
return PlaylistResponse.from_json(response).items
282375

283-
async def get_followed_artists(self) -> list[Artist]:
284-
"""Get followed artists."""
285-
params: dict[str, Any] = {"limit": 48, "type": "artist"}
286-
response = await self._get("v1/me/following", params=params)
287-
return ArtistResponse.from_json(response).artists.items
376+
# Get users playlists
377+
378+
# Create a playlist
288379

289380
async def get_featured_playlists(self) -> list[BasePlaylist]:
290381
"""Get featured playlists."""
291382
params: dict[str, Any] = {"limit": 48}
292383
response = await self._get("v1/browse/featured-playlists", params=params)
293384
return FeaturedPlaylistResponse.from_json(response).playlists.items
294385

295-
async def get_category(self, category_id: str) -> Category:
296-
"""Get category."""
297-
response = await self._get(f"v1/browse/categories/{category_id}")
298-
return Category.from_json(response)
299-
300-
async def get_categories(self) -> list[Category]:
301-
"""Get category."""
386+
async def get_category_playlists(self, category_id: str) -> list[BasePlaylist]:
387+
"""Get category playlists."""
302388
params: dict[str, Any] = {"limit": 48}
303-
response = await self._get("v1/browse/categories", params=params)
304-
return CategoriesResponse.from_json(response).categories.items
389+
response = await self._get(
390+
f"v1/browse/categories/{category_id}/playlists",
391+
params=params,
392+
)
393+
return CategoryPlaylistResponse.from_json(response).playlists.items
305394

306-
async def get_saved_albums(self) -> list[SavedAlbum]:
307-
"""Get saved albums."""
308-
params: dict[str, Any] = {"limit": 48}
309-
response = await self._get("v1/me/albums", params=params)
310-
return SavedAlbumResponse.from_json(response).items
395+
# Get playlist cover image
311396

312-
async def get_saved_tracks(self) -> list[SavedTrack]:
313-
"""Get saved tracks."""
314-
params: dict[str, Any] = {"limit": 48}
315-
response = await self._get("v1/me/tracks", params=params)
316-
return SavedTrackResponse.from_json(response).items
397+
# Upload a custom playlist cover image
317398

318-
async def get_saved_shows(self) -> list[SavedShow]:
319-
"""Get saved shows."""
320-
params: dict[str, Any] = {"limit": 48}
321-
response = await self._get("v1/me/shows", params=params)
322-
return SavedShowResponse.from_json(response).items
399+
# Search for an item
400+
401+
async def get_show(self, show_id: str) -> Show:
402+
"""Get show."""
403+
identifier = show_id.split(":")[-1]
404+
response = await self._get(f"v1/shows/{identifier}")
405+
return Show.from_json(response)
406+
407+
# Get several shows
323408

324409
async def get_show_episodes(self, show_id: str) -> list[SimplifiedEpisode]:
325410
"""Get show episodes."""
@@ -328,26 +413,46 @@ async def get_show_episodes(self, show_id: str) -> list[SimplifiedEpisode]:
328413
response = await self._get(f"v1/shows/{identifier}/episodes", params=params)
329414
return ShowEpisodesResponse.from_json(response).items
330415

331-
async def get_recently_played_tracks(self) -> list[PlayedTrack]:
332-
"""Get recently played tracks."""
416+
async def get_saved_shows(self) -> list[SavedShow]:
417+
"""Get saved shows."""
333418
params: dict[str, Any] = {"limit": 48}
334-
response = await self._get("v1/me/player/recently-played", params=params)
335-
return PlayedTrackResponse.from_json(response).items
419+
response = await self._get("v1/me/shows", params=params)
420+
return SavedShowResponse.from_json(response).items
336421

337-
async def get_category_playlists(self, category_id: str) -> list[BasePlaylist]:
338-
"""Get category playlists."""
339-
params: dict[str, Any] = {"limit": 48}
340-
response = await self._get(
341-
f"v1/browse/categories/{category_id}/playlists",
342-
params=params,
343-
)
344-
return CategoryPlaylistResponse.from_json(response).playlists.items
422+
# Save a show
345423

346-
async def get_new_releases(self) -> list[SimplifiedAlbum]:
347-
"""Get new releases."""
424+
# Remove a show
425+
426+
# Check if one or more shows is already saved
427+
428+
# Get a track
429+
430+
# Get several tracks
431+
432+
async def get_saved_tracks(self) -> list[SavedTrack]:
433+
"""Get saved tracks."""
348434
params: dict[str, Any] = {"limit": 48}
349-
response = await self._get("v1/browse/new-releases", params=params)
350-
return NewReleasesResponse.from_json(response).albums.items
435+
response = await self._get("v1/me/tracks", params=params)
436+
return SavedTrackResponse.from_json(response).items
437+
438+
# Save a track
439+
440+
# Remove a track
441+
442+
# Check if one or more tracks is already saved
443+
444+
# Get audio features for several tracks
445+
446+
# Get audio features for a track
447+
448+
# Get audio analysis for a track
449+
450+
# Get recommendations
451+
452+
async def get_current_user(self) -> UserProfile:
453+
"""Get current user."""
454+
response = await self._get("v1/me")
455+
return UserProfile.from_json(response)
351456

352457
async def get_top_artists(self) -> list[Artist]:
353458
"""Get top artists."""
@@ -361,28 +466,29 @@ async def get_top_tracks(self) -> list[Track]:
361466
response = await self._get("v1/me/top/tracks", params=params)
362467
return TopTracksResponse.from_json(response).items
363468

364-
async def get_episode(self, episode_id: str) -> Episode:
365-
"""Get episode."""
366-
identifier = episode_id.split(":")[-1]
367-
response = await self._get(f"v1/episodes/{identifier}")
368-
return Episode.from_json(response)
369-
370-
async def get_show(self, show_id: str) -> Show:
371-
"""Get show."""
372-
identifier = show_id.split(":")[-1]
373-
response = await self._get(f"v1/shows/{identifier}")
374-
return Show.from_json(response)
375-
376-
async def get_current_user(self) -> UserProfile:
377-
"""Get current user."""
378-
response = await self._get("v1/me")
379-
return UserProfile.from_json(response)
380-
381469
async def get_user(self, user_id: str) -> BaseUserProfile:
382470
"""Get user."""
383471
response = await self._get(f"v1/users/{user_id}")
384472
return BaseUserProfile.from_json(response)
385473

474+
# Follow a playlist
475+
476+
# Unfollow a playlist
477+
478+
async def get_followed_artists(self) -> list[Artist]:
479+
"""Get followed artists."""
480+
params: dict[str, Any] = {"limit": 48, "type": "artist"}
481+
response = await self._get("v1/me/following", params=params)
482+
return ArtistResponse.from_json(response).artists.items
483+
484+
# Follow an artist or user
485+
486+
# Unfollow an artist or user
487+
488+
# Check if a user is following an artist or user
489+
490+
# Check if a user is following a playlist
491+
386492
async def close(self) -> None:
387493
"""Close open client session."""
388494
if self.session and self._close_session:

0 commit comments

Comments
 (0)