Kodi Community Forum

Full Version: SortTV: Sort TV episodes, movies, and music into directories for xbmc (Linux/Win/Mac)
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
Pages: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
24 season 8 episode 24 is detected wrong.

1:33:47, 15-4-2011
INFO: making show directory: G:/Media/Video/TV/24 8x24 Day 8 300 PM
DOWNLOAD: downloading images for 24 8x24 Day 8 300 PM
INFO: making season directory: G:/Media/Video/TV/24 8x24 Day 8 300 PM/Season 4
DOWNLOAD: downloading season image for 24 8x24 Day 8 300 PM
WARN: Could not get episode title for 24 8x24 Day 8 300 PM Season 4 Episode 0.
MOVE EPISODE: sorting G:/Media/Video/TV/24/Season 8/24 8x24 Day 8 300 PM - S04E0
0.avi --to--> G:/Media/Video/TV/24 8x24 Day 8 300 PM/Season 4/24 8x24 Day 8 300
PM - S04E00.avi
WARN: Could not get episode title for 24 8x24 day 8 300 pm Season 4 Episode 0.
MOVE EPISODE: sorting G:/Media/Video/TV/24/Season 8/24 8x24 day 8 300 pm - S04E0
0.nfo --to--> G:/Media/Video/TV/24 8x24 Day 8 300 PM/Season 4/24 8x24 day 8 300
pm - S04E00.nfo
WARN: Could not get episode title for 24 8x24 day 8 300 pm Season 4 Episode 0.
MOVE EPISODE: sorting G:/Media/Video/TV/24/Season 8/24 8x24 day 8 300 pm - S04E0
0.tbn --to--> G:/Media/Video/TV/24 8x24 Day 8 300 PM/Season 4/24 8x24 day 8 300
pm - S04E00.tbn
WARN: Could not get episode title for 24 8x24 Day 8 300 PM Season 4 Episode 0.
MOVE EPISODE: sorting G:/Media/Video/TV/24/Season 8/24 8x24 Day 8 300 PM - S04E0
0.xml --to--> G:/Media/Video/TV/24 8x24 Day 8 300 PM/Season 4/24 8x24 Day 8 300
PM - S04E00.xml
SKIP: Matches blacklist: metadata
cliffe Wrote:With this update, if the file has already been extracted (and the extracted folder is still there) then extraction is skipped. I also added those file names you mentioned to the blacklist.



Thanks!


Has anyone experienced problems with files being extracted incompletely? I run the script from cron so I am investigating if there is some sort of timeout or options causing the script to be killed early. But occasionally I will get files that seem to only be half extracted. They play in XBMC but then quit after 20-30 mins and their files size is ~40-50% of what it should be. Re-extracting by hand works fine.

Oh, also, the cron job is set to run every 30 minutes so I don't believe the script is "trampling" itself or anything. I've never had it take over 5 minutes to run by hand, and that was sorting a lot of files.

Lastly, my torrents are set to be moved to the directory-to-sort on completion, so its not partial torrents. The only thing I could think is the script is being run while the copy is in process and only part of the rar files are in the directory-to-be-sorted. Seems like a pretty rare coincidence though for how often I am seeing this.
Hi

I've tried searching this thread but came up with nothing...

I have two folders for Doctor Who, the original "Doctor Who" Series and "Doctor Who (2005)". The folders are named as above, and while sortTV matches the episodes correctly for naming, it does not sort the episodes into the correct directories. For example the latest doctor who (2005) episode S06E07 goes into the "Doctor Who" folder instead of going into correct "Doctor Who (2005)" folder.

I am guessing the folder matching part of the script ignores the (2005) part of the file name?

Is there a way to manually force a show directory, similar to the way we can force match the tvdb-ids?

I assume this problem exists with other remakes such as battlestar?

Cheers

A.
Hello,
I found an issue. If I come by a season where the episodes are named only S01E01.divx etc the script WILL match the correct series if I place them in a folder structure "name/season 01" the issue is that all episodes gets renamed "name S01E01" and since I allow overwrite thats not ideal. Since the correct show is found I assume this is a small bug?
pcvii Wrote:24 season 8 episode 24 is detected wrong.

