Support library export
This commit is contained in:
parent
c6e9fe17ca
commit
37f4c81290
@ -20,18 +20,6 @@ def playlist_current_user_create(client: Spotify, user_id: str, name: str) -> Si
|
||||
return SimplifiedPlaylist(**client.user_playlist_create(user_id, name))
|
||||
|
||||
|
||||
def playlist_current_user_all(client: Spotify) -> Iterable[SimplifiedPlaylist]:
|
||||
"""
|
||||
Get all playlists that belong to the current user
|
||||
"""
|
||||
|
||||
def _playlists(limit: int, offset: int) -> Paging:
|
||||
return Paging(**client.current_user_playlists(limit, offset))
|
||||
|
||||
for playlist in exhaust(_playlists):
|
||||
yield SimplifiedPlaylist(**playlist)
|
||||
|
||||
|
||||
def playlist_current_user_find(playlists: Iterable[SimplifiedPlaylist], name: str) -> Iterable[str]:
|
||||
"""
|
||||
Find all playlists for the current user that match a specific name
|
||||
|
@ -4,10 +4,18 @@ Actions related to user information
|
||||
from argparse import ArgumentParser
|
||||
from typing import Iterable, Optional
|
||||
|
||||
from spotify_model import Artist, CursorPaging, PublicUser
|
||||
from spotify_model import (
|
||||
Artist,
|
||||
CursorPaging,
|
||||
Paging,
|
||||
PublicUser,
|
||||
SavedAlbum,
|
||||
SavedTrack,
|
||||
SimplifiedPlaylist,
|
||||
)
|
||||
from spotipy import Spotify
|
||||
|
||||
from .util import exhaust_cursor, read_credentials_oauth
|
||||
from .util import exhaust, exhaust_cursor, read_credentials_oauth
|
||||
|
||||
|
||||
def current_user(client: Spotify) -> PublicUser:
|
||||
@ -25,6 +33,44 @@ def current_user(client: Spotify) -> PublicUser:
|
||||
return PublicUser(**client.current_user())
|
||||
|
||||
|
||||
def current_user_library_albums(client: Spotify) -> Iterable[SavedAlbum]:
|
||||
"""
|
||||
Get the albums a user has saved to their library
|
||||
|
||||
https://developer.spotify.com/documentation/web-api/reference/#endpoint-get-users-saved-albums
|
||||
"""
|
||||
|
||||
def _library_albums(limit: int, offset: int) -> Paging:
|
||||
return Paging(**client.current_user_saved_albums(limit, offset))
|
||||
|
||||
for album in exhaust(_library_albums):
|
||||
yield SavedAlbum(**album)
|
||||
|
||||
|
||||
def current_user_library_tracks(client: Spotify) -> Iterable[SavedTrack]:
|
||||
"""
|
||||
https://developer.spotify.com/documentation/web-api/reference/#endpoint-get-users-saved-tracks
|
||||
"""
|
||||
|
||||
def _library_tracks(limit: int, offset: int) -> Paging:
|
||||
return Paging(**client.current_user_saved_tracks(limit, offset))
|
||||
|
||||
for track in exhaust(_library_tracks):
|
||||
yield SavedTrack(**track)
|
||||
|
||||
|
||||
def current_user_playlists(client: Spotify) -> Iterable[SimplifiedPlaylist]:
|
||||
"""
|
||||
Get all playlists that belong to the current user
|
||||
"""
|
||||
|
||||
def _playlists(limit: int, offset: int) -> Paging:
|
||||
return Paging(**client.current_user_playlists(limit, offset))
|
||||
|
||||
for playlist in exhaust(_playlists):
|
||||
yield SimplifiedPlaylist(**playlist)
|
||||
|
||||
|
||||
def current_user_followed_artists(client: Spotify) -> Iterable[Artist]:
|
||||
"""
|
||||
Required scopes:
|
||||
|
Loading…
Reference in New Issue
Block a user