Skip to content

Instantly share code, notes, and snippets.

@Stormix
Created January 19, 2022 19:19
Show Gist options
  • Save Stormix/41fe93b271e1ed1fda273c8135afeed0 to your computer and use it in GitHub Desktop.
Save Stormix/41fe93b271e1ed1fda273c8135afeed0 to your computer and use it in GitHub Desktop.
Make all playlist private on spotify
SPOTIPY_CLIENT_ID=''
SPOTIPY_CLIENT_SECRET=''
SPOTIPY_REDIRECT_URI='http://localhost'
import spotipy
from dotenv import load_dotenv
load_dotenv()
import spotipy
from spotipy.oauth2 import SpotifyOAuth
scope = "user-read-private user-read-email user-library-read playlist-modify-public playlist-modify-private playlist-read-private"
sp = spotipy.Spotify(auth_manager=SpotifyOAuth(scope=scope))
playlists = sp.current_user_playlists()
while playlists:
for idx, playlist in enumerate(playlists['items']):
if playlist['owner']['id'] == sp.current_user()['id']:
print("Changing: ", idx, playlist['name'], "to: Private")
sp.playlist_change_details(playlist['id'], playlist['name'], False)
if playlists['next']:
playlists = sp.next(playlists)
else:
playlists = None
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment