diff --git a/examples/add_tracks_to_playlist.py b/examples/add_tracks_to_playlist.py index a5297da..d0df161 100644 --- a/examples/add_tracks_to_playlist.py +++ b/examples/add_tracks_to_playlist.py @@ -1,7 +1,6 @@ # Adds tracks to a playlist -import pprint import sys import spotipy diff --git a/examples/artist_albums.py b/examples/artist_albums.py index 6b9f6ce..4213985 100644 --- a/examples/artist_albums.py +++ b/examples/artist_albums.py @@ -20,7 +20,7 @@ def show_artist_albums(artist): results = sp.next(results) albums.extend(results['items']) seen = set() # to avoid dups - albums.sort(key=lambda album:album['name'].lower()) + albums.sort(key=lambda album: album['name'].lower()) for album in albums: name = album['name'] if name not in seen: diff --git a/examples/artist_recommendations.py b/examples/artist_recommendations.py index 6efbc1e..142cf49 100644 --- a/examples/artist_recommendations.py +++ b/examples/artist_recommendations.py @@ -19,7 +19,7 @@ def get_artist(name): def show_recommendations_for_artist(artist): albums = [] - results = sp.recommendations(seed_artists = [artist['id']]) + results = sp.recommendations(seed_artists=[artist['id']]) for track in results['tracks']: print track['name'], '-', track['artists'][0]['name'] diff --git a/examples/audio_analysis_for_track.py b/examples/audio_analysis_for_track.py index 39e8347..1f728a5 100644 --- a/examples/audio_analysis_for_track.py +++ b/examples/audio_analysis_for_track.py @@ -20,4 +20,4 @@ start = time.time() analysis = sp.audio_analysis(tid) delta = time.time() - start print(json.dumps(analysis, indent=4)) -print ("analysis retrieved in %.2f seconds" % (delta,)) +print("analysis retrieved in %.2f seconds" % (delta,)) diff --git a/examples/audio_features.py b/examples/audio_features.py index 079f4f9..989c852 100644 --- a/examples/audio_features.py +++ b/examples/audio_features.py @@ -33,4 +33,4 @@ for feature in features: analysis = sp._get(feature['analysis_url']) print(json.dumps(analysis, indent=4)) print() -print ("features retrieved in %.2f seconds" % (delta,)) +print("features retrieved in %.2f seconds" % (delta,)) diff --git a/examples/audio_features_for_track.py b/examples/audio_features_for_track.py index cdc980a..0565298 100644 --- a/examples/audio_features_for_track.py +++ b/examples/audio_features_for_track.py @@ -22,4 +22,4 @@ if len(sys.argv) > 1: features = sp.audio_features(tids) delta = time.time() - start print(json.dumps(features, indent=4)) - print ("features retrieved in %.2f seconds" % (delta,)) + print("features retrieved in %.2f seconds" % (delta,)) diff --git a/examples/change_playlist_details.py b/examples/change_playlist_details.py index 621f5d0..42044aa 100644 --- a/examples/change_playlist_details.py +++ b/examples/change_playlist_details.py @@ -24,7 +24,7 @@ if len(sys.argv) > 3: description = sys.argv[6] else: - print ("Usage: %s username playlist_id name [public collaborative " + print("Usage: %s username playlist_id name [public collaborative " "description]" % (sys.argv[0])) sys.exit() diff --git a/examples/create_playlist.py b/examples/create_playlist.py index 6084108..c3c65d1 100644 --- a/examples/create_playlist.py +++ b/examples/create_playlist.py @@ -2,8 +2,6 @@ import pprint import sys -import os -import subprocess import spotipy import spotipy.util as util diff --git a/examples/errors.py b/examples/errors.py index 570600f..546fcb4 100644 --- a/examples/errors.py +++ b/examples/errors.py @@ -2,22 +2,19 @@ from __future__ import print_function # (at top of module) from spotipy.oauth2 import SpotifyClientCredentials -import json import spotipy -import time -import sys client_credentials_manager = SpotifyClientCredentials() sp = spotipy.Spotify(client_credentials_manager=client_credentials_manager) sp.trace=True try: - print ('bad call 0') + print('bad call 0') bad_artist_call = sp.artist('spotify:artist:12341234') except spotipy.client.SpotifyException: - print ('bad call 0 exception' ) + print('bad call 0 exception') -print ('bad call 1') +print('bad call 1') bad_artist_call = sp.artist('spotify:artist:12341234') -print ('bad artist', bad_artist_call) +print('bad artist', bad_artist_call) diff --git a/examples/my_playlists.py b/examples/my_playlists.py index 50d3b2a..651eef4 100644 --- a/examples/my_playlists.py +++ b/examples/my_playlists.py @@ -1,11 +1,9 @@ # Shows a user's playlists -import pprint import sys import spotipy import spotipy.util as util -import simplejson as json if len(sys.argv) > 1: username = sys.argv[1] diff --git a/examples/remove_specific_tracks_from_playlist.py b/examples/remove_specific_tracks_from_playlist.py index c0bbcd7..e7b4695 100644 --- a/examples/remove_specific_tracks_from_playlist.py +++ b/examples/remove_specific_tracks_from_playlist.py @@ -10,10 +10,10 @@ if len(sys.argv) > 3: username = sys.argv[1] playlist_id = sys.argv[2] track_ids_and_positions = sys.argv[3:] - track_ids = [ ] + track_ids = [] for t_pos in sys.argv[3:]: tid, pos = t_pos.split(',') - track_ids.append( { "uri" : tid, "positions": [ int(pos)] } ) + track_ids.append({"uri": tid, "positions": [int(pos)]}) else: print("Usage: %s username playlist_id track_id,pos track_id,pos ..." % (sys.argv[0],)) sys.exit() diff --git a/examples/show_artist_top_tracks.py b/examples/show_artist_top_tracks.py index 68d8755..dbca651 100644 --- a/examples/show_artist_top_tracks.py +++ b/examples/show_artist_top_tracks.py @@ -3,7 +3,6 @@ import spotipy from spotipy.oauth2 import SpotifyClientCredentials import sys -import pprint if len(sys.argv) > 1: urn = sys.argv[1] diff --git a/examples/show_featured_playlists.py b/examples/show_featured_playlists.py index 2c7f8d9..769037c 100644 --- a/examples/show_featured_playlists.py +++ b/examples/show_featured_playlists.py @@ -2,7 +2,6 @@ import spotipy import sys -import pprint import spotipy.util as util if len(sys.argv) > 1: diff --git a/examples/show_new_releases.py b/examples/show_new_releases.py index 5205245..d4bd5fa 100644 --- a/examples/show_new_releases.py +++ b/examples/show_new_releases.py @@ -2,7 +2,6 @@ import spotipy import sys -import pprint import spotipy.util as util if len(sys.argv) > 1: @@ -22,7 +21,7 @@ if token: while response: albums = response['albums'] for i, item in enumerate(albums['items']): - print(albums['offset'] + i,item['name']) + print(albums['offset'] + i, item['name']) if albums['next']: response = sp.next(albums) diff --git a/examples/show_related.py b/examples/show_related.py index 0fca47d..9be66b1 100644 --- a/examples/show_related.py +++ b/examples/show_related.py @@ -4,7 +4,6 @@ import spotipy from spotipy.oauth2 import SpotifyClientCredentials import sys -import pprint if len(sys.argv) > 1: artist_name = sys.argv[1] diff --git a/examples/title_chain.py b/examples/title_chain.py index 6838e22..5d6ae73 100644 --- a/examples/title_chain.py +++ b/examples/title_chain.py @@ -21,7 +21,7 @@ def find_songs_that_start_with_word(word): out = [] while offset < max_offset and len(out) < max_titles: - results = sp.search(q=word, type = 'track', limit=50, offset = offset) + results = sp.search(q=word, type='track', limit=50, offset=offset) if len(results['tracks']['items']) == 0: break diff --git a/examples/user_playlists.py b/examples/user_playlists.py index 7bcc1f5..e94e810 100644 --- a/examples/user_playlists.py +++ b/examples/user_playlists.py @@ -1,9 +1,6 @@ # shows a user's playlists (need to be authenticated via oauth) -import pprint import sys -import os -import subprocess import spotipy diff --git a/examples/user_starred_playlist.py b/examples/user_starred_playlist.py index 914344a..645384c 100644 --- a/examples/user_starred_playlist.py +++ b/examples/user_starred_playlist.py @@ -23,7 +23,7 @@ if token: while tracks: for item in tracks['items']: track = item['track'] - print(which, track['name' ], ' --', track['artists'][0]['name']) + print(which, track['name'], ' --', track['artists'][0]['name']) which += 1 tracks = sp.next(tracks)