mirror of
https://github.com/c0de-archive/spotipy.git
synced 2025-01-08 15:42:48 +00:00
Add example for user_playlist_change_details()
This commit is contained in:
parent
5ecfad1d3a
commit
b8ae99a6e6
38
examples/change_playlist_details.py
Normal file
38
examples/change_playlist_details.py
Normal file
@ -0,0 +1,38 @@
|
|||||||
|
|
||||||
|
# Modify the details of a playlist (name, public, collaborative)
|
||||||
|
|
||||||
|
import sys
|
||||||
|
|
||||||
|
import spotipy
|
||||||
|
import spotipy.util as util
|
||||||
|
|
||||||
|
if len(sys.argv) > 3:
|
||||||
|
username = sys.argv[1]
|
||||||
|
playlist_id = sys.argv[2]
|
||||||
|
name = sys.argv[3]
|
||||||
|
|
||||||
|
public = None
|
||||||
|
if len(sys.argv) > 4:
|
||||||
|
public = sys.argv[4].lower() == 'true'
|
||||||
|
|
||||||
|
collaborative = None
|
||||||
|
if len(sys.argv) > 5:
|
||||||
|
collaborative = sys.argv[5].lower() == 'true'
|
||||||
|
|
||||||
|
else:
|
||||||
|
print ("Usage: %s username playlist_id name [public collaborative]" %
|
||||||
|
(sys.argv[0]))
|
||||||
|
sys.exit()
|
||||||
|
|
||||||
|
scope = 'playlist-modify-public playlist-modify-private'
|
||||||
|
token = util.prompt_for_user_token(username, scope)
|
||||||
|
|
||||||
|
if token:
|
||||||
|
sp = spotipy.Spotify(auth=token)
|
||||||
|
sp.trace = False
|
||||||
|
results = sp.user_playlist_change_details(
|
||||||
|
username, playlist_id, name=name, public=public,
|
||||||
|
collaborative=collaborative)
|
||||||
|
print results
|
||||||
|
else:
|
||||||
|
print "Can't get token for", username
|
Loading…
Reference in New Issue
Block a user