From c3b28f626c421ba1b704d95ff992df1c0357a9a7 Mon Sep 17 00:00:00 2001
From: blacktwin <blacktwin@users.noreply.github.com>
Date: Wed, 12 Jul 2017 14:16:19 -0400
Subject: [PATCH] Create plexapi_delete_playlists.py

https://gist.github.com/blacktwin/45c420cbba4e18aadc8cc5090a67b9d1
---
 plexapi_delete_playlists.py | 28 ++++++++++++++++++++++++++++
 1 file changed, 28 insertions(+)
 create mode 100644 plexapi_delete_playlists.py

diff --git a/plexapi_delete_playlists.py b/plexapi_delete_playlists.py
new file mode 100644
index 0000000..8cc5da8
--- /dev/null
+++ b/plexapi_delete_playlists.py
@@ -0,0 +1,28 @@
+"""
+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