mirror of
https://github.com/spotipy-dev/spotipy.git
synced 2026-06-19 09:13:53 +00:00
* Add python_requires to help pip * Update supported versions in tox.ini * Upgrade Python syntax with pyupgrade --py37-plus * Bump GitHub Actions * Add Python 3.11 and 3.12 to CI * Remove six dependency * Remove redundant dependencies * Remove redudant Python 3.5 code * Drop support for EOL Python 3.7 * Upgrade Python syntax with pyupgrade --py38-plus * Update CHANGELOG * More f-strings --------- Co-authored-by: Hugo van Kemenade <hugovk@users.noreply.github.com>
22 lines
461 B
Python
22 lines
461 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(f"Usage: {sys.argv[0]} playlist_id track_id ...")
|
|
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)
|