Wednesday, 2 April 2014

SortTV - Sorting Movies

A application that can automatically sorts TV show episodes into an organised
directory structure. Can optionally move non-episodes into a separate directory. Also optional integration with xbmc (notification and library update).

Project located at : http://sourceforge.net/projects/sorttv/ at the time of writing the latest version was SortTV1.37

Download and extract the files and edit the configuration file (sorttv.conf)

most important values to set:
  • directory-to-sort=
  • tv-directory=
  • music-directory=
  • movie-directory=

and execute with perl;
perl sorttv.pl  or ./sorttv.pl

If you experience some errors it will be most likely perl libraries that are missing these can be installed with:

sudo apt-get install libwww-perl  
sudo perl -MCPAN -e 'install TVDB::API'  
sudo perl -MCPAN -e 'install WWW::TheMovieDB::Search'  
sudo perl -MCPAN -e 'install WWW::TheMovieDB'  
sudo perl -MCPAN -e 'install JSON::Parse'  

Titles can be substituted in the configuration file (sorttv.conf)

# Substitute the titles of these shows
show-name-substitute=CSI-->CSI: Crime Scene Investigation
show-name-substitute=CSI Crime Scene Investigation-->CSI: Crime Scene Investigation
show-name-substitute=Sanctuary US-->Sanctuary
show-name-substitute=Shit My Dad Says-->$#*! My Dad Says
show-name-substitute=ABC - Two and a Half Men-->Two and a Half Men
show-name-substitute=Its Always Sunny in Philadelphia-->It's Always Sunny in Philadelphia
show-name-substitute=American Dad-->American Dad!
show-name-substitute=Penn & Teller Bullshit!-->Penn & Teller: Bullshit!
show-name-substitute=Being Human UK-->Being Human
show-name-substitute=House MD-->House
show-name-substitute=House M.D.-->House
show-name-substitute=Game of Throne-->Game of Thrones
show-name-substitute=Star Trek DS9-->Star Trek Deep Space 9
show-name-substitute=Marvels Agents of S H I E L D -->Marvels Agents of S.H.I.E.L.D.

Spesific TVDB id's can be manually entered in the configuration file as well, for series that is incorrectly identified e.g.

# Use these tvdb IDs to lookup these shows
tvdb-id-substitute=$#*! My Dad Says-->164951
tvdb-id-substitute=$#-! My Dad Says-->164951
tvdb-id-substitute=Shit My Dad Says-->164951
tvdb-id-substitute:Brothers and Sisters-->79506
tvdb-id-substitute:Greys Anatomy-->73762
tvdb-id-substitute:David Letterman-->75088
tvdb-id-substitute:The Daily Show-->71256
tvdb-id-substitute:Conan-->194751
tvdb-id-substitute:Jay Leno-->70336
tvdb-id-substitute:Dont Trust the Bitch in Apartment 23-->248812
tvdb-id-substitute:True Detective-->270633
tvdb-id-substitute:The Tomorrow People US-->268591
tvdb-id-substitute:The Tomorrow People (US)-->268591
tvdb-id-substitute:Once Upon A Time-->248835
tvdb-id-substitute:Scandal-->248841

To make this task easier in ubuntu a Nautilus script can be created to add the sorttv command to the context menu (Right click > scripts)

Paste the following code into
~/.local/share/nautilus/scripts

or
right click > scripts > open scripts folder

then add the following code to a file and name it something that make sense e.g. Sorttv-Organiser
#!/bin/bash
notify-send "SortTV" "Script started to sort  " -i ~/Pictures/sorttv.png -t 500
/opt/applications/sorttv/sorttv.pl
notify-send "SortTV" "Script completed " -i ~/Pictures/sorttv.png -t 5000

in this example
notify-send is used to send a notification to the desktop and
/opt/applications/sorttv/ the location of sorttv application

Whenever you want to sort just right click in Nautilus and run the script