def getSpotifyTracks(sp: spotipy.client, playlist: []) -> []: spotifyTracks = [] tracks = playlist['tracks'] spotifyTracks.extend(tracks['items']) while tracks['next']: tracks = sp.next(tracks) spotifyTracks.extend(tracks['items']) return spotifyTracks
def getSpotifyUserPlaylists(sp: spotipy.client, userId: str) -> []: playlists = sp.user_playlists(userId) spotifyPlaylists = [] while playlists: playlistItems = playlists['items'] for i, playlist in enumerate(playlistItems): if playlist['owner']['id'] == userId: spotifyPlaylists.append(getSpotifyPlaylist(sp, userId, playlist['id'])) if playlists['next']: playlists = sp.next(playlists) else: playlists = None return spotifyPlaylists
def getSpotifyLoggedUserPlaylists(sp: spotipy.client) -> []: playlists = sp.current_user_playlists() spotifyPlaylists = [] while playlists: playlistItems = playlists['items'] # logging.info(playlists['items']) for i, playlist in enumerate(playlistItems): spotifyPlaylists.append(getSpotifyPlaylist(sp, playlist['owner']['id'], playlist['id'])) if playlists['next']: playlists = sp.next(playlists) else: playlists = None return spotifyPlaylists