def _fetch_track(track): splits = internals.get_splits(track) track_id = splits[-1] track = _getClient().track(track_id) data = { 'name': track['name'], 'artists': track['artists'], 'album': track['album']['name'], 'images': track['album']['images'], 'tracks': { 'items': [track] } } return data
def fetch_playlist(playlist): splits = internals.get_splits(playlist) try: username = splits[-3] except IndexError: # Wrong format, in either case log.error('The provided playlist URL is not in a recognized format!') sys.exit(10) playlist_id = splits[-1] try: results = spotify.user_playlist(username, playlist_id, fields='tracks,next,name') except spotipy.client.SpotifyException: log.error('Unable to find playlist') log.info('Make sure the playlist is set to publicly visible and then try again') sys.exit(11) return results
def _fetch_playlist(playlist): splits = internals.get_splits(playlist) try: username = splits[-3] except IndexError: # Wrong format, in either case log.error('The provided playlist URL is not in a recognized format!') return None playlist_id = splits[-1] try: results = _getClient().user_playlist( username, playlist_id, fields='tracks,next,name,images,artists,description') except spotipy.client.SpotifyException: log.error('Unable to find playlist', exc_info=True) log.info('Make sure the playlist is set to ' + 'publicly visible and then try again') return None return results
def fetch_album(album): splits = internals.get_splits(album) album_id = splits[-1] album = spotify.album(album_id) return album
def _fetch_album(album): splits = internals.get_splits(album) album_id = splits[-1] album = _getClient().album(album_id) return album