spotipy/examples/remove_tracks_from_playlist.py
jonathan-huston ba01a6aee5
Examples directory updates (#1055)
* Fixed scripts in examples directory that didn't work, deleted any redundant examples.

* Added examples for methods related to audiobooks, shows and episodes

* Updated changelog

---------

Co-authored-by: Stéphane Bruckert <stephane.bruckert@gmail.com>
2025-01-12 14:47:10 +00:00

23 lines
479 B
Python

# Removes tracks from playlist
import pprint
import sys
import spotipy
from spotipy.oauth2 import SpotifyOAuth
if len(sys.argv) > 2:
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_remove_all_occurrences_of_items(
playlist_id, track_ids)
pprint.pprint(results)