def from_spotify_playlist(spotify_playlist): return Playlist( spotify_playlist['id'], spotify_playlist['name'], spotify_playlist['description'], [ Track.from_spotify_playlist_track(track) for track in spotify_playlist['tracks']['items'] ], )
def _get_playlist_tracks(self, playlist_id): def track_fetcher(offset=0): results = self.client.playlist_tracks(playlist_id, offset=offset) return results['items'], results['total'] playlist_track_metadata = self._fetch_until_all_items_returned( track_fetcher) return [ Track.from_spotify_playlist_track(track) for track in playlist_track_metadata ]