Skip to content

Instantly share code, notes, and snippets.

@blacktwin
Created February 3, 2017 20:02
Show Gist options
  • Save blacktwin/45c420cbba4e18aadc8cc5090a67b9d1 to your computer and use it in GitHub Desktop.
Save blacktwin/45c420cbba4e18aadc8cc5090a67b9d1 to your computer and use it in GitHub Desktop.
Delete all playlists from Plex using PlexAPI
"""
Delete all playlists from Plex using PlexAPI
https://github.com/mjs7231/python-plexapi
"""
from plexapi.server import PlexServer
import requests
baseurl = 'http://localhost:32400'
token = 'XXXXXXXX'
plex = PlexServer(baseurl, token)
tmp_lst = []
for playlist in plex.playlists():
tmp = playlist.key
split = tmp.split('/playlists/')
tmp_lst += [split[1]]
for i in tmp_lst:
try:
r = requests.delete('{}/playlists/{}?X-Plex-Token={}'.format(baseurl,i,token))
print(r)
except Exception as e:
print e
@blacktwin
Copy link
Author

Why do you have 180k playlists?.... Nevermind. You need to provide more details other than "doesn't work". What isn't working? What is the error message that you're seeing?

@Maksim-us
Copy link

This is a very old Plex server, and there was an issue a long time ago where Kodi created hundreds of thousands of playlists when you tried to connect it to plex. And the script did work! Sorry, I just had to let it run for several hours.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment