mirror of
https://github.com/spotipy-dev/spotipy.git
synced 2026-06-19 09:13:53 +00:00
31 lines
729 B
Python
31 lines
729 B
Python
# Creates a playlist for a user
|
|
|
|
import pprint
|
|
import sys
|
|
import os
|
|
import subprocess
|
|
|
|
import spotipy
|
|
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 playlist-description" % (sys.argv[0],))
|
|
sys.exit()
|
|
|
|
scope = "playlist-modify-public"
|
|
token = util.prompt_for_user_token(username, scope)
|
|
|
|
if token:
|
|
sp = spotipy.Spotify(auth=token)
|
|
sp.trace = False
|
|
playlists = sp.user_playlist_create(username, playlist_name,
|
|
description=playlist_description)
|
|
pprint.pprint(playlists)
|
|
else:
|
|
print("Can't get token for", username)
|