mirror of
https://github.com/spotipy-dev/spotipy.git
synced 2026-06-19 09:13:53 +00:00
* Update playlist endpoints to modern format Deprecate user_playlist_* in favor of the following replacements: * user_playlist_change_details -> playlist_change_details * user_playlist_unfollow -> current_user_unfollow_playlist * user_playlist_add_tracks -> playlist_add_tracks * user_playlist_replace_tracks -> playlist_replace_tracks * user_playlist_reorder_tracks -> playlist_reorder_tracks * user_playlist_remove_all_occurrences_of_tracks -> playlist_remove_all_occurrences_of_tracks * user_playlist_remove_specific_occurrences_of_tracks -> playlist_remove_specific_occurrences_of_tracks * user_playlist_follow_playlist -> current_user_follow_playlist * user_playlist_is_following -> playlist_is_following * Add current_user_following_artists and current_user_following_users * Update tests and examples Resolve TODO in test_user_endpoints.py > SpotifyFollowApiTests.test_user_follows_and_unfollows_user Use modern playlist endpoints (no username required) in tests and examples. * Update changelog * Deprecate playlist_tracks in favor of playlist_items * Link deprecated functions to new functions and change tracks to items * Fix references to playlist_tracks * Change test_playlist_add_items as requested
22 lines
475 B
Python
22 lines
475 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 username 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)
|