From 4f6aef7e798b664950be5453816207f990563d5d Mon Sep 17 00:00:00 2001 From: Paul Lamere Date: Thu, 3 Jul 2014 06:36:36 -0400 Subject: [PATCH] Added show_tracks example --- CHANGES.txt | 1 + examples/show_tracks.py | 24 ++++++++++++++++++++++++ setup.py | 2 +- 3 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 examples/show_tracks.py diff --git a/CHANGES.txt b/CHANGES.txt index b8f82d0..fb95c50 100644 --- a/CHANGES.txt +++ b/CHANGES.txt @@ -1,3 +1,4 @@ v1.40, June 12, 2014 -- Initial public release. v1.42, June 19, 2014 -- Removed dependency on simplejson +v1.43, June 27, 2014 -- Fixed JSON handling issue diff --git a/examples/show_tracks.py b/examples/show_tracks.py new file mode 100644 index 0000000..de64bbb --- /dev/null +++ b/examples/show_tracks.py @@ -0,0 +1,24 @@ +''' + usage: show_tracks.py path_of_ids + + given a list of track IDs show the artist and track name +''' +import sys +import spotipy + +if __name__ == '__main__': + max_tracks_per_call = 50 + if len(sys.argv) > 1: + file = open(sys.argv[1]) + else: + file = sys.stdin + tids = file.read().split() + + sp = spotipy.Spotify() + for start in xrange(0, len(tids), max_tracks_per_call): + results = sp.tracks(tids[start: start + max_tracks_per_call]) + for track in results['tracks']: + print track['name'] + ' - ' + track['artists'][0]['name'] + + + diff --git a/setup.py b/setup.py index 7b9a0c2..a7f7df3 100644 --- a/setup.py +++ b/setup.py @@ -3,7 +3,7 @@ from setuptools import setup setup( name='SpotipyWebApi', - version='1.43', + version='1.44', description='simple client for the Spotify Web API', author="@plamere", author_email="paul@echonest.com",