AutoDelete.py - (Auto Delete Watched Shows) Script
Disclaimer:
Disclaimer:
*** USE AT YOUR OWN RISK I WILL NOT BE HELD RESPONSIBLE FOR ANYTHING BAD THAT HAPPENS *** Also Note: I'm New To Python. So Please Ignore The Messy Code. I'll Get Around to Cleaning It Up Later...What it is it and What Does It Do?
This is a Script I Wrote In Python. This Script is used to look for TV Shows That have been marked as "WATCHED". It will then find the "Watched" file and DELETE it to save you some hard drive space and clutter. - Tested on Ubuntu 12.04 Linux Server using Python 2.7.3 - Tested on Windows 8 Ultimate (64-Bit) using Python 3.3.2Configuring:
Also Briefly Described in The Top Portion Of The AutoDelete.py If Plex Was Installed with all the default settings, you do need to configure ANYTHING. You may need to adjust the "Section" Variable if you have multiple librarys like TV Shows, Movies, Audio, Etc You may want to adjust the "Shows" Variable if you have Shows, Movies, Audio, That You Don't Want Delete (Verifies Against Full File Path). If you want to save the OnDeck Shows from being Deleted, Set "OnDeck" = "1";Understanding the Configuration:
http : // <IP>:<PORT>/library/sections/<SECTION>/recenlyViewed <IP> = IP Address or Host name of the Server (You can also use 127.0.0.1 for localhost) <PORT> = Port For Plex Web Server (Default is 32400) <SECTION> = KEY for the Section You Want This Script To Look At **You can See what Sections are Available by going to: http : // 192.168.X.X:32400/library/sections/ Looking at the TITLE= and the associated KEY= It Is Using the XML Data Provided By Your Plex Web Server. The Number "1" might vary for you. For my new plex server I have only setup tv shows (no movies section yet) so since I created tv shows first it was given the index of 1. On my old plex server (windows) I setup tv shows second so it was given the index of 2. Easy way to tell whats what... Go to the URL and see if the data you are looking at is TV shows or whatever content you are wishing to remove.Notes:
Delete = "" Noting will be deleted - Safe for Review and Testing Delete = "1" Your files will be deleted... Please Don't CryLinux Users (Ubuntu):
sudo apt-get -y install python nano (typically skip this step it should already be installed) python -V (CAPITAL V - Check the Version - I use 2.7.3) touch AutoDelete.py chmod +x AutoDelete.py nano AutoDelete.py (OR YOUR FAVORITE TEXT EDITOR) Copy & Paste Contents PRESS: (CTRL + X) answer YES to Save and WriteOut the file) To run it: ./AutoDelete.py Or Dump It To A Log File: ./AutoDelete.py >> AutoDelete.log note the period then then slash followed by the file name. Then you'll need to setup a schedule task using cronjob (google it, if you really need help then ask).Windows User:
Download and Install Python: http://www.python.org/download/releases/3.3.2/ Windows x86 MSI Installer (3.3.2) (sig) and Visual Studio debug information files (sig) or Windows X86-64 MSI Installer (3.3.2) [1] (sig) and Visual Studio debug information files (sig) Note its installation location: Mine Was: C:\Python33 CREATE A BAT FIle using Notepad or whatever.. AutoDelete.BAT SET PythonEXE="C:\Python33\Python.exe" SET AutoDelete="C:\Python33\AutoDelete.py" SET LOGFILE=C:\Python33\AutoDelete.log" %PythonEXE% %AutoDelete%>>%LOGFILE% Then get your AutoDelete.py script and put in the location and modify the 3 above variables accordingly. I recommended a bat file as it easiest to use when setting up a scheduled task.Code for AutoDelete.py:
SECOND POST