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

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

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


- Holdengts - 2011-04-17 04:30

Hi There
I am currently getting this error message

DBM : : Deep: Wrong file version found - 4 - expected 3 at sorttv.pl line 139

How would I solve this pleaseConfused?


- cliffe - 2011-04-18 09:45

timgray Wrote:So any tips on how to disable the "season" subfolders?

If you want to hack at the code to remove season directories:

Line ~1062 of sorttv.pl looks something like this:
Code:
foreach my $season (bsd_glob($show.'/*')) {
                if(-d $season.'/' && $season =~ /(?:Season|Series|$seasontitle)?\s?0*(\d+)$/i && $1 == $series) {

That is the part that looks for a matching season directory.

You could try replacing those lines with some code that just sets the $season variable to $show (or just uses $show instead) so that it just puts episodes in the show directory rather than a season directory.

So you could try something like:
remove:
Code:
        if(fixtitle(filename($show)) =~ /^\Q$showname\E$/i || fixtitle(escape_myfilename(filename($show))) =~ /^\Q$subshowname\E$/i) {
            out("verbose", "INFO: found a matching show:\n\t$show\n");
            my $s = $show.'/*';
            my @g=bsd_glob($show);
            foreach my $season (bsd_glob($show.'/*')) {
                if(-d $season.'/' && $season =~ /(?:Season|Series|$seasontitle)?\s?0*(\d+)$/i && $1 == $series) {
                    out("verbose", "INFO: found a matching season:\n\t$season\n");
                    move_an_ep($file, $season, $show, $series, $episode);
                    # next FILE;
                    return 0;
                }
            }
            # didn't find a matching season, make DIR
            out("std", "INFO: making season directory: $show/$seasontitle$series\n");
            my $newpath = "$show/$seasontitle$series";
            if(mkdir($newpath, 0777)) {
                fetchseasonimages(resolve_show_name($pureshowname), $show, $series, $newpath) if $fetchimages ne "FALSE";
                redo SHOW; # try again now that the dir exists
            } else {
                out("warn", "WARN: Could not create season dir: $!\n");
                # next FILE;
                return 0;
            }
        }
And use this instead:
Code:
move_an_ep($file, $show, $show, $series, $episode);
return 0;

Keep in mind that this is just a quick hack, and I haven’t tested this suggestion. A better solution would be to make this a configurable option, in case others are interested in this feature. Feel free to send me a patch!


- cliffe - 2011-04-18 09:46

Holdengts Wrote:Hi There
I am currently getting this error message

DBM : : Deep: Wrong file version found - 4 - expected 3 at sorttv.pl line 139

How would I solve this pleaseConfused?

Please try deleting the ".cache" subdirectory in the sorttv directory.


- cliffe - 2011-04-18 09:49

freaktm Wrote:+1 on that - with that option, sorting music would be a lot easier! Big Grin

Regarding the MOVE-AND-LEAVE-SYMLINK-BEHIND problem I had earlier, I think it was because uTorrent was using the files, too.. Just started using COPY instead, and getting no problems Smile

Glad to hear you sorted that out.

Only episodes are moved into "Show/Season x/" directories, so it won't affect sorting of music. Check out the new feature for sorting music, described in an earlier post.


- sh0stak - 2011-04-26 17:03

Happy to see SortTV now handles extraction. I have a question about it though.

How I am running right now: finished downloads go into a /new folder where they are sorted from. I am using copy-and-leave-symlink so that files can continue to seed. This works fine for non-archived files.

For archives I had a problem where the .r## (but not .rar) were being copied/symlinked also. I added a blacklist entry for *.r(0-9)* (a separate entry for each digit), so now all the rar files remain untouched and seed just fine. The extracted video file is sorted fine and the extraction folder and symlink is left behind even though I never use it (this is fine, they just get delete once seeding is complete and take up no space).

The problem: Every time sorttv runs, it appears to re-extract the file since all the archives are still there. I cannot tell if it is actually extracting the file or not though, all that is in the extracted directory is a symlink so it looks like the actual extraction is skipped, but still displayed in the log. I know sorttv is smart enough to not re-copy files that are already sorted (dont move/copy if the destination file already exists) but does it do the same with extraction?

Here is sample log output if my point is not clear:

Code:
Sorting:
    From /media/munin-900/new/
    TV episodes into /media/munin-700/TV/
10:45:3, 26-3-2011
RAR: extracting /media/munin-900/new/Fringe.S03E20.HDTV.XviD-LOL/fringe.320.hdtv-lol.rar into //media/munin-900/new/Fringe.S03E20.HDTV.XviD-LOL/fringe.320.hdtv-lol.rar (extracted by SortTV)
SKIP: Matches blacklist: fringe.320.hdtv-lol.r00
SKIP: Matches blacklist: fringe.320.hdtv-lol.r01
SKIP: Matches blacklist: fringe.320.hdtv-lol.r02
SKIP: Matches blacklist: fringe.320.hdtv-lol.r03
SKIP: Matches blacklist: fringe.320.hdtv-lol.r04
SKIP: Matches blacklist: fringe.320.hdtv-lol.r05
SKIP: Matches blacklist: fringe.320.hdtv-lol.r06
SKIP: Matches blacklist: fringe.320.hdtv-lol.r07
SKIP: Matches blacklist: fringe.320.hdtv-lol.r08
SKIP: Matches blacklist: fringe.320.hdtv-lol.r09
SKIP: Matches blacklist: fringe.320.hdtv-lol.r10
SKIP: Matches blacklist: fringe.320.hdtv-lol.r11
SKIP: Matches blacklist: fringe.320.hdtv-lol.r12
SKIP: Matches blacklist: fringe.320.hdtv-lol.r13
SKIP: Matches blacklist: fringe.320.hdtv-lol.r14
SKIP: Matches blacklist: fringe.320.hdtv-lol.r15
SKIP: Matches blacklist: fringe.320.hdtv-lol.r16
SKIP: Matches blacklist: fringe.320.hdtv-lol.r17
SKIP: Matches blacklist: fringe.320.hdtv-lol.r18
SKIP: Matches blacklist: fringe.320.hdtv-lol.r19
SKIP: Matches blacklist: fringe.320.hdtv-lol.r20
SKIP: Matches blacklist: fringe.320.hdtv-lol.r21
SKIP: Matches blacklist: fringe.320.hdtv-lol.r22
SKIP: Matches blacklist: fringe.320.hdtv-lol.r23
SKIP: Matches blacklist: fringe.320.hdtv-lol.rar
Sorting:
    From /media/munin-900/new/
    TV episodes into /media/munin-700/TV/
11:0:1, 26-3-2011
RAR: extracting /media/munin-900/new/Fringe.S03E20.HDTV.XviD-LOL/fringe.320.hdtv-lol.rar into //media/munin-900/new/Fringe.S03E20.HDTV.XviD-LOL/fringe.320.hdtv-lol.rar (extracted by SortTV)
SKIP: Matches blacklist: fringe.320.hdtv-lol.r00
SKIP: Matches blacklist: fringe.320.hdtv-lol.r01
SKIP: Matches blacklist: fringe.320.hdtv-lol.r02
SKIP: Matches blacklist: fringe.320.hdtv-lol.r03
SKIP: Matches blacklist: fringe.320.hdtv-lol.r04
SKIP: Matches blacklist: fringe.320.hdtv-lol.r05
SKIP: Matches blacklist: fringe.320.hdtv-lol.r06
SKIP: Matches blacklist: fringe.320.hdtv-lol.r07
SKIP: Matches blacklist: fringe.320.hdtv-lol.r08
SKIP: Matches blacklist: fringe.320.hdtv-lol.r09
SKIP: Matches blacklist: fringe.320.hdtv-lol.r10
SKIP: Matches blacklist: fringe.320.hdtv-lol.r11
SKIP: Matches blacklist: fringe.320.hdtv-lol.r12
SKIP: Matches blacklist: fringe.320.hdtv-lol.r13
SKIP: Matches blacklist: fringe.320.hdtv-lol.r14
SKIP: Matches blacklist: fringe.320.hdtv-lol.r15
SKIP: Matches blacklist: fringe.320.hdtv-lol.r16
SKIP: Matches blacklist: fringe.320.hdtv-lol.r17
SKIP: Matches blacklist: fringe.320.hdtv-lol.r18
SKIP: Matches blacklist: fringe.320.hdtv-lol.r19
SKIP: Matches blacklist: fringe.320.hdtv-lol.r20
SKIP: Matches blacklist: fringe.320.hdtv-lol.r21
SKIP: Matches blacklist: fringe.320.hdtv-lol.r22
SKIP: Matches blacklist: fringe.320.hdtv-lol.r23
SKIP: Matches blacklist: fringe.320.hdtv-lol.rar
SKIP: Matches blacklist: fringe.320.hdtv-lol.sfv



New version available - cliffe - 2011-04-29 16:23

v1.27

This is just a minor update, changing the way that archives are handled.

http://sourceforge.net/projects/sorttv

As always, donations are appreciated!

sh0stak Wrote:Happy to see SortTV now handles extraction. I have a question about it though.

How I am running right now: finished downloads go into a /new folder where they are sorted from. I am using copy-and-leave-symlink so that files can continue to seed. This works fine for non-archived files.

For archives I had a problem where the .r## (but not .rar) were being copied/symlinked also. I added a blacklist entry for *.r(0-9)* (a separate entry for each digit), so now all the rar files remain untouched and seed just fine. The extracted video file is sorted fine and the extraction folder and symlink is left behind even though I never use it (this is fine, they just get delete once seeding is complete and take up no space).

The problem: Every time sorttv runs, it appears to re-extract the file since all the archives are still there. I cannot tell if it is actually extracting the file or not though, all that is in the extracted directory is a symlink so it looks like the actual extraction is skipped, but still displayed in the log. I know sorttv is smart enough to not re-copy files that are already sorted (dont move/copy if the destination file already exists) but does it do the same with extraction?

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.


- newphreak - 2011-05-05 08:13

Hi, I really miss the library update when sorting is done. How would i setup this with pre eden xbmc? i guess i should conf the new xbmc communication setting, but how does it work when you have a username and password and it's running on another box? I would appreciate some better examples in the conf for this. Other then that, great work updating and including new and good features for this script. Smile Can't wait to see an official Add-on for this.

Edit:
Looked at the script, and i guess this protocol only needs ip, and judging by my xbmc.log it is hosting at 9090. But i don't get any library updates when it has new episodes, so how could i debug this? Smile


- newphreak - 2011-05-05 19:07

Also i would like to do a feature request, i would like to extract compressed files after sorting. So i don't mess up what I'm copying from. Rolleyes

Edit: i tried "extract-compressed-before-sorting=TRUE" with "sort-by=COPY", but it does not seem to unpack the content, and there is no error about it in the log, extracting is not even mentioned. I have made sure unrar is installed too. So I'm not able to see if my feature request is needed or not, as i cant get it to work.


- cliffe - 2011-05-10 16:53

newphreak Wrote:Hi, I really miss the library update when sorting is done. How would i setup this with pre eden xbmc? i guess i should conf the new xbmc communication setting, but how does it work when you have a username and password and it's running on another box? I would appreciate some better examples in the conf for this. Other then that, great work updating and including new and good features for this script. Smile Can't wait to see an official Add-on for this.

Edit:
Looked at the script, and i guess this protocol only needs ip, and judging by my xbmc.log it is hosting at 9090. But i don't get any library updates when it has new episodes, so how could i debug this? Smile

Yesterday I updated to a newer version of xbmc on my HTPC and I have started seeing the same thing. On my dev box the library update works fine during testing, but on the HTPC it is receiving and displaying the notifications but not looking for new content.

I have both the old and new command interface setup in my SortTV configuration.

My first guess is that the interface for RPC commands has changed yet again. I don't have time to investigate this right away, but if someone else has the time to get to the bottom of this it would help a lot of users Smile


- cliffe - 2011-05-10 17:09

newphreak Wrote:Also i would like to do a feature request, i would like to extract compressed files after sorting. So i don't mess up what I'm copying from. Rolleyes

Edit: i tried "extract-compressed-before-sorting=TRUE" with "sort-by=COPY", but it does not seem to unpack the content, and there is no error about it in the log, extracting is not even mentioned. I have made sure unrar is installed too. So I'm not able to see if my feature request is needed or not, as i cant get it to work.

If extraction is enabled and it can't find a program to do the extraction it should say so. Perhaps try creating some more .zip/.rar files and putting them in the directory you are sorting to see what happens.


- vikjon0 - 2011-05-13 17:56

I just got the daily shows working in xbmc with sorttv! You should promote this functionality a bit more e.g. in the feature list!

I manage to miss it and only found out when I tried to review the code to do it myself. (pretty tricky code btw).

It is more or less impossible to get to work in xbmc without a rename to the s99e99 format due to the limitations in thetvdb (well, or due to limititations in the scrapers)

My conf was correct to do this already, the issue was name format (did not work with liberal matching for some reason)
Best fixed by defining the shows in the conf

E.g.
Code:
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
On a (un-)related note I also have

Code:
show-name-substitute:House MD-->House
show-name-substitute:House M.D.-->House

Perhaps you want to add these to the templete or else someone might want to copy it.


- cliffe - 2011-05-13 20:10

vikjon0 Wrote:I just got the daily shows working in xbmc with sorttv! You should promote this functionality a bit more e.g. in the feature list!

I manage to miss it and only found out when I tried to review the code to do it myself. (pretty tricky code btw).

It is more or less impossible to get to work in xbmc without a rename to the s99e99 format due to the limitations in thetvdb (well, or due to limititations in the scrapers)

My conf was correct to do this already, the issue was name format (did not work with liberal matching for some reason)
Best fixed by defining the shows in the conf

E.g.
Code:
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
On a (un-)related note I also have

Code:
show-name-substitute:House MD-->House
show-name-substitute:House M.D.-->House

Perhaps you want to add these to the templete or else someone might want to copy it.

Glad you found the daily show name matching feature helpful. Credit to CoinTos for contributing the code.

If liberal matching is enabled, it basically pulls any numbers out of the filename for the season and episode numbers. Handy for filenames such as "Show Ser 1 Epi 2.avi", but I don't have it enabled on my system and havn't needed it. As you found out, it tries liberal matching before it tries dates.

Thanks for the config lines, I will add them to the next version.

Since you have already had a look at the code, remember I am always happy to receive patches, so if you can think of any other features or want to have a crack at one of the features we have discussed (movie sorting, multi-episode files, the xbmc interface), then please go for it!


- vikjon0 - 2011-05-14 13:12

Turns out the place where i procure the shows is not too bothered with the naming of daily shows. All (so far) have to be identified.

tvdb-id-substitute:Conan-->194751
(assumimg we only download current conan)
tvdb-id-substitute:Jay Leno-->70336
(assuming we only down curremt Jay)


- vikjon0 - 2011-05-14 13:31

Quote:Since you have already had a look at the code,
Well, so far my conclusion is that it looks tricky. Wink I don't know perl and I never figured out regex. Not knowing a language have never stopped me from reading code before, but perhaps it is time to read up on regex.

Do you have a feature request list?

The music folder is a great addition (altough I have to pretend it says audio since I am an audiobook addict)
I think more folders would be useful.

Of course separating movies from other non-episodes would be great. Sorting the movies would be even greater.
I assume a full solution is a lot of work but one fix would be to handle it like music, if non-ep then check if video and move to video folder ("non-ep video").

An "assumed to be crap if found togther with media files" folder would also be nice.
.txt, .nfo etc is moved to this folder if found together with e.g. a tv serie
This folder can then be checked and emptied and the files will not be mixed with non episodes or non sorted material.

An alternative to the last thing would be another blacklist, instead of the existing ignore-list the new list will send matches to a another folder.


- cliffe - 2011-05-14 16:03

vikjon0 Wrote:Well, so far my conclusion is that it looks tricky. Wink I don't know perl and I never figured out regex. Not knowing a language have never stopped me from reading code before, but perhaps it is time to read up on regex.

Do you have a feature request list?

Not formally. Feel free to mention any ideas here. The ones I mentioned are the main outstanding ones.

vikjon0 Wrote:The music folder is a great addition (altough I have to pretend it says audio since I am an audiobook addict)
I think more folders would be useful.

Of course separating movies from other non-episodes would be great. Sorting the movies would be even greater.
I assume a full solution is a lot of work but one fix would be to handle it like music, if non-ep then check if video and move to video folder ("non-ep video").

An "assumed to be crap if found togther with media files" folder would also be nice.
.txt, .nfo etc is moved to this folder if found together with e.g. a tv serie
This folder can then be checked and emptied and the files will not be mixed with non episodes or non sorted material.

An alternative to the last thing would be another blacklist, instead of the existing ignore-list the new list will send matches to a another folder.

I think the best way to do movie sorting would be to look it up on the moviedb: for example, using a perl module.

If there is a match, then rename using the movie title (and year?) and move it to a movie directory. Optionally in a subdirectory for the movie.

As I mentioned in a previous post this module looks promising, but for some reason is not available in Strawberry Perl CPAN:
http://search.cpan.org/~pjobson/WWW-TheMovieDB-Search.docupdate/lib/WWW/TheMovieDB/Search.pm
I haven't looked into it any further, but it would be great if someone could look into why Perl and Strawberry Perl have separate modules available via CPAN.