mirror of
https://github.com/c0de-archive/spotipy.git
synced 2024-11-05 07:27:47 +00:00
24 lines
619 B
Python
24 lines
619 B
Python
|
# shows audio analysis for the given track
|
||
|
|
||
|
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)
|
||
|
|
||
|
if len(sys.argv) > 1:
|
||
|
tid = sys.argv[1]
|
||
|
else:
|
||
|
tid = 'spotify:track:4TTV7EcfroSLWzXRY6gLv6'
|
||
|
|
||
|
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,))
|