1:33:47, 15-4-2011
INFO: making show directory: G:/Media/Video/TV/24 8x24 Day 8 300 PM
DOWNLOAD: downloading images for 24 8x24 Day 8 300 PM
INFO: making season directory: G:/Media/Video/TV/24 8x24 Day 8 300 PM/Season 4
DOWNLOAD: downloading season image for 24 8x24 Day 8 300 PM
WARN: Could not get episode title for 24 8x24 Day 8 300 PM Season 4 Episode 0.
MOVE EPISODE: sorting G:/Media/Video/TV/24/Season 8/24 8x24 Day 8 300 PM - S04E0
0.avi --to--> G:/Media/Video/TV/24 8x24 Day 8 300 PM/Season 4/24 8x24 Day 8 300
PM - S04E00.avi
WARN: Could not get episode title for 24 8x24 day 8 300 pm Season 4 Episode 0.
MOVE EPISODE: sorting G:/Media/Video/TV/24/Season 8/24 8x24 day 8 300 pm - S04E0
0.nfo --to--> G:/Media/Video/TV/24 8x24 Day 8 300 PM/Season 4/24 8x24 day 8 300
pm - S04E00.nfo
WARN: Could not get episode title for 24 8x24 day 8 300 pm Season 4 Episode 0.
MOVE EPISODE: sorting G:/Media/Video/TV/24/Season 8/24 8x24 day 8 300 pm - S04E0
0.tbn --to--> G:/Media/Video/TV/24 8x24 Day 8 300 PM/Season 4/24 8x24 day 8 300
pm - S04E00.tbn
WARN: Could not get episode title for 24 8x24 Day 8 300 PM Season 4 Episode 0.
MOVE EPISODE: sorting G:/Media/Video/TV/24/Season 8/24 8x24 Day 8 300 PM - S04E0
0.xml --to--> G:/Media/Video/TV/24 8x24 Day 8 300 PM/Season 4/24 8x24 Day 8 300
PM - S04E00.xml
SKIP: Matches blacklist: metadata

The episode filename does not really make sense. SortTV is picking up on the S04E00 at the end of the filename. Just remove that part and all should be well. If that is still not working try that with the new version 1.28, which I am just about to post.
A new version of SortTV is now available: v1.28

Since the last version:
  • --use-season-directories:[TRUE|FALSE]
    Whether to use directories for seasons is now optional.
    For example, should "Show S1E01.avi" be sorted into "Show/Season 1/" or "Show"
    If FALSE, all episodes will be put in the one show directory and season images will not be fetched
    If not specified, TRUE
  • SortTV now handles years better. For example, "Doctor Who (2005) S01E01.avi". When sorting it first looks for a matching directory with the specific show title and year, if not found it will try to find the matching title without the year. If no directory exists, it will use the year version to create the directory.

    Therefore, the thing to keep in mind is that if you know you have two shows with the same title from different years, but they are going into one directory without a year (eg ".../Doctor Who"), just create a directory including the year (".../Doctor Who (2005").
  • Only sends notifications when sort is successful
  • Added pattern: Show/Season 1/S1E1.avi
  • Fixed pattern: Show Season 1/101.avi
  • Config changes: more blacklists, show name substitutes, etc
  • A number of small bug fixes

This script is free open source software. You are free to use and modify this software.

I really appreciate donations. Please consider a $5 donation if you find this script helpful. Click here for more information and to make a quick and easy donation using paypal

Get the new version from:
http://sourceforge.net/projects/sorttv/

--

timgray Wrote:Is there any way to disable the "season" subfolders?
There is now Smile

sh0stak Wrote:Thanks!


Has anyone experienced problems with files being extracted incompletely?
The blacklist has been updated to stop more of the .rXX files from being moved. That might have been the problem.

fush Wrote:Hi

I've tried searching this thread but came up with nothing...

I have two folders for Doctor Who, the original "Doctor Who" Series and "Doctor Who (2005)". The folders are named as above, and while sortTV matches the episodes correctly for naming, it does not sort the episodes into the correct directories. For example the latest doctor who (2005) episode S06E07 goes into the "Doctor Who" folder instead of going into correct "Doctor Who (2005)" folder.

I am guessing the folder matching part of the script ignores the (2005) part of the file name?

Is there a way to manually force a show directory, similar to the way we can force match the tvdb-ids?

I assume this problem exists with other remakes such as battlestar?

Cheers

A.
The new version now tries to take the years into account.

vikjon0 Wrote:Hello,
I found an issue. If I come by a season where the episodes are named only S01E01.divx etc the script WILL match the correct series if I place them in a folder structure "name/season 01" the issue is that all episodes gets renamed "name S01E01" and since I allow overwrite thats not ideal. Since the correct show is found I assume this is a small bug?
That naming format is now correctly detected.

Enjoy!
Big Grin
Hi
Nice will be add possibility support transmission task manager over RCP:
example:

Transmission finish download some movie .. then your script delate task from transmission and start move/unpack process etc.

https://trac.transmissionbt.com/browser/...c-spec.txt
and this is link to actual spec of RPC from Tranmission

