2014-10-25 10:40:51 +00:00
|
|
|
# shows artist info for a URN or URL
|
|
|
|
|
|
|
|
import spotipy
|
|
|
|
import sys
|
|
|
|
import pprint
|
|
|
|
import spotipy.util as util
|
|
|
|
|
|
|
|
if len(sys.argv) > 1:
|
|
|
|
username = sys.argv[1]
|
|
|
|
else:
|
2015-06-05 09:07:28 +00:00
|
|
|
print("Whoops, need your username!")
|
|
|
|
print("usage: python new_releases.py [username]")
|
2014-10-25 10:40:51 +00:00
|
|
|
sys.exit()
|
|
|
|
|
|
|
|
token = util.prompt_for_user_token(username)
|
|
|
|
|
|
|
|
if token:
|
|
|
|
sp = spotipy.Spotify(auth=token)
|
|
|
|
|
|
|
|
response = sp.new_releases()
|
|
|
|
|
|
|
|
while response:
|
|
|
|
albums = response['albums']
|
|
|
|
for i, item in enumerate(albums['items']):
|
2015-06-05 09:07:28 +00:00
|
|
|
print(albums['offset'] + i,item['name'])
|
2014-10-25 10:40:51 +00:00
|
|
|
|
|
|
|
if albums['next']:
|
|
|
|
response = sp.next(albums)
|
|
|
|
else:
|
|
|
|
response = None
|
|
|
|
else:
|
2015-06-05 09:07:28 +00:00
|
|
|
print("Can't get token for", username)
|