2014-07-03 10:36:36 +00:00
|
|
|
'''
|
|
|
|
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()
|
2015-06-05 09:07:28 +00:00
|
|
|
for start in range(0, len(tids), max_tracks_per_call):
|
2014-07-03 10:36:36 +00:00
|
|
|
results = sp.tracks(tids[start: start + max_tracks_per_call])
|
|
|
|
for track in results['tracks']:
|
2015-06-05 09:07:28 +00:00
|
|
|
print(track['name'] + ' - ' + track['artists'][0]['name'])
|
2014-07-03 10:36:36 +00:00
|
|
|
|
|
|
|
|
|
|
|
|