I previously used the emptyTrash webcall to schedule an emptyTrash process to avoid it running when my NAS was disconnected. This was whilst running on Windows.
I have since moved Plex to Docker and want to reinstate this behaviour.
I have a strange situation.
This works; http://“ip”:32400/library/sections/1/refresh?X-Plex-Token=“token”
This does not work; http://“ip”:32400/library/sections/1/emptyTrash?X-Plex-Token=“token”
I was using curl and PUT in my .sh script, but was trying to test the validity of the url by using my web browser.
The original request actually still works when i use it in the script.
This is my script for anyone interested
#!/bin/bash
# Empty Libraries
# Forces all the Plex libraries to empty their trash
# Each of the libraries you wish to empty separated by a space. To find
# the IDs hover the mouse over the library in Plex Web and look for the
# bit in at the end of the URL which is source=XX - with XX being the ID
libraries="1 2 3 4"
# The URL required to access Plex. Use 127.0.0.1 to mean "the same machine"
url="http://xxx.xxx.x.xxx:32400"
# Your Plex token, which can be found with the following instructions
# https://support.plex.tv/articles/204059436-finding-an-authentication-token-x-plex-token/
token="<token>"
# ----- Code starts here -----
for l in $libraries; do
if [ -d "/synology/video/Shared Videos/PlexServer/Scripts" ]
then
echo "Emptying library ID $l"
curl -X PUT "$url/library/sections/$l/emptyTrash?X-Plex-Token=$token"
else
echo "Error: Directory does not exist"
fi
done
echo "Finished"