Im on your homepage of project, upload my script in python for sort movies (is include support Transmission task support) please look on this, this is very easy. Thanks Wink

Best Regards
piotrasd Wrote:Hi
Nice will be add possibility support transmission task manager over RCP:
example:

Transmission finish download some movie .. then your script delate task from transmission and start move/unpack process etc.

https://trac.transmissionbt.com/browser/...c-spec.txt
and this is link to actual spec of RPC from Tranmission

Im on your homepage of project, upload my script in python for sort movies (is include support Transmission task support) please look on this, this is very easy. Thanks Wink

Best Regards

I just spent quite a bit of time working on SortTV, and I only have a limited amount of time available. To be honest, since I don't use Transmission that request is low on my priorities. However, (especially since you have some programming background) I encourage you to try to make the changes to SortTV yourself. If your changes look good and are helpful I will include them in SortTV.

Thanks,

Cliffe.

Update: You could just move completed downloads into a separate directory for sorting by SortTV. If Transmission still does not include this basic feature, then use a separate script to do that first step of moving completed downloads: http://1000umbrellas.com/2010/04/28/how-...-downloads or https://gist.github.com/791609
Quote:That naming format is now correctly detected.
Thank you! In the shame of not fixing it myself I made a small donation. I will read a tut on regex later today as a first step to figure out sorting and scraping.

I found another exception later earlier today. If there is more than one file per episodes whith matched fileformat and not blacklisted (sample) they need to be named S01E01-part1
This does not happen often, I will see if I can make a small rename script to sort it out as an excersise.
cliffe Wrote:[*]SortTV now handles years better. For example, "Doctor Who (2005) S01E01.avi". When sorting it first looks for a matching directory with the specific show title and year, if not found it will try to find the matching title without the year. If no directory exists, it will use the year version to create the directory.

Therefore, the thing to keep in mind is that if you know you have two shows with the same title from different years, but they are going into one directory without a year (eg ".../Doctor Who"), just create a directory including the year (".../Doctor Who (2005").

Hi Cliffe

That is fantastic, looking forward to trying it out when I get home...

Cheers

A.
Quote:be named S01E01-part1
I made a flithy fix for this.


Code:
my $forceeptitle = ""; # HACK for limitation in TVDB API module
#VIKJON0
my $prevnewpath ="";
my $part = 1;


