• 1
  • 28
  • 29
  • 30(current)
  • 31
  • 32
  • 49
SortTV: Sort TV episodes, movies, and music into directories for xbmc (Linux/Win/Mac)
For all who had issues with installing it on Debian Squeeze, try this:
Code:
apt-get install make build-essential libxml-sax-expat-perl
cpan File::Copy::Recursive File::Glob LWP::Simple TVDB::API Getopt::Long Switch WWW::TheMovieDB::Search XML::Simple
perl -MXML::SAX -e "XML::SAX->add_parser(q(XML::SAX::Expat))->save_parsers()"
This helped me to get this running without error.

Edit:
I get no Series-Info with this file i just DL:
itg-dexter-s04e01.avi

Maybe the script can be improved to:
1. ignore the first part of the filename and try to find everything on TVDB after the first "-"
2. Don't move files, which are NOT in the TVDB, so i can rename them by hand and let SortTV move it.

Maybe this XML-regex can help with this. XBMC finds the corrext TVDB-entry for the above file
Thx
Philips TV with Kodi 20.2 with IPTV --- Orbsmart 500 Android 21 alpha/beta as Online-radio/TV in the kitchen
Reply
It's a wonderfull tool, the only thing that is missing is an easy to use GUI for these powerfull features. I think a lot of newbies are scared to use it, because of this. However, it's still a great tool! Thx Cliffe!
Reply
I've been using this tool for a few months now and it is great. It does exactly what I want it to do, move / rename files into the correct location and leave symbolic link behind. Really really great script!

I have a few feature requests.
1 - Be able to simulate / printout what the script will do with a given command, but not actually do (move) anything. A few times the script has failed, for instance when running on a whole season the TV show was picked up incorrectly and sorted it in the wrong location. This was fixed by simily adding the correct tv substitute flag, but I had to move all the files back to where they were first.
2 - Be able to run the script on a single file not a folder.
3 - Seperate input directorys for movies / tv shows. I use this script for movies as well, where some movies (Super 8 was one) get picked up as tv shows and get sorted in the wrong location. This would take the guess work out of if it is a tv show or movie.

If you want some help implementing these features let me know and I can give you a hand. I have experience with this type of stuff.

Nexxo
Reply
If in the config "--use-dots-instead-of-spaces" is set, it should do that for Folders also. So "Game of Thrones" becomes "Game.of.Thrones"

Thx
Philips TV with Kodi 20.2 with IPTV --- Orbsmart 500 Android 21 alpha/beta as Online-radio/TV in the kitchen
Reply
First a thanks for a nice script!
Got it running ok with portable strawberry on a windows machine, had to do some changes though.
Don't know if this helps but this is what I found out, windows don't like ' (single quote) when it comes to paths. So that messes up the extracting with rar a bit.

