mirror of
https://github.com/c0de-archive/spotipy.git
synced 2025-01-06 14:52:50 +00:00
Improved example
This commit is contained in:
parent
45232a2489
commit
fdff788ff2
@ -15,19 +15,22 @@ sp.trace=False
|
|||||||
|
|
||||||
if len(sys.argv) > 1:
|
if len(sys.argv) > 1:
|
||||||
artist_name = ' '.join(sys.argv[1:])
|
artist_name = ' '.join(sys.argv[1:])
|
||||||
results = sp.search(q=artist_name, limit=50)
|
else:
|
||||||
tids = []
|
artist_name = 'weezer'
|
||||||
for i, t in enumerate(results['tracks']['items']):
|
|
||||||
print(' ', i, t['name'])
|
|
||||||
tids.append(t['uri'])
|
|
||||||
|
|
||||||
start = time.time()
|
results = sp.search(q=artist_name, limit=50)
|
||||||
features = sp.audio_features(tids)
|
tids = []
|
||||||
delta = time.time() - start
|
for i, t in enumerate(results['tracks']['items']):
|
||||||
for feature in features:
|
print(' ', i, t['name'])
|
||||||
print(json.dumps(feature, indent=4))
|
tids.append(t['uri'])
|
||||||
print()
|
|
||||||
analysis = sp._get(feature['analysis_url'])
|
start = time.time()
|
||||||
print(json.dumps(analysis, indent=4))
|
features = sp.audio_features(tids)
|
||||||
print()
|
delta = time.time() - start
|
||||||
print ("features retrieved in %.2f seconds" % (delta,))
|
for feature in features:
|
||||||
|
print(json.dumps(feature, indent=4))
|
||||||
|
print()
|
||||||
|
analysis = sp._get(feature['analysis_url'])
|
||||||
|
print(json.dumps(analysis, indent=4))
|
||||||
|
print()
|
||||||
|
print ("features retrieved in %.2f seconds" % (delta,))
|
||||||
|
Loading…
Reference in New Issue
Block a user