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

+- Kodi Community Forum (https://forum.kodi.tv)
+-- Forum: Support (https://forum.kodi.tv/forumdisplay.php?fid=33)
+--- Forum: Supplementary Tools for Kodi (https://forum.kodi.tv/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 46 47 48 49


RE: SortTV: Sort TV episodes, movies, and music into directories for xbmc (Linux/Win/Mac) - FoeT - 2015-01-09

I have no perl experience but hacked this which works. Just comment (#) out the code thats currently in place in the "sub update_xbmc {" section and replace it with this.

my $jsonUrl = sprintf("http://127.0.0.1:8080/jsonrpc");
my $jsonReq = "\{\"jsonrpc\"\: \"2.0\", \"method\": \"VideoLibrary.Scan\", \"id\"\: 1\}";
my $http = HTTP::Request->new('POST', $jsonUrl);
$http->header('Content-Type' => 'application/json');
$http->content($jsonReq);
# Fire off the request.
my $ua = LWP::UserAgent->new;
my $res = $ua->request($http);
die "Couldn't post request" unless defined $res;
# Return the HTTP status and exit.
printf("Library Updated: %s\n", $res->status_line);
#print $res;

my $jsonUrl2 = sprintf("http://127.0.0.1:8080/jsonrpc");
my $jsonReq2 = "{\"jsonrpc\":\"2.0\",\"method\":\"GUI.ShowNotification\",\"params\":{\"title\":\"New Shows Available to Watch\",\"message\":\"$new\",\"image\":\"\"},\"displaytime\":10000,\"id\":1}\n";
my $http2 = HTTP::Request->new('POST', $jsonUrl2);
$http2->header('Content-Type' => 'application/json');
$http2->content($jsonReq2);
# Fire off the request.
my $ua2 = LWP::UserAgent->new;
my $res2 = $ua2->request($http2);
die "Couldn't post request" unless defined $res2;
# Return the HTTP status and exit.
printf("Sent message: %s\n", $res2->status_line);
#print $res;


RE: SortTV: Sort TV episodes, movies, and music into directories for xbmc (Linux/Win/Mac) - mrbrookz - 2015-01-12

(2010-06-20, 09:59)cliffe Wrote: ~~~~~~

---
Automation

If you want to make it sort new episodes every hour:

On Linux:
In a console type: crontab -e
On a new line enter "5 * * * * " followed by the command to run the script.
This will run the script 5 mins past every hour.
Eg:
5 * * * * nice perl /home/cliffe/sorttv/sorttv.pl

Every hour this would sort new episodes according to the configuration in /home/cliffe/sorttv/sorttv.conf

Hi Cliffe,

Just wanted to suggest a small change to the README info for automation, after installing the perl modules, for cron to work properly, the correct full path for perl needs to be specified.
For me, this was: "/usr/local/bin/perl"
not just "perl" or "/usr/bin/perl", otherwise cron doesn't have access to the modules, in particular, the TVDB one, for which perl 5.2 was installed with cpan

This might save some others a bit of time.


RE: SortTV: Sort TV episodes, movies, and music into directories for xbmc (Linux/Win/Mac) - Nekromantik - 2015-01-18

Just used the latest version on Windows.
Works well but it missed a lot of files.

Examples of file names and folder names it missed are:

Lo (2009)/Lo DVDrip (2009).avi
I.Am.Nancy.2010.720p.BluRay.x264/ly-iamnancy720.mkv

and files

PSYCHO.III.1986.DVDRip.WS.XviD.avi
Romeos.2011.DVDRip.XviD.avi


RE: SortTV: Sort TV episodes, movies, and music into directories for xbmc (Linux/Win/Mac) - The_Countess - 2015-01-19

(2015-01-09, 03:58)FoeT Wrote: I have no perl experience but hacked this which works. Just comment (#) out the code thats currently in place in the "sub update_xbmc {" section and replace it with this.

i tried this (after changing to port 80 instead of 8080) and it reports back "library updated: 200 OK" and "Send message: 200 OK" on the command line.

but the library isn't updated and no message was displayed unfortunately

i'm using openElec 5.0.0 (64bits)
(installed activeperl and added the dependencies... but cpan doesn't work so i had to use the install (as described here http://openelec.tv/forum/71-pvr-live-tv/40321-xmltv-adding-a-new-grabber).

the names you have to use are different though so i had to translate.
i think i got all the dependencies correctly and don't get any errors besides one about not finding info for WWW and YTS in the tv series database.. which is just the first and second word of a release group jpg file

i installed the watchdog addon in the mean time (which just checks for changes on the hdd and if it finds any sends a update command) but that seems inelegant to me and probably keeps the machine awake when it doesn't need to be.


TVDB Lookup Error - Gfei - 2015-01-20

Quick question... has anyone else noticed problems sorting show names that start with numbers ie: 12 Monkeys. The script does not seem to be able to parse the title properly and ends up searching for "" on TVDB. This ends up causing an error to be thrown in the perl TVDB api. Here is the actual error:

Can't use string ("") as a HASH ref while "strict refs" in use at /usr/local/share/perl/5.14.2/TVDB/API.pm line 472.


RE: SortTV: Sort TV episodes, movies, and music into directories for xbmc (Linux/Win/Mac) - TwiztedIndian - 2015-01-21

Has anyone figured out how to properly setup config to sort "60 Minutes" episodes?

Using my feed to grab them they come in with the following file name format -> 60.Minutes.US.2015.01.11.HDTV.x264-W4F.mp4

This is causing issue with sorttv due to the lack of a season or episode number... Is there any solution for this or am I out of luck for this show?

Code:
SortTV
~~~~~~
Sorting:
        From /mnt/1TB/Torrents/completed/
        TV episodes into /mnt/1TB/TV/
        Movies into /mnt/1TB/Movies/
        Everything else into /mnt/1TB/Torrents/limbo/
22:43:42, 20-0-2015
WARN: Failed to get 60 Minutes US series information on the tvdb.com.
MOVE OTHER: sorting /mnt/1TB/Torrents/completed/60.Minutes.US.2015.01.11.HDTV.x264-W4F.mp4 --to--> /mnt/1TB/Torrents/limbo/60.Minutes.US.2015.01.11.HDTV.x264-W4F.mp4



RE: SortTV: Sort TV episodes, movies, and music into directories for xbmc (Linux/Win/Mac) - FoeT - 2015-01-23

(2014-11-03, 22:37)nickr Wrote: The current master code on sourceforge for this function is:

Code:
update_xbmc {
$new = '' if !$new;
my $sock = new IO::Socket::INET (
PeerAddr => $xbmcaddress,
PeerPort => $xbmcport,
Proto => 'tcp', 6 );
if($sock) {
print $sock '{"id":1,"method":"VideoLibrary.Scan","params":[],"jsonrpc":"2.0"}';
print $sock '{"jsonrpc": "2.0", "method": "VideoLibrary.ScanForContent", "id": 1}\n';
print $sock "{\"jsonrpc\":\"2.0\",\"method\":\"GUI.ShowNotification\",\"params\":{\"title\":\"New Shows Available to Watch\",\"message\":\"$new\",\"image\":\"\"},\"displaytime\":10000,\"id\":1}\n";
close($sock);
} else {
out("warn", "WARN: Could not connect to xbmc server: $!\n");
}

Which seems to send 3 JSON commands. The third is a notification.

The first two seem to be trying to scan, however the second one is wrong according to the current API. Perhaps due to the fact that all three commands have id of 1 the JSON server is getting confused? The JSON-RPC spec says:

Quote:id - The request id. This can be of any type. It is used to match the response with the request that it is replying to.
- I would have thought the id should be unique if you are sending three commands in rapid succession.

The code doesn't seem to do anything with the response either. Surely it should? How else does it tell that the command was successful. The ionly thing it seems to test is whether a socket is actually established. That doesn't tell you if the command is successful.

(2015-01-19, 19:06)The_Countess Wrote:
(2015-01-09, 03:58)FoeT Wrote: I have no perl experience but hacked this which works. Just comment (#) out the code thats currently in place in the "sub update_xbmc {" section and replace it with this.

i tried this (after changing to port 80 instead of 8080) and it reports back "library updated: 200 OK" and "Send message: 200 OK" on the command line.

but the library isn't updated and no message was displayed unfortunately

i'm using openElec 5.0.0 (64bits)
(installed activeperl and added the dependencies... but cpan doesn't work so i had to use the install (as described here http://openelec.tv/forum/71-pvr-live-tv/40321-xmltv-adding-a-new-grabber).

the names you have to use are different though so i had to translate.
i think i got all the dependencies correctly and don't get any errors besides one about not finding info for WWW and YTS in the tv series database.. which is just the first and second word of a release group jpg file

i installed the watchdog addon in the mean time (which just checks for changes on the hdd and if it finds any sends a update command) but that seems inelegant to me and probably keeps the machine awake when it doesn't need to be.

Slight change and I tested it works.


RE: SortTV: Sort TV episodes, movies, and music into directories for xbmc (Linux/Win/Mac) - staticxsoil71 - 2015-01-24

is it possible to add an option to convert season numbers for shows that are listed on TVDB by year.
Paws Stars is what im currently having problems with. The files are listed as S12 but TVDB list them by year. If i rename the file so S2015 they sort correctly.


RE: SortTV: Sort TV episodes, movies, and music into directories for xbmc (Linux/Win/Mac) - nickr - 2015-01-24

(2015-01-24, 00:19)staticxsoil71 Wrote: is it possible to add an option to convert season numbers for shows that are listed on TVDB by year.
Paws Stars is what im currently having problems with. The files are listed as S12 but TVDB list them by year. If i rename the file so S2015 they sort correctly.
filebot handles that correctly


RE: SortTV: Sort TV episodes, movies, and music into directories for xbmc (Linux/Win/Mac) - magnumk - 2015-01-25

I've been having this issue for years and I can't find any solution to it.

SortTv won't sort shows that starts with the letter S, and give the wrong name for shows that contains it.
If a show for an example is called "Man Seeking Woman", SortTv will handle this as if the show is called "Man" and sort the files in to the folder "Man".

And for example Suits, it will ignore it and leave these files untouched...

For shows with the letter S in it i use the "show-name-substitute", this works for the most (even if it is annoying)

Example for shows with letter S in the name:
show-name-substitute=The Leftover-->The Leftovers
show-name-substitute=Intruder-->Intruders
show-name-substitute=The Mentali-->The Mentalist
show-name-substitute=Bo-->Bosch
show-name-substitute=12 Monkey-->12 Monkeys
show-name-substitute=Back-->Backstrom
show-name-substitute=Man-->Man Seeking Woman

Any thoughts?


SortTV hangs and never completes - Toddmc - 2015-02-10

I'm having trouble getting sorttv to work correctly. It used to sort everything fine but some time last year it started hanging.

The script would freeze up, take a bunch of cpu time, and never finish. Sometimes it would work, sometimes not. Turns out the problem is TV shows. It sorts movies, music, and misc fine if I turn off the tv show option. Unfortunately my main use for it is sorting TV episodes. Fiddling around a little more it's not every TV show episode, sometimes it will sort a couple and then hit one it can't handle and hang. Using verbose it hangs at the step INFO: Fetching episode title for whatever. If I set --rename-episodes=FALSE then the script does not hang, but of course the episode titles are not consistent. Which seems like it could cause problems.

The problem does not seem to be file names, permissions, or formats. It just doesn't seem to like certain episodes. Mythbusters almost always hangs it.

So any thoughts on why this is happening and how I could fix it? Is my TVDB not installed correctly, or perhaps a bug in the script or the wrong version of perl? I'm using perl 5.20.1.

Edit: It also doesn't like if an archer episode leaves out the 2009, maybe it's checking the wrong show.

Edit 2: Taking EP_NAME out of rename-tv-format also works.


RE: SortTV: Sort TV episodes, movies, and music into directories for xbmc (Linux/Win/Mac) - nickr - 2015-02-10

thetvdb does have its downtime quite frequently.

Archer is a different series to Archer (2009).

Have you tried filebot? I haven't used sort tv, but I know filebot is great.


RE: SortTV: Sort TV episodes, movies, and music into directories for xbmc (Linux/Win/Mac) - Toddmc - 2015-02-12

(2015-02-10, 21:06)nickr Wrote: thetvdb does have its downtime quite frequently.

Archer is a different series to Archer (2009).

Have you tried filebot? I haven't used sort tv, but I know filebot is great.

It's not related to downtime with tvdb. Other episodes will work fine, then one will stall out sorttv. Also XBMC can then pull in the information that sorttv fails. It has to be a bug with sorttv or the tvdb module. Sorttv really needs to timeout if it fails to pull an episode title, it already does that if it fail to pull the episode image.

In any case I don't care enough to fiddle with it any more, I'm keeping that feature turned off.

Filebot's not in my repo and it looks like more work than it's worth for a feature I don't need.


RE: SortTV: Sort TV episodes, movies, and music into directories for xbmc (Linux/Win/Mac) - nickr - 2015-02-12

filebot is very easy, and IMHO worth the effort.


RE: SortTV: Sort TV episodes, movies, and music into directories for xbmc (Linux/Win/Mac) - Toddmc - 2015-02-17

(2015-01-09, 03:58)FoeT Wrote: I have no perl experience but hacked this which works. Just comment (#) out the code thats currently in place in the "sub update_xbmc {" section and replace it with this.

my $jsonUrl = sprintf("http://127.0.0.1:8080/jsonrpc");
my $jsonReq = "\{\"jsonrpc\"\: \"2.0\", \"method\": \"VideoLibrary.Scan\", \"id\"\: 1\}";
my $http = HTTP::Request->new('POST', $jsonUrl);
$http->header('Content-Type' => 'application/json');
$http->content($jsonReq);
# Fire off the request.
my $ua = LWP::UserAgent->new;
my $res = $ua->request($http);
die "Couldn't post request" unless defined $res;
# Return the HTTP status and exit.
printf("Library Updated: %s\n", $res->status_line);
#print $res;

my $jsonUrl2 = sprintf("http://127.0.0.1:8080/jsonrpc");
my $jsonReq2 = "{\"jsonrpc\":\"2.0\",\"method\":\"GUI.ShowNotification\",\"params\":{\"title\":\"New Shows Available to Watch\",\"message\":\"$new\",\"image\":\"\"},\"displaytime\":10000,\"id\":1}\n";
my $http2 = HTTP::Request->new('POST', $jsonUrl2);
$http2->header('Content-Type' => 'application/json');
$http2->content($jsonReq2);
# Fire off the request.
my $ua2 = LWP::UserAgent->new;
my $res2 = $ua2->request($http2);
die "Couldn't post request" unless defined $res2;
# Return the HTTP status and exit.
printf("Sent message: %s\n", $res2->status_line);
#print $res;

I got a concatenation error in the second paragraph. I deleted it rather than try to debug it, the GUI notification seems useless to me anyway.

The first paragraph works fine and updates the library. I changed the first line so it would respect the xbmc address settings, since mine is not on the local machine.

my $jsonUrl = sprintf("http://%s:%s/jsonrpc",$xbmcaddress,$xbmcport);

For anyone testing this remember that the script only updates your library if it finds a new file to sort.