mirror of
https://github.com/spotipy-dev/spotipy.git
synced 2026-06-19 09:13:53 +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:
parent
bea781d28f
commit
275cd7ea89
@ -11,6 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
### Fixed
|
### Fixed
|
||||||
- playlist_tracks example code no longer prints extra characters on final loop iteration
|
- playlist_tracks example code no longer prints extra characters on final loop iteration
|
||||||
- SpotifyException now thrown when a request fails & has no response ( fixes #571, #581 )
|
- SpotifyException now thrown when a request fails & has no response ( fixes #571, #581 )
|
||||||
|
- Added scope, 'playlist-read-private', to examples that access user playlists using the spotipy api: current_user_playlists() (fixes #591)
|
||||||
|
|
||||||
### Changed
|
### Changed
|
||||||
|
|
||||||
|
|||||||
@ -3,7 +3,8 @@
|
|||||||
import spotipy
|
import spotipy
|
||||||
from spotipy.oauth2 import SpotifyOAuth
|
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)
|
results = sp.current_user_playlists(limit=50)
|
||||||
for i, item in enumerate(results['items']):
|
for i, item in enumerate(results['items']):
|
||||||
|
|||||||
@ -1,10 +1,19 @@
|
|||||||
# Shows a user's playlists (need to be authenticated via oauth)
|
# Shows a user's playlists (need to be authenticated via oauth)
|
||||||
|
|
||||||
|
import sys
|
||||||
import spotipy
|
import spotipy
|
||||||
from spotipy.oauth2 import SpotifyOAuth
|
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())
|
sp = spotipy.Spotify(auth_manager=SpotifyOAuth())
|
||||||
playlists = sp.current_user_playlists()
|
|
||||||
|
playlists = sp.user_playlists(username)
|
||||||
|
|
||||||
for playlist in playlists['items']:
|
for playlist in playlists['items']:
|
||||||
print(playlist['name'])
|
print(playlist['name'])
|
||||||
@ -13,7 +13,8 @@ def show_tracks(results):
|
|||||||
|
|
||||||
|
|
||||||
if __name__ == '__main__':
|
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()
|
playlists = sp.current_user_playlists()
|
||||||
user_id = sp.me()['id']
|
user_id = sp.me()['id']
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user