Project

General

Profile

Working (I think) renaming post processing script for Plex (or XBMC).

Added by Ryan Harter over 10 years ago

I spent the last few days searching around for a good post processing script that would rename the video files for use with Plex (SXXEXX style season and episode numbers). I didn't have any luck finding scripts (I'm surprised there aren't more scripts being shared, unless I'm just missing them) so I decided to write my own.

First I should point out that this script is not extensively tested. I've worked with it manually and had TVHeadend execute it on a few recordings and it's working well, but that could hardly count as extensive testing.

The script itself is super basic right now, it simply uses the SYNOPSIS field of the video metadata to extract the season and episode information. I haven't verified with all recordings, but this seems to contain the appropriate information somewhat reliably.

To use the script:

This script should be installed somewhere on your system. Once I learn a bit more about packaging python apps, this part should get much easier.

The script depends on the pymediainfo package, which you can install with:

sudo pip install pymediainfo

Then just set this script as your Post-processor command in TVHeadend like so:

python /usr/local/bin/rename.py %f /opt/recordings/

Where /usr/local/bin/rename.py is the path to the rename script, and /opt/recordings is the output directory where you'd like your renamed videos written to.

Aside from "Tag files with metadata", which is required, the other recording settings aren't terribly important.

I have no idea how this might work internationally, and it this is even a reliable enough method to work, but it's a start. If you guys have scripts to share, or places I should look for them, I think it would be great to have a resource for working, high quality scripts.

You can check out the source of the script and submit pull requests at: https://github.com/rharter/tvheadend-postproc

rename.py (2.21 KB) rename.py