mirror of
https://github.com/c0de-archive/spotipy.git
synced 2024-11-04 23:17:48 +00:00
Added audio_analysis example
This commit is contained in:
parent
fdff788ff2
commit
b9af5ad719
23
examples/audio_analysis_for_track.py
Normal file
23
examples/audio_analysis_for_track.py
Normal file
@ -0,0 +1,23 @@
|
||||
# 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,))
|
Loading…
Reference in New Issue
Block a user