mirror of
https://github.com/spotipy-dev/spotipy.git
synced 2026-06-19 09:13:53 +00:00
Format examples
Add spaces after ':' and ','.
Remove spaces before and after '(', '{', '[', ']', '}'
and ')'.
This commit is contained in:
parent
0b0942423c
commit
6c83f09898
@ -20,7 +20,7 @@ def show_artist_albums(artist):
|
|||||||
results = sp.next(results)
|
results = sp.next(results)
|
||||||
albums.extend(results['items'])
|
albums.extend(results['items'])
|
||||||
seen = set() # to avoid dups
|
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:
|
for album in albums:
|
||||||
name = album['name']
|
name = album['name']
|
||||||
if name not in seen:
|
if name not in seen:
|
||||||
|
|||||||
@ -20,4 +20,4 @@ start = time.time()
|
|||||||
analysis = sp.audio_analysis(tid)
|
analysis = sp.audio_analysis(tid)
|
||||||
delta = time.time() - start
|
delta = time.time() - start
|
||||||
print(json.dumps(analysis, indent=4))
|
print(json.dumps(analysis, indent=4))
|
||||||
print ("analysis retrieved in %.2f seconds" % (delta,))
|
print("analysis retrieved in %.2f seconds" % (delta,))
|
||||||
|
|||||||
@ -33,4 +33,4 @@ for feature in features:
|
|||||||
analysis = sp._get(feature['analysis_url'])
|
analysis = sp._get(feature['analysis_url'])
|
||||||
print(json.dumps(analysis, indent=4))
|
print(json.dumps(analysis, indent=4))
|
||||||
print()
|
print()
|
||||||
print ("features retrieved in %.2f seconds" % (delta,))
|
print("features retrieved in %.2f seconds" % (delta,))
|
||||||
|
|||||||
@ -22,4 +22,4 @@ if len(sys.argv) > 1:
|
|||||||
features = sp.audio_features(tids)
|
features = sp.audio_features(tids)
|
||||||
delta = time.time() - start
|
delta = time.time() - start
|
||||||
print(json.dumps(features, indent=4))
|
print(json.dumps(features, indent=4))
|
||||||
print ("features retrieved in %.2f seconds" % (delta,))
|
print("features retrieved in %.2f seconds" % (delta,))
|
||||||
|
|||||||
@ -24,7 +24,7 @@ if len(sys.argv) > 3:
|
|||||||
description = sys.argv[6]
|
description = sys.argv[6]
|
||||||
|
|
||||||
else:
|
else:
|
||||||
print ("Usage: %s username playlist_id name [public collaborative "
|
print("Usage: %s username playlist_id name [public collaborative "
|
||||||
"description]" % (sys.argv[0]))
|
"description]" % (sys.argv[0]))
|
||||||
sys.exit()
|
sys.exit()
|
||||||
|
|
||||||
|
|||||||
@ -9,12 +9,12 @@ client_credentials_manager = SpotifyClientCredentials()
|
|||||||
sp = spotipy.Spotify(client_credentials_manager=client_credentials_manager)
|
sp = spotipy.Spotify(client_credentials_manager=client_credentials_manager)
|
||||||
sp.trace=True
|
sp.trace=True
|
||||||
try:
|
try:
|
||||||
print ('bad call 0')
|
print('bad call 0')
|
||||||
bad_artist_call = sp.artist('spotify:artist:12341234')
|
bad_artist_call = sp.artist('spotify:artist:12341234')
|
||||||
except spotipy.client.SpotifyException:
|
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')
|
bad_artist_call = sp.artist('spotify:artist:12341234')
|
||||||
print ('bad artist', bad_artist_call)
|
print('bad artist', bad_artist_call)
|
||||||
|
|
||||||
|
|||||||
@ -11,10 +11,10 @@ if len(sys.argv) > 3:
|
|||||||
username = sys.argv[1]
|
username = sys.argv[1]
|
||||||
playlist_id = sys.argv[2]
|
playlist_id = sys.argv[2]
|
||||||
track_ids_and_positions = sys.argv[3:]
|
track_ids_and_positions = sys.argv[3:]
|
||||||
track_ids = [ ]
|
track_ids = []
|
||||||
for t_pos in sys.argv[3:]:
|
for t_pos in sys.argv[3:]:
|
||||||
tid, pos = t_pos.split(',')
|
tid, pos = t_pos.split(',')
|
||||||
track_ids.append( { "uri" : tid, "positions": [ int(pos)] } )
|
track_ids.append({"uri": tid, "positions": [int(pos)]})
|
||||||
else:
|
else:
|
||||||
print("Usage: %s username playlist_id track_id,pos track_id,pos ..." % (sys.argv[0],))
|
print("Usage: %s username playlist_id track_id,pos track_id,pos ..." % (sys.argv[0],))
|
||||||
sys.exit()
|
sys.exit()
|
||||||
|
|||||||
@ -21,7 +21,7 @@ if token:
|
|||||||
while response:
|
while response:
|
||||||
albums = response['albums']
|
albums = response['albums']
|
||||||
for i, item in enumerate(albums['items']):
|
for i, item in enumerate(albums['items']):
|
||||||
print(albums['offset'] + i,item['name'])
|
print(albums['offset'] + i, item['name'])
|
||||||
|
|
||||||
if albums['next']:
|
if albums['next']:
|
||||||
response = sp.next(albums)
|
response = sp.next(albums)
|
||||||
|
|||||||
@ -23,7 +23,7 @@ if token:
|
|||||||
while tracks:
|
while tracks:
|
||||||
for item in tracks['items']:
|
for item in tracks['items']:
|
||||||
track = item['track']
|
track = item['track']
|
||||||
print(which, track['name' ], ' --', track['artists'][0]['name'])
|
print(which, track['name'], ' --', track['artists'][0]['name'])
|
||||||
which += 1
|
which += 1
|
||||||
tracks = sp.next(tracks)
|
tracks = sp.next(tracks)
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user