EDIT: small fix...I need to store the prevnewpath before amendment otherwise there will never be a third hit.
Code:
sub sort_file {
    my ($file, $newpath, $msg) = @_;
    # returns whether to display a message
    my $retval = 'FALSE';

    #VIKJON0
    if($newpath eq $prevnewpath){
        $part = $part + 1;
        my($fname, $fpath, $ftype) = fileparse($newpath,qr/\.[^.]*/);
        $prevnewpath = $newpath;
        $newpath = "$fpath$fname-part$part$ftype";
    } else {
        $part = 1;
        $prevnewpath = $newpath;
    }


This is of course a stupid way of doing it since I do not get part1 correctly. However, since stacking does not work in dharma it is not a big deal assuming it will scrap.
EDIT2: Bad luck for me.. it scraps but "-part2" is displayed before "" in xbmc episode list. A further filthy fix could rename the already moved file but that is perhaps a bit too dirty since we do not know if we actually did create that file or we "skipped"

In addition to this kind of fix I should probably try to guess that it is a part based on filename as well. (part1, cd1 + custom list from config file). E.g of custom list: "","walkthrough","revisited". (example from grand designs)

For the moment that is too advanced for me..still did not do the regex homeworkNo
vikjon0 Wrote:I made a flithy fix for this.


Code:
my $forceeptitle = ""; # HACK for limitation in TVDB API module
#VIKJON0
my $prevnewpath ="";
my $part = 1;


EDIT: small fix...I need to store the prevnewpath before amendment otherwise there will never be a third hit.
Code:
sub sort_file {
    my ($file, $newpath, $msg) = @_;
    # returns whether to display a message
    my $retval = 'FALSE';

    #VIKJON0
    if($newpath eq $prevnewpath){
        $part = $part + 1;
        my($fname, $fpath, $ftype) = fileparse($newpath,qr/\.[^.]*/);
        $prevnewpath = $newpath;
        $newpath = "$fpath$fname-part$part$ftype";
    } else {
        $part = 1;
        $prevnewpath = $newpath;
    }


This is of course a stupid way of doing it since I do not get part1 correctly. However, since stacking does not work in dharma it is not a big deal assuming it will scrap.
EDIT2: Bad luck for me.. it scraps but "-part2" is displayed before "" in xbmc episode list. A further filthy fix could rename the already moved file but that is perhaps a bit too dirty since we do not know if we actually did create that file or we "skipped"

In addition to this kind of fix I should probably try to guess that it is a part based on filename as well. (part1, cd1 + custom list from config file). E.g of custom list: "","walkthrough","revisited". (example from grand designs)

For the moment that is too advanced for me..still did not do the regex homeworkNo

So, to clarify, you want it to detect that two files resulted in the same rename during a SortTV sort, and name them with part1, part2 etc. But if a later sort results in the same name then that is a separate case, since they might be coming from the exact same origin filename or be a later repack of the same episode and you don't want to have those stacked, where the same episode would show more than once.

Eg "Show S1E1 - Episode part 1.avi", "Show S1E1 - Episode part 2.avi", and "Show S1E1 - making of.avi" when sorted at the same time would become:
Show/Season 1/Show - S01E01 - Title part1.avi
Show/Season 1/Show - S01E01 - Title part2.avi
Show/Season 1/Show - S01E01 - Title part3.avi

The way I would go about doing this would probably be as follows. SortTV already maintains a shorthand list of episodes that have been sorted this time around, which is stored in the variable $newshows. $newshows contains a list of ("Show S1E1\nShow S1E2\n") etc. When sorting you could check if $newshows already contains the episode being sorted. If it does, then figure out how many of that episode are in the list and tack a part number at the end of the new one, if this is the second instance, then rename the first sorted file to have "part1" at the end.

Learning regex is definitely a good idea Smile

Thanks and good luck.
Quote:So, to clarify, you want it to detect that two files resulted in the same rename during a SortTV sort, and name them with part1, part2 etc. But if a later sort results in the same name then that is a separate case, since they might be coming from the exact same origin filename or be a later repack of the same episode and you don't want to have those stacked, where the same episode would show more than once.
Yes, and the reason I wanted to add guessing from the filename if it was a part is that if the sorting are interupted with one of the parts left in sortdir the current method will not remember. In the example I work with now it is not clear from the filename but part1 or cd1 will often be part of the name.

Quote: $newshows
Ok, that is useful. It does not include skipped files? Still it is not very clean to go back into the destination dir and rename a file. A better solution will require some more work. A pre-loop of the directory or a temp dir.
vikjon0 Wrote:Yes, and the reason I wanted to add guessing from the filename if it was a part is that if the sorting are interupted with one of the parts left in sortdir the current method will not remember. In the example I work with now it is not clear from the filename but part1 or cd1 will often be part of the name.

I think the place to do this would be when the new file name is being calculated, and you could look at the original filename to see if it includes "part" etc (regex). If so add to the end.

vikjon0 Wrote:Ok, that is useful. It does not include skipped files? Still it is not very clean to go back into the destination dir and rename a file. A better solution will require some more work. A pre-loop of the directory or a temp dir.

$newshows does not include skipped files, but it does include files that have been overwritten with a repack etc. Maybe renaming sorted files is not quite as clean as deciding in advance, but it would be much faster to do the sort and probably easier in terms of the amount of code you would have to change. It would also be easier to review your changes and it will be easier for you to write if you don't have to make huge changes to the existing code.

On the other hand, one alternative approach would be to calculate the moves and directory creations etc in a dry run and store the changes to make in a list. This would make it possible to do the actual sorting multi-threaded: once all the decisions had been made the actual changes could be done by multiple threads. I am really not sure if it is worth the added complexity though, and I don't have the time to do that kind of refactoring.

Probably the easiest solution would be, when calculating the new name, if the original had "part1" or "cd1" etc then add "part1" to the end of the new name.

Anyway, let me know how you go.

Update: Hint:

Off the top of my head, untested:
Code:
# search for "anything, then "part", then grab any numbers, then a dot, then some letters etc, then the end of the string
if($file =~ /.*part(\d+)\.\w+$/) {
    # keep track of the number we grabbed
    my $partnum = $1;
    # replace the ending (a dot then some letters etc) with "part" then the number from before, then the original ending
    $newname =~ s/(\.\w+)$/ part$partnum\1/;
}

Update 2: On second thoughts this could all be achieved with a one-line regex substitution.

Hope that helps, maybe try putting that in to the rename and see if it works etc
From G:/Media/Video/Wont sort TV/
TV episodes into G:/Media/Video/TV/
13:30:57, 14-5-2011
INFO: trying to move dirty jobs season 7 episode 11
INFO: found a matching show:
G:/Media/Video/TV/Dirty Jobs
INFO: found a matching season directory:
G:/Media/Video/TV/Dirty Jobs/Season 7
INFO: Fetching episode title for Dirty Jobs Season 7 Episode 11.
Entity: line 1: parser error : Start tag expected, '<' not found
▼ï
^
Pages: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49