I changed row 1093
Code:
if(num_found_in_list(system("rar e -o$over '$arfile' '$dest'"), @errors) eq "FALSE") {
to
Code:
if(num_found_in_list(system("rar e -o$over \"$arfile\" \"$dest\""), @errors) eq "FALSE") {
to get it running.

There's still some problem with creating the temp directory but that I don't care so much about since it works nicely with the source dir.
If you find any spelling mistakes you can keep them ;)
Reply
I am interested in trying out this script as I have been using utorrent/therenamer on the server to do this. I have since moved this functionality off the server and onto my HTPC. Unfortunately, something with therenamer causes XBMC to lose focus and is very annoying. In reading through the instructions, I'm not sure if my format is supported. My episodes are organized as follows:

server://tv/Show Name/Season 1/01 - Episode.ext

If possible, how would I make this work properly?

Thanks in advance!
The XBMC team, plug-in devs, skinners, etc. do this for us for FREE in their spare time because they want to. Think about that for a second before you start bitching...
Reply
TechLife Wrote:In reading through the instructions, I'm not sure if my format is supported. My episodes are organized as follows:

server://tv/Show Name/Season 1/01 - Episode.ext

If possible, how would I make this work properly?

Thanks in advance!

I don't think the format you want is supported....

Quote:--rename-format:{formatstring}
the format to use if renaming to a new format (as specified above)
Hint: including the Episode Title as part of the name slows the process down a bit since titles are retrieved from thetvdb.com
The formatstring can be made up of:
[SHOW_NAME]: "My Show"
[EP1]: "S01E01"
[EP2]: "1x1"
[EP3]: "1x01"
[EP_NAME1] " - Episode Title"
[EP_NAME2] ".Episode Title"
If not specified the format is, "[SHOW_NAME] - [EP1][EP_NAME1]"
For example:
for "My Show S01E01 - Episode Title" (this is the default)
--rename-format:[SHOW_NAME] - [EP1][EP_NAME1]

All episode naming seems to include the season number as well, which is a good thing IMO. The script is still definetly worth it with everything else it does!
Reply
I'm trying to get the xbmc-remote-control option to update my library automatically. I however get the following error message:

WARN: Could not connec to xbmc server: Invalid argument

Any ideas?
Reply
So even though my format isn't supported, I spent the day yesterday getting uTorrent and this script setup on my F12 server. It's awesome to say the least. Thanks to the dev for creating and maintaining this script. I see your paypal account growing shortly. Wink

I am having a couple issues that I hope you guys can help me out with however:
Code:
SortTV
~~~~~~
Sorting:
        From /mnt/samba/Videos/Unsorted TV/
        TV episodes into /mnt/samba/TV/
10:20:33, 22-0-2012
could not find ParserDetails.ini in /usr/local/lib/perl5/site_perl/5.10.0/XML/SAX
Warning:  TBDB::API: No series id found for: 73696
WARN: Could not get episode title for CSI NY Season 8 Episode 11.
MOVE EPISODE: sorting /mnt/samba/Videos/Unsorted TV/CSI.NY.S08E11.HDTV.XviD-LOL.avi --to--> /mnt/samba/TV/CSI- NY/Season 8/8x11.avi
The first is that even though I ran CPAN XML::SAX, I am still getting the "could not find ParserDetails.ini in /usr/local/lib/perl5/site_perl/5.10.0/XML/SAX" error.

EDIT: I was finally able to get this corrected. Do the following as root if you are experiencing this issue:
Code:
perl -MXML::SAX -e "XML::SAX->add_parser(q(XML::SAX::PurePerl))->save_parsers()"


The second is that even though I have added the following lines:
Code:
show-name-substitute=CSI New York-->CSI: NY
tvdb-id-substitute:CSI NY-->73696
tvdb-id-substitute:CSI New York-->73696
CSI: New York is not being found though it IS being moved to the correct directory: /mnt/samba/TV/CSI- NY/Season x/

Any help is greatly appreciated. Thanks in advance!

Also, I'd like to offer a suggestion... I am running this script entirely in the background on my server and I'm sure I'm not the only one. Therefore, if there is an update available and I don't happen to see it here, I'm never going to know. I would propose an option to have a message popup in XBMC when the script runs if an update is available.

Thanks again!

EDIT: Though I have no knowledge of perl whatsoever, I was able to modify the script to accommodate my naming convention: /Series/Season 1/01 - Episode.ext
If anyone is interested, or if the dev wants to add this to the next version, here is all I had to do:

After existing line 1438: my $ep3 = sprintf("%dx%02d", $series, $episode);
Add line:
Code:
my $ep4 = sprintf("%02d", $episode);
After existing line 1444: $newfilename =~ s/\[EP3]/$ep3/ig;
Add line:
Code:
$newfilename =~ s/\[EP4]/$ep4/ig;

And if you want to modify the help section:
After existing line 668: [EP3]: "1x01"
Add line:
Code:
[EP4]: "01" (Episode number only)

Don't forget to change your .conf file to use the new formatting rule.
The XBMC team, plug-in devs, skinners, etc. do this for us for FREE in their spare time because they want to. Think about that for a second before you start bitching...
Reply
Ok, so i've hit the same problem as mentioned right back at the start of the thread, can't use TheMovieDB:

Quote:Running install for module 'WWW::TheMovieDB::Search'
Running make for P/PJ/PJOBSON/WWW-TheMovieDB-Search-0.03.tar.gz
Checksum for /home/simon/.cpan/sources/authors/id/P/PJ/PJOBSON/WWW-TheMovieDB-Search-0.03.tar.gz ok

CPAN.pm: Building P/PJ/PJOBSON/WWW-TheMovieDB-Search-0.03.tar.gz

Checking if your kit is complete...
Looks good
Warning: prerequisite Switch 0 not found.
Writing Makefile for WWW::TheMovieDB::Search
Writing MYMETA.yml and MYMETA.json
---- Unsatisfied dependencies detected during ----
---- PJOBSON/WWW-TheMovieDB-Search-0.03.tar.gz ----
Switch [requires]
Running make test
Delayed until after prerequisites
Running make install
Delayed until after prerequisites
Running install for module 'Switch'
Running make for R/RG/RGARCIA/Switch-2.16.tar.gz
Checksum for /home/simon/.cpan/sources/authors/id/R/RG/RGARCIA/Switch-2.16.tar.gz ok

CPAN.pm: Building R/RG/RGARCIA/Switch-2.16.tar.gz

Checking if your kit is complete...
Looks good
Writing Makefile for Switch
Writing MYMETA.yml and MYMETA.json
cp Switch.pm blib/lib/Switch.pm
Manifying blib/man3/Switch.3
RGARCIA/Switch-2.16.tar.gz
/usr/bin/make -- OK
'YAML' not installed, will not store persistent state
Running make test
PERL_DL_NONLAZY=1 /usr/local/bin/perl "-MExtUtils::Command::MM" "-e" "test_harness(0, 'blib/lib', 'blib/arch')" t/*.t
t/given.t ... Useless use of numeric gt (>) in void context at t/given.t line 19.
t/given.t ... Failed 2/293 subtests
t/nested.t .. ok
t/switch.t .. ok

Test Summary Report
-------------------
t/given.t (Wstat: 0 Tests: 293 Failed: 2)
Failed tests: 2-3
Files=3, Tests=590, 0 wallclock secs ( 0.05 usr 0.00 sys + 0.33 cusr 0.00 csys = 0.38 CPU)
Result: FAIL
Failed 1/3 test programs. 2/590 subtests failed.
make: *** [test_dynamic] Error 255
RGARCIA/Switch-2.16.tar.gz
/usr/bin/make test -- NOT OK
//hint// to see the cpan-testers results for installing this module, try:
reports RGARCIA/Switch-2.16.tar.gz
Running make install
make test had returned bad status, won't install without force
Running make for P/PJ/PJOBSON/WWW-TheMovieDB-Search-0.03.tar.gz
Has already been unwrapped into directory /home/simon/.cpan/build/WWW-TheMovieDB-Search-VVDiKe

CPAN.pm: Building P/PJ/PJOBSON/WWW-TheMovieDB-Search-0.03.tar.gz

Warning: Prerequisite 'Switch => 0' for 'PJOBSON/WWW-TheMovieDB-Search-0.03.tar.gz' failed when processing 'RGARCIA/Switch-2.16.tar.gz' with 'make_test => NO'. Continuing, but chances to succeed are limited.
cp lib/WWW/TheMovieDB/Search.pm blib/lib/WWW/TheMovieDB/Search.pm
Manifying blib/man3/WWW::TheMovieDB::Search.3
PJOBSON/WWW-TheMovieDB-Search-0.03.tar.gz
/usr/bin/make -- OK
Running make test
PERL_DL_NONLAZY=1 /usr/local/bin/perl "-MExtUtils::Command::MM" "-e" "test_harness(0, 'blib/lib', 'blib/arch')" t/*.t
t/WWW-TheMovieDB-Search.t .. 1/1
# Failed test 'use WWW::TheMovieDB::Search;'
# at t/WWW-TheMovieDB-Search.t line 9.
# Tried to use 'WWW::TheMovieDB::Search'.
# Error: Can't locate Switch.pm in @INC (@INC contains: /home/simon/.cpan/build/WWW-TheMovieDB-Search-VVDiKe/blib/lib /home/simon/.cpan/build/WWW-TheMovieDB-Search-VVDiKe/blib/arch /usr/local/lib/perl5/site_perl/5.15.4/x86_64-gnukfreebsd /usr/local/lib/perl5/site_perl/5.15.4 /usr/local/lib/perl5/5.15.4/x86_64-gnukfreebsd /usr/local/lib/perl5/5.15.4 .) at /home/simon/.cpan/build/WWW-TheMovieDB-Search-VVDiKe/blib/lib/WWW/TheMovieDB/Search.pm line 8.
# BEGIN failed--compilation aborted at /home/simon/.cpan/build/WWW-TheMovieDB-Search-VVDiKe/blib/lib/WWW/TheMovieDB/Search.pm line 8.
# Compilation failed in require at (eval 4) line 2.
# BEGIN failed--compilation aborted at (eval 4) line 2.
# Looks like you failed 1 test of 1.
t/WWW-TheMovieDB-Search.t .. Dubious, test returned 1 (wstat 256, 0x100)
Failed 1/1 subtests

Test Summary Report
-------------------
t/WWW-TheMovieDB-Search.t (Wstat: 256 Tests: 1 Failed: 1)
Failed test: 1
Non-zero exit status: 1
Files=1, Tests=1, 0 wallclock secs ( 0.02 usr 0.00 sys + 0.05 cusr 0.00 csys = 0.07 CPU)
Result: FAIL
Failed 1/1 test programs. 1/1 subtests failed.
make: *** [test_dynamic] Error 1
PJOBSON/WWW-TheMovieDB-Search-0.03.tar.gz
one dependency not OK (Switch); additionally test harness failed
/usr/bin/make test -- NOT OK
//hint// to see the cpan-testers results for installing this module, try:
reports PJOBSON/WWW-TheMovieDB-Search-0.03.tar.gz
Running make install
make test had returned bad status, won't install

edit: i should note that I'm running kFreeBSD which is effectively Debian Squeeze running on a BSD core, so although it's one of the more exotic OSes out there, it should have more in common with Debian-based issues than anything else.

further edit: the above problem was caused by a dependency that wouldn't install unless sudo was used. Problem is now solved
Fileserver: Athlon 7850 | 8GB RAM | 5x2TB RAID-Z2 | Ubuntu Trusty | Lian Li PC-A05B

HTPC: Raspberry Pi 2 with OSMC
Reply
I am running sorttv on a linux box which has the media disks mounted via NFS, so the season image symlinks created confused the hell out of XBMC. I've created a small patch to enable copying instead. This is the result of diff -u. Am I doing this correctly? I'm not familiar with perl.

Code:
--- v1.31/sorttv/sorttv.pl      2011-08-18 15:52:19.000000000 +0200
+++ sorttv.pl   2012-01-30 13:37:28.146018869 +0100
@@ -73,6 +73,7 @@
my $renameformat = "[SHOW_NAME] - [EP1][EP_NAME1]";
my $movierenameformat = "[MOVIE_TITLE] [YEAR2]/[MOVIE_TITLE] [YEAR1]";
my $fetchmovieimages = "TRUE";
+my $copyseasonimages = "FALSE";
my $treatdir = "RECURSIVELY_SORT_CONTENTS";
my $fetchimages = "NEW_SHOWS";
my $imagesformat = "POSTER";
@@ -135,6 +136,7 @@
        "fetch-tv-images|fetch-images|fi=s" => \$fetchimages,
        "fetch-movie-images|fi=s" => \$fetchmovieimages,
        "images-format|im=s" => \$imagesformat,
+       "copy-season-images|csi=s" => \$copyseasonimages,
        "require-show-directories-already-exist|rs=s" => \$needshowexist,
        "force-windows-compatible-filenames|fw=s" => \$windowsnames,
        "rename-tv-format|rename-format|rf=s" => \$renameformat,
@@ -723,6 +725,10 @@
        RECURSIVELY_SORT_CONTENTS - doesn't move directories, just their contents, including subdirectories
        IGNORE - ignores directories
        If not specified, RECURSIVELY_SORT_CONTENTS
+
+--copy-images=[TRUE|FALSE]
+       Season images are copied (as opposed to symlinked) to the season subdirectories.
+       If not specified, FALSE.

--require-show-directories-already-exist=[TRUE|FALSE]
        Only sort into show directories that already exist
@@ -1247,9 +1253,20 @@
        copy ("$scriptpath/.cache/$fanart", "$newshowdir/fanart.jpg") if $fanart && -e "$scriptpath/.cache/$fanart";
        copy ("$scriptpath/.cache/$banner", "$newshowdir/banner.jpg") if $banner && -e "$scriptpath/.cache/$banner";
        copy ("$scriptpath/.cache/$poster", "$newshowdir/poster.jpg") if $poster && -e "$scriptpath/.cache/$poster";
-       my $ok = eval{symlink "$newshowdir/poster.jpg", "$newshowdir/folder.jpg" if $poster && -e "$scriptpath/.cache/$poster" && $imagesformat eq "POSTER";};
+       my $ok = 0;
+        if($copyseasonimages eq "TRUE") {
+               out("std", "Copying poster\n");
+               $ok = eval{copy "$newshowdir/poster.jpg", "$newshowdir/folder.jpg" if $poster && -e "$scriptpath/.cache/$poster" && $imagesformat eq "POSTER";};
+       } else {
+                out("std", "Symlinking poster\n");
+               $ok = eval{symlink "$newshowdir/poster.jpg", "$newshowdir/folder.jpg" if $poster && -e "$scriptpath/.cache/$poster" && $imagesformat eq "POSTER";};
+       }
        if(!defined $ok) {copy "$newshowdir/poster.jpg", "$newshowdir/folder.jpg" if $poster && -e "$scriptpath/.cache/$poster" && $imagesformat eq "POSTER";};
-       $ok = eval{symlink "$newshowdir/banner.jpg", "$newshowdir/folder.jpg" if $banner && -e "$scriptpath/.cache/$banner" && $imagesformat eq "BANNER";};
+       if($copyseasonimages eq "TRUE") {
+               $ok = eval{copy "$newshowdir/banner.jpg", "$newshowdir/folder.jpg" if $banner && -e "$scriptpath/.cache/$banner" && $imagesformat eq "BANNER";};
+       } else {
+               $ok = eval{symlink "$newshowdir/banner.jpg", "$newshowdir/folder.jpg" if $banner && -e "$scriptpath/.cache/$banner" && $imagesformat eq "BANNER";};
+       }
        if(!defined $ok) {copy "$newshowdir/banner.jpg", "$newshowdir/folder.jpg" if $banner && -e "$scriptpath/.cache/$banner" && $imagesformat eq "BANNER";};
}

@@ -1261,7 +1278,12 @@
        my $snum = sprintf("%02d", $season);
        copy ("$scriptpath/.cache/$banner", "$newshowdir/season${snum}.jpg") if $banner && -e "$scriptpath/.cache/$banner" && $imagesformat eq "POSTER";
        copy ("$scriptpath/.cache/$bannerwide", "$newshowdir/season${snum}.jpg") if $bannerwide && -e "$scriptpath/.cache/$bannerwide" && $imagesformat eq "BANNER";
-       my $ok = eval{symlink "$newshowdir/season$snum.jpg", "$seasondir/folder.jpg" if -e "$newshowdir/season$snum.jpg";};
+       my $ok = 0;
+       if($copyseasonimages) {
+               $ok = eval{copy "$newshowdir/season$snum.jpg", "$seasondir/folder.jpg" if -e "$newshowdir/season$snum.jpg";};
+       } else {
+               $ok = eval{symlink "$newshowdir/season$snum.jpg", "$seasondir/folder.jpg" if -e "$newshowdir/season$snum.jpg";};
+       }
        if(!defined $ok) {copy "$newshowdir/season$snum.jpg", "$seasondir/folder.jpg" if -e "$newshowdir/season$snum.jpg";};
}
Reply
Hi there, I'd like to request what should be a trivial feature - I'd code it myself but the baby at home and the boss at work have other ideas!

Could you add an option to do nothing (fail) when TVDB information is unavailable? I love love love sorttv, but I've spent rather more time than should be necessary cleaning up when it's plowed ahead and created a new show when it couldn't match a misspelled or poorly formatted name.

This is useful for me because I run the script twice - once on a folder that is automatcally populated (by RSS) with files that can generally be trusted for naming and formatting, and once on a folder for files that we add ourselves, which are much less reliable. They're sorted to the same destination, though.

Thanks for your time, and thanks for sorttv.pl!
Reply
wererogue Wrote:Hi there, I'd like to request what should be a trivial feature - I'd code it myself but the baby at home and the boss at work have other ideas!

Could you add an option to do nothing (fail) when TVDB information is unavailable? I love love love sorttv, but I've spent rather more time than should be necessary cleaning up when it's plowed ahead and created a new show when it couldn't match a misspelled or poorly formatted name.

This is useful for me because I run the script twice - once on a folder that is automatcally populated (by RSS) with files that can generally be trusted for naming and formatting, and once on a folder for files that we add ourselves, which are much less reliable. They're sorted to the same destination, though.

Thanks for your time, and thanks for sorttv.pl!
What he said. This goes for one annoying little "bug" I have. When there is no episode name and it sorts it goes without that. But when TVDB is updated it also creates a second link, so sometimes i get double episodes in XBMC. Blush
Samsung ES7005 55" led tv - Denon AVR-3313 - NAD C275BEE - B&W DM683 - B&W HTM61 - B&W 686
Intel NUC D34010WYK - 128GB Crucial ssd, Built in IR Receiver
And a Logitech Harmony Touch to control it all. https://libreelec.tv
Retired: Asus EB1501P ION2 - OCZ Vertex 2 64gb ssd - Built in IR Receiver
Reply
Ok, after finding a little time to look at the script I see that it's not entirely trivial - it looks like the flow needs a little reworking to make failing clean at that point?

Anyway, I'll keep poking at it (and learning perl) when I get the chance, unless someone beats me to it.
Reply
Thanks guys. Its great to see some code being contributed! I'll merge code into the next release soon. I've just moved house (to the UK) and started a new job, so SortTV development had slowed down. However, I have had a chance to implement a few of the feature requests, so expect a release some time in the next few weeks.

wererogue Wrote:Ok, after finding a little time to look at the script I see that it's not entirely trivial - it looks like the flow needs a little reworking to make failing clean at that point?

Anyway, I'll keep poking at it (and learning perl) when I get the chance, unless someone beats me to it.

The simplest solution would be to do something around
Code:
$name = $tvdb->getEpisodeName($showtitle, $series, $episode);

Something like (pseudo-code):
Code:
if not defined $name AND config option for forcing it is enabled
    out "warn", "SKIP: failed to retrieve episode name"
    return (break out of function)

Its not a pretty flow, but that would be acceptable in this case. Feel free to come up with a better solution if you can.

I look forward to the patch.

Cheers.
Reply
  • 1
  • 28
  • 29
  • 30(current)
  • 31
  • 32
  • 49

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