XBMC Community Forum
SortTV: Sort TV episodes, movies, and music into directories for xbmc (Linux/Win/Mac) - Printable Version

+- XBMC Community Forum (http://forum.xbmc.org)
+-- Forum: Help and Support (/forumdisplay.php?fid=33)
+--- Forum: Supplementary Tools for XBMC (/forumdisplay.php?fid=116)
+--- Thread: SortTV: Sort TV episodes, movies, and music into directories for xbmc (Linux/Win/Mac) (/showthread.php?tid=75949)



RE: SortTV, automatically sort new episodes into dirs and update XBMC library (Linux/Win) - DoubleDroz - 2012-06-30 15:01

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


RE: SortTV, automatically sort new episodes into dirs and update XBMC library (Linux/Win) - verysoftpaper - 2012-07-05 09:49

Hi, great tool, just what I have been looking for.. anyway you can ignore sample files which many times come next to the movies/tvshows?

Cheers


RE: SortTV, automatically sort new episodes into dirs and update XBMC library (Linux/Win) - deranjer - 2012-07-05 14:20

(2012-07-05 09:49)verysoftpaper Wrote:  Hi, great tool, just what I have been looking for.. anyway you can ignore sample files which many times come next to the movies/tvshows?

Cheers

Sample files should already be on the ignore list in sorttv.conf:

ignore=sample*

So any files that start with "sample" will not be sorted.


RE: SortTV, automatically sort new episodes into dirs and update XBMC library (Linux/Win) - verysoftpaper - 2012-07-05 21:06

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..


RE: SortTV, automatically sort new episodes into dirs and update XBMC library (Linux/Win) - cliffe - 2012-07-08 13:35

(2012-04-29 10:48)john.doe Wrote:  Trying to get this work on windows 7. I installed strawberry-perl-5.14.2.1-32bit and when I do

cpan WWW::TheMovieDB::Search

Then I got this error
[...]
How can I fix this and get this script to work in w7 ? plz help Confused

If cpan modules are not passing the tests, you can force cpan to install them anyway. Run sudo cpan (or just "cpan" on Windows), then type "force install Switch", where Switch is the name of the module you are trying to install.
(2012-06-24 20:54)cableghost Wrote:  Newbie here...

I'm not understanding the install and run functions. I have tried reading XBMC scripting readme, but it doesn't jive with sorttv instructions.

1. I don't have an existing directory called 'scripts in my default XBMC install directory 'C:\Program Files (x86)\XBMC', so where do I copy/move the 'sorttv' folder to?
3. What is meant by 'install pearl'
2. Where do I run: 'cpan File::Copy::Recursive File::Glob LWP::Simple TVDB::API Getopt::Long Switch WWW::TheMovieDB::Search XML::Simple'?

My setup: Windows 7 HP x64

Any help would be appreciated.

-Scott

P.S. Does any of this change if using Raspberry Pi?

Hi Scott,

1: you can put SortTV anywhere, it doesn't need to live in the xbmc directory.
2: install Strawberry Perl if you are using Windows
3: the command prompt
(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.


RE: SortTV, automatically sort new episodes into dirs and update XBMC library (Linux/Win) - cliffe - 2012-07-08 13:47

(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?


New version of SortTV available: 1.33 - cliffe - 2012-07-08 14:35

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.


RE: SortTV, automatically sort new episodes into dirs and update XBMC library (Linux/Win) - cliffe - 2012-07-09 18:54

(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?


RE: SortTV: Sort TV episodes, movies, and music into directories for xbmc (Linux/Win/Mac) - TheOgreToe - 2012-07-15 06:02

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!


RE: SortTV: Sort TV episodes, movies, and music into directories for xbmc (Linux/Win/Mac) - ozp1 - 2012-07-16 06:48

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