Skip to content

Instantly share code, notes, and snippets.

@blacktwin
Created February 3, 2017 20:02
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • 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
@tarnecki
Copy link

tarnecki commented May 23, 2017

can you please add option to delete specific playlists for shared users based on script below?

PLAYLISTS = ['Playlist 1', 'Playlist 2', 'Playlist 3'] # List of playlists to delete
USERS = ['User 1', 'User 2', 'User 3'] # List of users to delete the playlists from

https://gist.github.com/JonnyWong16/2607abf0e3431b6f133861bbe1bb694e

@DennisFury
Copy link

I know this is years late, but here's a quicker way..

delete everything after line 13 and replace it with..

for i in plex.playlists():
    requests.delete(baseurl + i.key + '?X-Plex-Token=' + token)

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