From b9af5ad7199f0a636ce9c6da652e210f4be94453 Mon Sep 17 00:00:00 2001 From: Paul Lamere Date: Sat, 31 Dec 2016 09:38:25 -0500 Subject: [PATCH] Added audio_analysis example --- examples/audio_analysis_for_track.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 examples/audio_analysis_for_track.py diff --git a/examples/audio_analysis_for_track.py b/examples/audio_analysis_for_track.py new file mode 100644 index 0000000..39e8347 --- /dev/null +++ b/examples/audio_analysis_for_track.py @@ -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,))