mirror of
https://github.com/c0de-archive/spotipy.git
synced 2025-07-30 14:00:18 +00:00
Added support for new_releases and featured_playlists endpoints.
This commit is contained in:
33
examples/show_featured_playlists.py
Normal file
33
examples/show_featured_playlists.py
Normal file
@@ -0,0 +1,33 @@
|
||||
# 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:
|
||||
print "Whoops, need your username!"
|
||||
print "usage: python featured_playlists.py [username]"
|
||||
sys.exit()
|
||||
|
||||
token = util.prompt_for_user_token(username)
|
||||
|
||||
if token:
|
||||
sp = spotipy.Spotify(auth=token)
|
||||
|
||||
response = sp.featured_playlists()
|
||||
print response['message']
|
||||
|
||||
while response:
|
||||
playlists = response['playlists']
|
||||
for i, item in enumerate(playlists['items']):
|
||||
print playlists['offset'] + i, item['name']
|
||||
|
||||
if playlists['next']:
|
||||
response = sp.next(playlists)
|
||||
else:
|
||||
response = None
|
||||
else:
|
||||
print "Can't get token for", username
|
32
examples/show_new_releases.py
Normal file
32
examples/show_new_releases.py
Normal file
@@ -0,0 +1,32 @@
|
||||
# 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:
|
||||
print "Whoops, need your username!"
|
||||
print "usage: python new_releases.py [username]"
|
||||
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']):
|
||||
print albums['offset'] + i,item['name']
|
||||
|
||||
if albums['next']:
|
||||
response = sp.next(albums)
|
||||
else:
|
||||
response = None
|
||||
else:
|
||||
print "Can't get token for", username
|
Reference in New Issue
Block a user