• 1
  • 32
  • 33
  • 34(current)
  • 35
  • 36
  • 49
SortTV: Sort TV episodes, movies, and music into directories for xbmc (Linux/Win/Mac)
(2012-03-30, 15:06)greeneca Wrote: Hello all,

love this script, always hated sorting my shows manually. I have one, hopefully small, feature request. I am doing the initial sort of my shows and movies dir. the shows went fairly well, one or two small easy fixes, but the script only picked up half to two thirds of my movies. looking at the verbose output i found that this was because it was matching the file to 2 or more movies. I would suggest adding a argument to allow manual selection of the movie from the list of matched movies. I hope this isn't already a feature that I missed. I looked through the help and through many of the forum posts and found nothing. I have not looked at the code yet but will see if is something that I could figure out my self.

Could you please provide an example of a file name that triggers this behaviour?
Reply
Smile 
Version 1.33 of SortTV is now available.

Included in this release:
  • File extensions are now considered more extensively during the sort process, so by default SortTV will only consider appropriate files for candidates as TV episodes and movies. Rather than simply trying to regex match/lookup any file.
    --consider-media-file-extensions=[TRUE|FALSE]
    Consider the file extension before treating certain files as movies or TV episodes
    Recommended: SortTV is aware of a large number of extensions, and this can avoid many false matches
    if not specified, TRUE
  • --non-media-extension=pattern
    These extensions are NEVER movies or TV shows or music, treat them as "others" automatically
    Note: Will not run these file types through tvdb, tmdb, etc.
    Not typically required if consider-media-file-extensions=TRUE
    This argument can be repeated to add multiple extensions
  • --sort-movie-directories=[TRUE|FALSE]
    Attempt to sort entire directories that represent a movie
    The directory (and all its contents AS IS) will be sorted
    Note: Currently, this option WILL NOT rename or sort ANY of the contents of the directory,
    including the movie. The directory will just be sorted into the movie-directory.
    If not specified, FALSE
    This is similar to --treat-directories=AS_FILES_TO_SORT, except that it can apply to any directory.
  • TV Images are no longer downloaded on Windows, this has never worked properly on Windows (due to the module used), so to avoid confusion it shouldn't happen anymore.
  • Movie image download now names images in ways more compatible with xbmc skins (movie.tbn, folder.jpg, fanart.jpg, etc). This includes symlinking where appropriate, and naming images differently depending on whether the movie is going into its own directory.
  • A new testing script "other_scripts/sorttv-tests.pl", this script runs SortTV and conducts a number of tests (>70) to ensure that features are operating correctly. This is primarily for development purposes, although it will also help you to see if SortTV is working in Windows and Mac (I develop and test on Linux). Please report any problems not marked as "(expected to fail on Windows)".
  • Various bug fixes and improvements including
    • Wont delete files on a dry run
    • UTF8 encoding improvements
    • Intelligently handle slashes in movie and TV names
    • Major refactoring of some existing code
    • Various README and output updates: for example "/" is described as a valid format string for movie names (SortTV can automatically put movies in their own subdirectories), a FAQ has been added, and some features are better documented
    • File size border values fix (0MB-10MB now includes 0 and 10 as valid values)
    • Movie files can now be sorted without renaming them
    • Extraction errors
    • Config updates: substitution and ignore settings

Thanks to everyone who submitted code and/or suggestions.

You can get the new version here:
https://sourceforge.net/projects/sorttv/files/

Enjoy!

