mirror of
https://github.com/spotipy-dev/spotipy.git
synced 2026-06-19 17:23:53 +00:00
* Made cache_path and username optional * Update readme and example * Lint * Lint * Feedback / add warning
22 lines
466 B
Python
22 lines
466 B
Python
# Replaces all tracks in a playlist
|
|
|
|
import pprint
|
|
import sys
|
|
|
|
import spotipy
|
|
from spotipy.oauth2 import SpotifyOAuth
|
|
|
|
if len(sys.argv) > 3:
|
|
playlist_id = sys.argv[1]
|
|
track_ids = sys.argv[2:]
|
|
else:
|
|
print("Usage: %s playlist_id track_id ..." % (sys.argv[0],))
|
|
sys.exit()
|
|
|
|
scope = 'playlist-modify-public'
|
|
|
|
sp = spotipy.Spotify(auth_manager=SpotifyOAuth(scope=scope))
|
|
|
|
results = sp.playlist_replace_items(playlist_id, track_ids)
|
|
pprint.pprint(results)
|