OK I'm finally posting my rewrite of the script. I rewrote the script from the ground up to be more cohesive instead of a lot of different things hacked together. The script will now navigate through the Plex API movies and shows instead of only looking at the Recently Added page. This means that episodes should no longer be missed if a large update is made to the library. It also allows more customization and control of individual shows. I will probably post a new thread with this new version, but I will post it for you guys to test first. I have included most of the updates people have requested in the thread so hopefully everyone is happy and we can prevent fragmentation.
Most of the new options in the script are described in the commented code,but I'll go over the basics. Any line that has a # in the front is a comment and should not be edited.
The general options are the same give your HOST IP, Port, SectionList, Log File. Also for any users with Plex Home and in general it is recommended to use a username/password or a Token for logging in. Token is the recommended way. To generate a Token first fillout the host, port, username and password fields. Then run the script with the --test parameter. A token will be generated form plex.tv and will be printed in the console and log file. You can then paste this token into the script and remove the username and password.
Newly added there is an option to translate a remote Plex server address to a locally mounted address. This will simply replace the beginning part of the file name with the path to the file on the local server. I would recommend running the script on the Plex Server itself, but if that's not possible then this is another option. This will require all of the Plex Media files to be accessible by the local computer.
Now there are default actions that will be used for any show. These default actions can be overridden for shows later. The default actions are similar to PlexAutoDelete and are described in the script.
New options are:
similar_files - this is similar to the delete_similar option, but now it will also move, copy, or delete similar named files depending on the action specified.
cleanup_movie folders - this will search through movie directories and delete folders that are smaller than minimum_folder_size in megabytes.
default_episodes - this will save a certain number of TV Shows in a series, useful if you want to keep a few episodes always available or have episodes to recap before the next season starts.
default_maxDays - this will override the default_episodes setting and delete files that have been stored for too long
There is a new ShowPreferences section. Examples settings are included in the script. It allows you to have custom settings on a per show basis. The show settings in ShowPreferences will override the default settings. You can specify how many episodes to keep, whether to only delete watched episodes, the minimum days to keep, the action to perform, etc. This allows complete customization on TV_Shows. There is not IgnoreShows anymore, but the same thing can be done by setting the action for a show to "keep". The ShowPreferences has a particular format, so it is recommended you copy paste one of the examples and carefully edit the line. Each line in ShowPreferences should end in a comma (,) or you will get format errors.
The script has been tested on Windows and Linux, on python2 and python3. Let me know if there are any issues.
PlexCleaner v1
https://www.dropbox.com/s/39ei1444lwrefut/PlexCleaner.py?dl=0