(2012-04-18, 19:31)frozenesper Wrote: I found SortTV a few weeks ago and I love it! If you don't mind, I may have some bugfixes for issues with the 1.32 release. (I don't know perl, but I have some programming experience.)
  • In the sub escape_myfilename, line 1036 should have "\/' added to it, so the whole line should read:
    Code:
            $name =~ s/[\/:*?\"<>|]/-/g;
    This makes it properly sort of a movie like Frost/Nixon as the file Frost-Nixon rather than the file Nixon in the folder Frost.
  • A weird issue with TheMovieDB search. I kept getting occasional wide character errors (similar to some seen earlier in the thread) until I added a line to encode the result of the Movie_search:
    Code:
        my $result = $tmdb->Movie_search(remdot($title));
        $result = Encode::encode("utf8", $result);
    I honestly have no idea what this does, but it seems to have solved my intermittent issues. I decided to try different combinations of encoding and decoding after I did some searching about wide character issues.

I also had some issues with how the movie search works:

Currently: As far as I can tell, after looking for series/season folders, individual episodes by season and ep, and finally episodes by name/date, the sorter treats all remaining (nonep) files as movies. The movie search acts as a fall through for any unknown file.

Problem: That leads to really heavy usage of TheMovideDB api and a lot of noise in the movie folder. (Especially if you're running sorttv often on cron.) For example: I had a zipped android rom in my sort directory that contained hundreds of files. I later found a ton of movies like Core (2010).jar and Network (1976).conf and a really long sorttv.log file.

Workaround: I replaced my current whitelist with common video and subtitle extensions (*.avi, *.m4v, *.mkv, *.mov, *.mp4, *.mpg, *.mpeg, *.ogm, *.wmv, *.divx, *.dvr-ms, *.3gp, *.ssa, *.srt, *.sub) and that pretty much did the trick. This stops me from extracting zip files or sorting audio, but that's fine with me.

I'm not really sure what kind of general solution there is for this, but one possibility might be to include video-file-ext and audio-file-ext conf variables that would stop the sorter if no matching extension is found. (This would have to take place after the extraction step for zip files.)

Thanks, I have incorporated some of your suggestions incl. utf8 encoding into this release.

(2012-06-04, 16:52)Fox Wrote: Cliffe I found a new error code, if winrar runs into a CRC it returns 768.

You probably know this already but the delete part seems to be a bit on its own. If you run a dry-run it still delete the files and also if you catch an error with in the extraction part it doesn't cancel the delete.

/Fox

Thanks. Both of these have been incorporated into this release.

(2012-07-05, 21:06)verysoftpaper Wrote: oh, yes,, I had to alter the mask to ignore=*sample* though..

Any way if deleting the containing folders when tvshows and movies are successfully extracted from?

I end up with a bunch o empty folders.. in the root. I wouldn't mind to moving the entire folders, but it failed to recognized a season folder and sent it to the "others" category..

I have updated the ignore string for samples in this release. SortTV should delete empty directories.

(2012-03-31, 07:17)agentxan Wrote: I was upgrading some older shows to HD versions and had a problem sorting one episode. I am assuming the problem is the / in the episode title.

This has been fixed in this release.

(2012-06-13, 04:32)deranjer Wrote: I have edited sorttv.pl to add the following options you can set in the sorttv.conf file:

Code:
#OPTIONAL - These extensions are NOT movies or TV shows or music, treat them as non episodes/Movies automatically
#Note: Will not run these file types through tvdb, etc.
#non-media-ext=smc,pdf,mobi,jpg,exe

# OPTIONAL - The movie-in-folder setting tells sorttv that if if finds a movie file to move it to the movie directory,
# but create a folder in the movie directory for the movie, named after the movie.
# For example, it would name a movie "The Bourne Identity - 2002.avi" and then create a folder in the movie directory
# and place the movie in it like so: "The Bourne Identity - 2002\The Bourne Identity - 2002.avi".
# If not specified, FALSE
movie-in-folder=FALSE

# OPTIONAL - The movie-move-folder setting tells sorttv that if it finds a FOLDER that matches a movie directory name (not TV)
# then sorttv will rename and move the folder (AND ALL CONTENTS) into the movie directory wholesale.
# Note: Currently, this option WILL NOT rename or sort ANY of the contents of the folder, including the movie.
# If not specified=FALSE
movie-move-folder=FALSE

I have tested this as best I could on linux (this is not tested on Windows), and it seems to work okay. I am not good at programming perl, so I'm sure I did this the long way, and perhaps did some things wrong. I will submit this to the original author as well, see if he is interested it looking it over and integrating it/optimizing it.

You can download the modified script below:

Download

Thanks. I incorporated some of your code and suggestions into this release.
Reply
(2012-07-08, 13:47)cliffe Wrote:
(2012-06-30, 15:01)DoubleDroz Wrote: Also - I'm not sure if this has been mentioned before, but the script runs brilliantly on OS X once the CLI developer tools have been downloaded and installed.

Tested on Lion 10.7.4

Thanks. That is good to know. I have noticed that a number of Mac users have been downloading SortTV, so it is nice to hear that it works Smile The next release includes a test script for SortTV. I will be interested to know how Mac OS X goes with that. I have updated the README mentioning Mac OS X, let me know if there are any install instructions that could be improved.

Also, I would love for a Windows user of SortTV to create a set of step by step instructions for those with less experience with such things. Would anyone like to volunteer?
Reply
Absolutely love the script. Quick question, and I apologize if this has been addressed already: it seems many of the movies I'm processing via SortTV are unmatched/go unprocessed due to a mismatch in release year. I can see how this would be useful in matching, say, the modern version of True Grit (2010) vs True Grit (1969). I've found that in many instances, however, the scene release / title of the file will indicate, say, 2007, and the SortTV lookup will return the actual year of 2006, off by 1.

SortTV will declare this a mismatch and not process the file, when in reality it's definitely a match.

Clearly I'm nitpicking an already amazing script...but it would be great if there was an ability to specify a margin of error. I'd much rather SortTV make a best-guess match and process the file, instead of not processing the file at all (please let me know if I'm missing a config option or something).

Thanks again!
Reply
I register at this forum just to thanks Z. Cliffe about this wonderfull software

I'm glad I have the knowledge to install and make it work from command line and config file. Its not much but I was able to do it.
Using ubuntu 10.04

Some question:

Movies: the file extensions were gone, is this correct?
example:
Born to Be Wild (2011) -- this is the actual name of the movie file. no .mkv or .mp4

I've noticed that some videos were moved with the subtitle (srt), others dont.

Thanks
Reply
Great script! not a fan of perl as a language but the amount of regex and matching makes sense to use perl.

anyways, I am running windows 7 64 bit and cannot install WWW::TheMovieDB::Search and this site: suggests it does not support windows anyways. http://code.activestate.com/ppm/WWW-TheMovieDB-Search/

the solution is to comment line 54 : # use WWW::TheMovieDB::Search; note that the movie aspect of this script has to be disabled for this to work.

Cliffe, may i edit the script to work with utorrent better for my personal use? Essentially, utorrent has the ability to run a script after a torrent changes state. I am simply passing the state as an argument and the path of the file to be sorted.

I'd be willing to help out with the tutorial for windows user as long as I am correct in saying the movie aspect of this script does not work on a windows machine with active perl due to the module not supporting windows. Is WWW::TheMovieDB::Search different to TMDB or WWW::TMDB::API? Windows also has access to IMDB api... I am quite busy at the moment but i dont mind spending a day exploring the api to see if i can replace for myself and see if it works.


again thanks for the work Smile

Reply
hello. Is there any way to prevent sorttv to take out the file extension from the videos?

The problem is that when I run it, I have to remember what movies were at the original folder and then go to the respective folder (tv or movies) and then find the movie and change the file name in order to get the extension back

My computer can play the files with no extension, but XBMC does not recognize them as video files and they dont show up at the movies/tv list.

regards

Reply
(2012-07-17, 15:26)ozp1 Wrote: hello. Is there any way to prevent sorttv to take out the file extension from the videos?

The problem is that when I run it, I have to remember what movies were at the original folder and then go to the respective folder (tv or movies) and then find the movie and change the file name in order to get the extension back

My computer can play the files with no extension, but XBMC does not recognize them as video files and they dont show up at the movies/tv list.

regards
you could try changing the config file so that sorttv does not rename the file at all.
Reply
Do you mean here?

Code:
# ~~~~~~~~~~~~~
# File renaming
# ~~~~~~~~~~~~~

# OPTIONAL - rename media to a new format when moving
# TRUE/FALSE
# If not specified, FALSE
rename-media=TRUE

But if I do dhis I will loose some great function of the script.
I wonder if this rename feature always remove the file extension or not?
Reply
(2012-07-17, 18:36)ozp1 Wrote: Do you mean here?

Code:
# ~~~~~~~~~~~~~
# File renaming
# ~~~~~~~~~~~~~

# OPTIONAL - rename media to a new format when moving
# TRUE/FALSE
# If not specified, FALSE
rename-media=TRUE

But if I do dhis I will loose some great function of the script.
I wonder if this rename feature always remove the file extension or not?

yeh, what OS are you using? i am on windows and it does not remove my extension
Reply
I am using ubuntu 12.04.

I am not sure but looks like when there is a .SRT file at the same folder and with the same filename as the movie, then the movie loose its file extension.
Sometimes the SRT are left behind at the old folder, sometimes dont.
Sometimes the SRT are moved at the new folder (with no file extension) and the movie is left behind

feature request: when the script finds a movie with "3D' at the file name, then write the new file name with "3dbd" so it will be recognized as a 3D movie
Reply
(2012-07-15, 06:02)TheOgreToe Wrote: Absolutely love the script. Quick question, and I apologize if this has been addressed already: it seems many of the movies I'm processing via SortTV are unmatched/go unprocessed due to a mismatch in release year. I can see how this would be useful in matching, say, the modern version of True Grit (2010) vs True Grit (1969). I've found that in many instances, however, the scene release / title of the file will indicate, say, 2007, and the SortTV lookup will return the actual year of 2006, off by 1.

SortTV will declare this a mismatch and not process the file, when in reality it's definitely a match.

Clearly I'm nitpicking an already amazing script...but it would be great if there was an ability to specify a margin of error. I'd much rather SortTV make a best-guess match and process the file, instead of not processing the file at all (please let me know if I'm missing a config option or something).

Thanks again!

Thanks for the suggestion. I will try to include such a feature in a future release.

(2012-07-16, 06:48)ozp1 Wrote: I register at this forum just to thanks Z. Cliffe about this wonderfull software

I'm glad I have the knowledge to install and make it work from command line and config file. Its not much but I was able to do it.
Using ubuntu 10.04

Some question:

Movies: the file extensions were gone, is this correct?
example:
Born to Be Wild (2011) -- this is the actual name of the movie file. no .mkv or .mp4

I've noticed that some videos were moved with the subtitle (srt), others dont.

Thanks

Strange. I haven't seen that. And this comment indicates not everyone on Windows does...

(2012-07-18, 05:26)itachi46 Wrote: [...snip...] i am on windows and it does not remove my extension

(2012-07-17, 14:42)itachi46 Wrote: Great script! not a fan of perl as a language but the amount of regex and matching makes sense to use perl.

anyways, I am running windows 7 64 bit and cannot install WWW::TheMovieDB::Search and this site: suggests it does not support windows anyways. http://code.activestate.com/ppm/WWW-TheMovieDB-Search/

the solution is to comment line 54 : # use WWW::TheMovieDB::Search; note that the movie aspect of this script has to be disabled for this to work.

Cliffe, may i edit the script to work with utorrent better for my personal use? Essentially, utorrent has the ability to run a script after a torrent changes state. I am simply passing the state as an argument and the path of the file to be sorted.

I'd be willing to help out with the tutorial for windows user as long as I am correct in saying the movie aspect of this script does not work on a windows machine with active perl due to the module not supporting windows. Is WWW::TheMovieDB::Search different to TMDB or WWW::TMDB::API? Windows also has access to IMDB api... I am quite busy at the moment but i dont mind spending a day exploring the api to see if i can replace for myself and see if it works.


again thanks for the work Smile

Thanks for offering to help with a tutorial.

It should be possible to tell utorrent to call "perl sorttv.pl --file-to-sort=..."
Edit: feel free to add an option for passing the state through and have it, for example, not do anything unless the state is "completed" (or whatever). See if you can make that as general as possible. Perhaps have the actual state text be something configured.
For example, --only-sort-if-statetext-is=complete --statetext=$utorrentstate
Or something more elegant Smile


I think that WWW::TheMovieDB::Search should work with Windows... Please try "cpan", "force install WWW::TheMovieDB::Search", if there are any problems installing its dependencies, then try forcing those. Let us know how you go.

(2012-07-18, 05:29)ozp1 Wrote: I am using ubuntu 12.04.

I am not sure but looks like when there is a .SRT file at the same folder and with the same filename as the movie, then the movie loose its file extension.
Sometimes the SRT are left behind at the old folder, sometimes dont.
Sometimes the SRT are moved at the new folder (with no file extension) and the movie is left behind

feature request: when the script finds a movie with "3D' at the file name, then write the new file name with "3dbd" so it will be recognized as a 3D movie

Ok, I'll have to have a look at that, I don't know why that would happen. Subtitles with easily identifiable names should get sorted into the same directory as the video file, and they should both retain extensions.

It may help to understand the problem if you run the SortTV testing script now included.

Does XBMC recognise "3dbd"? (If not, what is it used for?)
Edit: looks like it does. I am happy to add that feature later. And remember everyone, if you want to try your hand at adding features please feel free!

Thanks everyone!
Reply
Hello cliffe!

I ran the test script. It went ok until this point below and then I think it hanged. I had to "ctrl+c" to keep it going until the end.

Code:
20:49:7, 18-6-2012
INFO: Currently checking file: Pioneer One Season 1 Episode 1.avi
INFO: trying to move Pioneer One season 1 episode 1
INFO: making show directory: /home/ozp/bin/sorttv/other_scripts/test_directory/TV/Pioneer One
DOWNLOAD: downloading images for Pioneer One
INFO: found a matching show:
    /home/ozp/bin/sorttv/other_scripts/test_directory/TV/Pioneer One
INFO: making season directory: /home/ozp/bin/sorttv/other_scripts/test_directory/TV/Pioneer One/Season 1
DOWNLOAD: downloading season image for Pioneer One

The results:

All tests complete:
71 tests passed
6 tests failed

the test.log is here http://pastebin.com/QBPBuFtt

Regards
Reply
Hey Cliffe,

I've swapped over to Strawberry Perl rather than active perl (they have issues with getting cpan working on a windows 64-bit)

and the only drama i had was the module File::Glob had to be replaced with File::Glob:Windows there were a few others but Windows made the most sense to me and it seems to be working...

So the tutorial is literally this.

Install Strawberry Perl from here : http://strawberryperl.com/

Open up command line and type this: cpan File::Copy::Recursive File::Glob::Windows LWP::Simple TVDB::API Getopt::Long Switch WWW::TheMovieDB::Search XML::Simple

and to run the script: Perl SortTv.pl or simply double click on the script


edit: @ozp1 I just tested your problem with the downloading season image on ubuntu (this feature is disabled on windows) and i am confident in saying that it is a bug in TVDB::API

specifically $tvdb->getSeasonBanner and $tvdb->getSeasonBannerWide . They are not returning from their call. I have tried getSeasonBanners which returns an array of banner names but to no avail.

if you don't mind letting xbmc parse for the season banners, then find these two lines in sorttv.pl

Code:
    my $banner = $tvdb->getSeasonBanner($fetchname, $season);
    my $bannerwide = $tvdb->getSeasonBannerWide($fetchname, $season);

and replace them with

Code:
    my $banner ="";# $tvdb->getSeasonBanner($fetchname, $season);
    my $bannerwide ="";# $tvdb->getSeasonBannerWide($fetchname, $season);

This will stop sorttv.pl from trying to download the season banners but it will not "freeze" anymore Smile
Reply
Hey again Cliffe,

I've finished implementing the states... i called them --run-state and --current-state i have also updated the help message.

I know i said i will be using this for personal use but if you think others may want to use this feature then simply ask and i'll give you the source (bear in mind this is my first time developing on perl so its probably not the prettiest of code).
Reply
  • 1
  • 32
  • 33
  • 34(current)
  • 35
  • 36
  • 49

Logout Mark Read Team Forum Stats Members Help
SortTV: Sort TV episodes, movies, and music into directories for xbmc (Linux/Win/Mac)8