mirror of
https://github.com/spotipy-dev/spotipy.git
synced 2026-06-19 01:03:53 +00:00
32 lines
837 B
Python
32 lines
837 B
Python
# Creates a playlist for a user
|
|
|
|
import argparse
|
|
import logging
|
|
|
|
import spotipy
|
|
from spotipy.oauth2 import SpotifyOAuth
|
|
|
|
logger = logging.getLogger('examples.create_playlist')
|
|
logging.basicConfig(level='DEBUG')
|
|
|
|
|
|
def get_args():
|
|
parser = argparse.ArgumentParser(description='Creates a playlist for user')
|
|
parser.add_argument('-p', '--playlist', required=True,
|
|
help='Name of Playlist')
|
|
parser.add_argument('-d', '--description', required=False, default='',
|
|
help='Description of Playlist')
|
|
return parser.parse_args()
|
|
|
|
|
|
def main():
|
|
args = get_args()
|
|
scope = "playlist-modify-public"
|
|
sp = spotipy.Spotify(auth_manager=SpotifyOAuth(scope=scope))
|
|
user_id = sp.me()['id']
|
|
sp.user_playlist_create(user_id, args.playlist)
|
|
|
|
|
|
if __name__ == '__main__':
|
|
main()
|