forked from MediaBrowser/plugin.video.emby
-
-
Notifications
You must be signed in to change notification settings - Fork 77
How to automatically delete playlists
croneter edited this page Dec 23, 2018
·
19 revisions
If you've been testing PKC thoroughly, it's possible that you unintentionally put PKC in a state where it kept spawning playlists on both the Plex and Kodi side. Using Plex Web, you'll see potentially hundreds to thousands of playlists listed, all of them ending in a digit like _15
.
- Exit EVERY Kodi instance that has PKC up and running
- For every Kodi instance with PKC, delete the
Database
folder in the Kodi userdata folder. Also do this for all the Kodi profiles in theprofiles
folder, if you're using different Kodi users - Also delete the
playlists
folder of the userdata folder and also do this for all profiles - Using Plex Web, navigate to a single movie or show's information page. Hit the three dots
...
at the top right, thenShow Information
, thenShow XML-file
. A new browser window opens - The URL of the new browser window will be something like this:
https://82-123-96-251.7923ljfse892382.plex.direct:34698/library/metadata/12345?checkFiles=1&includeExtras=1&includeBandwidths=1&X-Plex-Token=alkjb84klafj83
For the script below, you'll need to copy-paste the following information:
- PMS address: in the example above,
https://82-123-96-251.7923ljfse892382.plex.direct
- PMS port: in the example above,
34698
- Your PMS token (don't share that with anyone!!): the string directly after the
X-Plex-Token=
, in the example abovealkjb84klafj83
- Using Plex Web, navigate into the very first playlist that is listed. The browser window's URL will be something like this:
https://82-123-96-251.7923ljfse892382.plex.direct:34698/playlists/682194?<potentially-more-stuff>
- Copy the playlist ID from the URL, in the example above
682194
WARNING: All playlists with an ID higher than the one noted above (682194
) will be deleted.
Run the following Python script on any machine with network/internet access to your PMS. Both Python 2 and Python 3 will work. Replace the values with the ones you retrieved using the steps above.
import requests
import threading
import Queue
import time
# Copy-paste the details of your PMS here!
PMS_ADDRESS = 'https://82-123-96-251.7923ljfse892382.plex.direct'
PMS_PORT = 34698
PMS_TOKEN = 'alkjb84klafj83'
# Make sure that APPROXIMATE_NUMBER_OF_PLAYLISTS is high enough
FIRST_PLAYLIST_ID = 682194
APPROXIMATE_NUMBER_OF_PLAYLISTS = 500
# Advanced settings if you want more threads concurrently
NUMBER_OF_THREADS = 30
class MyThread(threading.Thread):
def __init__(self, queue, args):
self.queue = queue
self.args = args
threading.Thread.__init__(self)
def run(self):
while True:
try:
target = self.queue.get(block=False)
except Queue.Empty:
time.sleep(0.05)
else:
r = requests.delete(target, params=self.args)
print(r.status_code)
URL = '%s:%s/playlists' % (PMS_ADDRESS, PMS_PORT)
URL += '/%s'
ARGS = {
'X-Plex-Token': PMS_TOKEN
}
QUEUE = Queue.Queue()
for i in range(FIRST_PLAYLIST_ID,
FIRST_PLAYLIST_ID + APPROXIMATE_NUMBER_OF_PLAYLISTS + 1):
QUEUE.put(URL % i)
for i in range(0, NUMBER_OF_THREADS):
t = MyThread(QUEUE, ARGS)
t.daemon = True
t.start()
print('Waiting to finish...')
QUEUE.join()
print('Done...')
Devs: croneter
- Screenshots
- Direct Paths Explained
- Set-up Direct Paths
- Direct Play
- Skins and Video Nodes
- Multiple users
- Multiple Plex Media Servers
- Manage additional Media without Plex
- Is PKC a hack
- FAQ
- Report a Bug
- How to uninstall PKC
- How to automatically delete playlists
- Update PKC Repository to receive automatic updates