Perl Script to convert shows listed by date to SxxExx format

Come up with a useful post-processing script? Share it here!
Post Reply
Piqued
Newbie
Newbie
Posts: 1
Joined: January 11th, 2011, 3:33 pm

Perl Script to convert shows listed by date to SxxExx format

Post by Piqued »

There is an 2 year old thread on this topic with a somewhat working script, but I wanted to be able to do more with it, so I wrote a perl script to take a file that is listed by date (ex:The.Colbert.Report.2011.01.10.Fen.Montaigne.HDTV.XviD-FQM) and convert it to the SxxExx format (ex: The Colbert Report.S07E05-Fen Montaigne).  NOTE: This is only for Windows.  If there is enough interest for linux/Mac, I may expand it.

I tried to make it easy enough so that you can add your own shows (by default it has The Colbert Report, The Daily Show, Conan, and Real Time with Bill Maher).  It can also support additional date formats other than the standard YYYY-MM-DD, but there probably won't be much use for that.

Instructions:

1. Download Perl, use perl package manager to download Date:Dumper and TVDB:API.  
2. Change the API key for thetvdb (variable $api).  You can get this by registering at www.thetvdb.com.
3. Change the path you want to the files to go in (variable $default_path).  IMPORTANT: Make sure you escape all the necessary characters, such as "\" turns into "\\".  The files will be put in that folder, then a subfolder for the show.  For example, if you set it to "C:\shows\" it would put all Daily Show files into "c:\shows\The Daily Show".  Use the default value as an example.
4. Add or remove files from @extensions_to_omit if you want certain file types to be deleted when the script runs.
5. Add or remove shows from @omitepisodename if you don't want the title of the episode to show up in the new filename.  I added this because it can sometimes confuse programs like Boxee.  For example, it will turn "Conan 2011 01 10 Adam Sandler 720p HDTV x264 BFF" into Conan.S01E29 if you put "Conan (2010)" into the array.
6. Consider the variable $files_in_folder.  If you leave this at 0, it won't put the shows in their own folder.  If you put it at 1, it will.  If you put a bunch of extensions in @extensions_to_omit so that it just leaves the .avi or .mkv (or whatever), you probably want to leave it at 0.  If you like to keep the nfo, nzb, etc files, you probably want them in their own folder, so set to 1.  This is an all or none variable.  Either it does it for all shows, or none.
7. Add additional shows into the hash, %shows, if needed.  Follow the format used.  The hash key is set to the string you want to search for in the file name, where the key value is set to the proper name, as used by www.thetvdb.com.  This is important because the file doesn't always have the same name as the API uses.  For example, the proper name of Conan is "Conan (2010)" because there was a previous show titled Conan, but the files just list the name as Conan.  Therefore, we need to differentiate.  "Conan" => "Conan (2010)".
8. The @dates variable probably isn't necessary, but I added it in case groups start to use a different dating format.
9. Stick in your sabnzbd post processing folder, and set to run for the desired files.  Also, sabnzbd must be run as admin.

There may be little to no interest in this script, but I will support it if there is a need.  If the instructions are unclear or bugs are found, let me know and I will do my best to fix it.

ALSO VERY IMPORTANT!!!!! These forums won't allow me to upload a file with a .pl extension.  You must change the extension to .pl once you download it.

Piqued
Last edited by Piqued on January 11th, 2011, 5:09 pm, edited 1 time in total.
User avatar
JustJv
Newbie
Newbie
Posts: 8
Joined: March 30th, 2010, 8:50 am
Location: Belgium

Re: Perl Script to convert shows listed by date to SxxExx fo

Post by JustJv »

Or you could just use SickBeard ;) http://code.google.com/p/sickbeard/
Post Reply