From 4c3238fb17f8817f74efcd36e30fde3819cff5e7 Mon Sep 17 00:00:00 2001 From: Nathan Coleman Date: Fri, 2 Jun 2017 18:51:59 -0500 Subject: [PATCH] Add playlist description field to create/update examples --- examples/change_playlist_details.py | 10 +++++++--- examples/create_playlist.py | 6 ++++-- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/examples/change_playlist_details.py b/examples/change_playlist_details.py index ac2a7bb..621f5d0 100644 --- a/examples/change_playlist_details.py +++ b/examples/change_playlist_details.py @@ -19,9 +19,13 @@ if len(sys.argv) > 3: if len(sys.argv) > 5: collaborative = sys.argv[5].lower() == 'true' + description = None + if len(sys.argv) > 6: + description = sys.argv[6] + else: - print ("Usage: %s username playlist_id name [public collaborative]" % - (sys.argv[0])) + print ("Usage: %s username playlist_id name [public collaborative " + "description]" % (sys.argv[0])) sys.exit() scope = 'playlist-modify-public playlist-modify-private' @@ -32,7 +36,7 @@ if token: sp.trace = False results = sp.user_playlist_change_details( username, playlist_id, name=name, public=public, - collaborative=collaborative) + collaborative=collaborative, description=description) print results else: print "Can't get token for", username diff --git a/examples/create_playlist.py b/examples/create_playlist.py index aacbac7..efa334d 100644 --- a/examples/create_playlist.py +++ b/examples/create_playlist.py @@ -12,8 +12,9 @@ import spotipy.util as util if len(sys.argv) > 2: username = sys.argv[1] playlist_name = sys.argv[2] + playlist_description = sys.argv[3] else: - print("Usage: %s username playlist-name" % (sys.argv[0],)) + print("Usage: %s username playlist-name playlist-description" % (sys.argv[0],)) sys.exit() token = util.prompt_for_user_token(username) @@ -21,7 +22,8 @@ token = util.prompt_for_user_token(username) if token: sp = spotipy.Spotify(auth=token) sp.trace = False - playlists = sp.user_playlist_create(username, playlist_name) + playlists = sp.user_playlist_create(username, playlist_name, + playlist_description) pprint.pprint(playlists) else: print("Can't get token for", username)