mirror of
https://github.com/spotipy-dev/spotipy.git
synced 2026-10-11 01:10:45 +00:00
Added scope, 'playlist-read-private', to examples that access user playlists using the spotipy api: current_user_playlists() (fixes #591) (#595)
* - Added scope, 'playlist-read-private', to examples that access user playlists using the spotipy api: current_user_playlists() (fixes #591) * Fix example to use user_playlists again Co-authored-by: Stephane Bruckert <stephane.bruckert@gmail.com>
This commit is contained in:
1 parent
bea781d28f
commit
275cd7ea89
4 files changed
+16
-4
No files matched your search
@@ -3,7 +3,8 @@
|
||||
import spotipy
|
||||
from spotipy.oauth2 import SpotifyOAuth
|
||||
|
||||
sp = spotipy.Spotify(auth_manager=SpotifyOAuth())
|
||||
scope = 'playlist-read-private'
|
||||
sp = spotipy.Spotify(auth_manager=SpotifyOAuth(scope=scope))
|
||||
|
||||
results = sp.current_user_playlists(limit=50)
|
||||
for i, item in enumerate(results['items']):
|
||||
|
||||
@@ -1,10 +1,19 @@
|
||||
# Shows a user's playlists (need to be authenticated via oauth)
|
||||
|
||||
import sys
|
||||
import spotipy
|
||||
from spotipy.oauth2 import SpotifyOAuth
|
||||
|
||||
if len(sys.argv) > 1:
|
||||
username = sys.argv[1]
|
||||
else:
|
||||
print("Whoops, need a username!")
|
||||
print("usage: python user_playlists.py [username]")
|
||||
sys.exit()
|
||||
|
||||
sp = spotipy.Spotify(auth_manager=SpotifyOAuth())
|
||||
playlists = sp.current_user_playlists()
|
||||
|
||||
playlists = sp.user_playlists(username)
|
||||
|
||||
for playlist in playlists['items']:
|
||||
print(playlist['name'])
|
||||
print(playlist['name'])
|
||||
@@ -13,7 +13,8 @@ def show_tracks(results):
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
sp = spotipy.Spotify(auth_manager=SpotifyOAuth())
|
||||
scope = 'playlist-read-private'
|
||||
sp = spotipy.Spotify(auth_manager=SpotifyOAuth(scope=scope))
|
||||
|
||||
playlists = sp.current_user_playlists()
|
||||
user_id = sp.me()['id']
|
||||
|
||||
Reference in new issue
Block a user