SortTV: Sort TV episodes, movies, and music into directories for xbmc (Linux/Win/Mac)

  Thread Rating:
  • 8 Vote(s) - 4.88 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Post Reply
CoinTos Offline
Member
Posts: 90
Joined: Oct 2010
Reputation: 0
Location: Canada
Post: #151
Malexx Wrote:Yes i have this.
Is this batch script otherwise correct?
So if there is
Code:
perl sorttv.pl --directory-to-sort:D:\Download\Series --directory-to-sort-into:E:\HD Serien
perl sorttv.pl --directory-to-sort:D:\Download\Series --directory-to-sort-into:Z:\
it should start the second call if it found nothing in the first?

Yes, your batch will run each instance that you put in there. It runs each line one at a time when the first is done it calls the second and so on.

You also may want @echo off at the top of your batch script if you want it to run silent.

@cliffe:
You may want to change the handling of database update command to xbmc, I'll add it to my list of things to send a patch for if I get the time. Basically, just sorted a season folder and the pop for each new file is nice, the db update starting and then restarting after each one not so nice, little rough on the old xbox. Smile It should only issue that command once an instance, basically the script needs a flag that on exit if has done any sorting it should then send the update command (if xbmc setting is set, of course).
find quote
cliffe Offline
Senior Member
Posts: 185
Joined: Jun 2010
Reputation: 8
Post: #152
Malexx Wrote:Yes i have this.
Is this batch script otherwise correct?
So if there is
Code:
perl sorttv.pl --directory-to-sort:D:\Download\Series --directory-to-sort-into:E:\HD Serien
perl sorttv.pl --directory-to-sort:D:\Download\Series --directory-to-sort-into:Z:\
it should start the second call if it found nothing in the first?

Yes, it will move shows into the first place they already exist. (eg if you have "E:\HD Serien\MyShow" then "MyShow s1e1" will be moved there) Or to try to sort from "D:\Download\Series" moving into "E:\HD Serien" if the directories already exist, then otherwise creating dirs in "Z:\":

Code:
perl sorttv.pl --directory-to-sort:D:\Download\Series --directory-to-sort-into:E:\HD Serien --require-show-directories-already-exist:TRUE
perl sorttv.pl --directory-to-sort:D:\Download\Series --directory-to-sort-into:Z:\ --require-show-directories-already-exist:FALSE
find quote
cliffe Offline
Senior Member
Posts: 185
Joined: Jun 2010
Reputation: 8
Post: #153
CoinTos Wrote:Yes, your batch will run each instance that you put in there. It runs each line one at a time when the first is done it calls the second and so on.

You also may want @echo off at the top of your batch script if you want it to run silent.

@cliffe:
You may want to change the handling of database update command to xbmc, I'll add it to my list of things to send a patch for if I get the time. Basically, just sorted a season folder and the pop for each new file is nice, the db update starting and then restarting after each one not so nice, little rough on the old xbox. Smile It should only issue that command once an instance, basically the script needs a flag that on exit if has done any sorting it should then send the update command (if xbmc setting is set, of course).

There is a variable (IIRC named xbmcnew) with a list of all the new episodes, used to send the last message, if that isn't empty it could send the update command. I thought that was how it was setup already, but you are probably right.
find quote
CoinTos Offline
Member
Posts: 90
Joined: Oct 2010
Reputation: 0
Location: Canada
Post: #154
cliffe Wrote:There is a variable (IIRC named xbmcnew) with a list of all the new episodes, used to send the last message, if that isn't empty it could send the update command. I thought that was how it was setup already, but you are probably right.

Oh, there could be, I haven't looked at the code just reporting what I saw on the xbmc when it sorted a season folder, so a tweak may be in order.

Update:
Look at the code and it has to do with the sub call to displayandupdateinfo. I will submit a patch regarding this as display and update should be separate. Right now to move a season with recursive sort it will call displayandupdateinfo for each new ep. It should only call update on exit, so it looks like the xbmc update command needs to be moved to your $newshow notify if statement and maybe even need a config parameter for those that use the script in batch file. Smile
(This post was last modified: 2010-11-11 23:13 by CoinTos.)
find quote
nicx76 Offline
Member
Posts: 92
Joined: Feb 2010
Reputation: 0
Post: #155
any hints to my problem?

nicx...
find quote
TravellingGuy Offline
Junior Member
Posts: 33
Joined: Nov 2010
Reputation: 2
Post: #156
Hey Cliffe.

Awesome program, it works on almost all of my files.

But I do have one problem/request. Daily shows like "The Daily Show with Jon Stewart" and "The Colbert Report" that I'm getting are often not in an S##E## format, instead of a 2010.11.10 format (i.e. The.Colbert.Report.2010.11.09.Cee-Lo.Green.HDTV.Xvid.avi ). As a result, tvsort isn't recognizing them and dumps them into the non-episode-dir location. I tried match-type:LIBERAL hoping it might figure it out, but didn't.

Can you please add support for daily shows that use a year.month.day format?

Also, any thoughts of adding support for figuring out and properly parsing movies? :-)
(Ok, so I had two requests!)

Thanks
TravellingGuy
find quote
newphreak Offline
Donor
Posts: 196
Joined: Oct 2010
Reputation: 4
Location: sofa @ Norway
Post: #157
nice work cliffe. both features works fine.
however it seems i need some help sorting perl and thetvdb api.

Code:
INFO: trying to move Burn.Notice season 4 episode 13
could not find ParserDetails.ini in /usr/local/share/perl/5.10.0/XML/SAX
Warning:  TBDB::API: No series id found for: BurnNotice
DBM::Deep: Cannot write to a readonly filehandle at /usr/local/share/perl/5.10.0/TVDB/API.pm line 458

Any ideas what i should poke with a stick to fix this?
find quote
cliffe Offline
Senior Member
Posts: 185
Joined: Jun 2010
Reputation: 8
Post: #158
nicx76 Wrote:wow, thanks a lot! Smile

nicx...

EDIT: just tested it, but its not working... if i start it with option "treat-directories:RECURSIVELY_SORT_CONTENTS" its running for hours without exeptions or renaming actions, if i use "treat-directories:IGNORE" its immedeately ending without renaming any file. so what does this parameter do that it affects the script even if i choose "directory-to-sort-into:KEEP_IN_SAME_DIRECTORIES"?

my folder structure is:
D:\videos\series\<series title>\<series title - episode name>.ts and i want to rename all files recursevly in D:\videos\series\

should this work?

nicx...

Try:
Code:
perl sorttv.pl --directory-to-sort:D:\videos\series\ --directory-to-sort-into:KEEP_IN_SAME_DIRECTORIES --match-files-named-showname-episodetitle:TRUE --xbmc-web-server: --fetch-images:FALSE
and report what happens.

Update: To answer your question: treat-directories:RECURSIVELY_SORT_CONTENTS will go through all directories to do the sort looking at the names of all the contained files, treat-directories:AS_FILES_TO_SORT will just rename/sort the directories and files directly in the directory-to-sort (it would rename directories rather than look at what files and directories are in them), and IGNORE would only deal with files in the directory-to-sort, ignoring all directories entirely.
(This post was last modified: 2010-11-14 15:27 by cliffe.)
find quote
cliffe Offline
Senior Member
Posts: 185
Joined: Jun 2010
Reputation: 8
Post: #159
CoinTos Wrote:Oh, there could be, I haven't looked at the code just reporting what I saw on the xbmc when it sorted a season folder, so a tweak may be in order.

Update:
Look at the code and it has to do with the sub call to displayandupdateinfo. I will submit a patch regarding this as display and update should be separate. Right now to move a season with recursive sort it will call displayandupdateinfo for each new ep. It should only call update on exit, so it looks like the xbmc update command needs to be moved to your $newshow notify if statement and maybe even need a config parameter for those that use the script in batch file. Smile

Yep, just a matter of moving the call to update the library to where the final message is sent. Smile For now I wouldn't worry about adding a config for that, since it could be done by setting the xbmc server to "" if they don't want updates. It wouldn't be hard to allow multiple destinations in the script, but I don't consider that a high priority since it can be scripted.
find quote
cliffe Offline
Senior Member
Posts: 185
Joined: Jun 2010
Reputation: 8
Post: #160
newphreak Wrote:nice work cliffe. both features works fine.
however it seems i need some help sorting perl and thetvdb api.

Code:
INFO: trying to move Burn.Notice season 4 episode 13
could not find ParserDetails.ini in /usr/local/share/perl/5.10.0/XML/SAX
Warning:  TBDB::API: No series id found for: BurnNotice
DBM::Deep: Cannot write to a readonly filehandle at /usr/local/share/perl/5.10.0/TVDB/API.pm line 458

Any ideas what i should poke with a stick to fix this?

That looks like a bug in the TVDB API Perl module, which is a fantastic module that allows Perl scripts to talk to thetvdb.com The author is Behan Webster. His email address is behanw AT websterwood DOT com. You could try reporting the problem to him. Please share any advice you get.

Alternatively just turn off those features of SortTV with the --no-network switch.
find quote
cliffe Offline
Senior Member
Posts: 185
Joined: Jun 2010
Reputation: 8
Post: #161
TravellingGuy Wrote:Hey Cliffe.

Awesome program, it works on almost all of my files.

But I do have one problem/request. Daily shows like "The Daily Show with Jon Stewart" and "The Colbert Report" that I'm getting are often not in an S##E## format, instead of a 2010.11.10 format (i.e. The.Colbert.Report.2010.11.09.Cee-Lo.Green.HDTV.Xvid.avi ). As a result, tvsort isn't recognizing them and dumps them into the non-episode-dir location. I tried match-type:LIBERAL hoping it might figure it out, but didn't.

Can you please add support for daily shows that use a year.month.day format?

Also, any thoughts of adding support for figuring out and properly parsing movies? :-)
(Ok, so I had two requests!)

Thanks
TravellingGuy

This is possible, and would be similar to how CoinTos got the "Show title - Episode title" matching working. Are you interested in having a go at implementing this? I can help you out and point you in the right direction. If you are not interested in perl programming then CoinTos or I may implement it later.
find quote
nicx76 Offline
Member
Posts: 92
Joined: Feb 2010
Reputation: 0
Post: #162
cliffe Wrote:Try:
Code:
perl sorttv.pl --directory-to-sort:D:\videos\series\ --directory-to-sort-into:KEEP_IN_SAME_DIRECTORIES --match-files-named-showname-episodetitle:TRUE --xbmc-web-server: --fetch-images:FALSE
and report what happens.

Update: To answer your question: treat-directories:RECURSIVELY_SORT_CONTENTS will go through all directories to do the sort looking at the names of all the contained files, treat-directories:AS_FILES_TO_SORT will just rename/sort the directories and files directly in the directory-to-sort (it would rename directories rather than look at what files and directories are in them), and IGNORE would only deal with files in the directory-to-sort, ignoring all directories entirely.

hi,

i just tried it (with an subdirectory of the main one because this is very large), this is the output:

D:\Software\HTPC\SortTV\sorttv>perl sorttv.pl --directory-to-sort:"D:\videos\serien\desperate housewives" --directory-to-sort-into:KEEP_IN_SAME_DIRECTORIES --match-files-named-showname-episodetitle:TRUE --xbmc-web-server: --fetch-images:FALSE
SortTV
~~~~~~
WARN: Couldn't open config file 'D:\Software\HTPC\SortTV\sorttv/sorttv.conf': No such file or directory
INFO: An example config file is available and can make using SortTV easier
14:21:1, 14-10-2010 Sorting D:\videos\serien\desperate housewives/ into KEEP_IN_SAME_DIRECTORIES
Use of uninitialized value $matchtype in string eq at sorttv.pl line 137.
Use of uninitialized value $matchtype in string eq at sorttv.pl line 137.

but no files are renamed Sad

regards,
nicx...
find quote
cliffe Offline
Senior Member
Posts: 185
Joined: Jun 2010
Reputation: 8
Post: #163
nicx76 Wrote:hi,

i just tried it (with an subdirectory of the main one because this is very large), this is the output:

D:\Software\HTPC\SortTV\sorttv>perl sorttv.pl --directory-to-sort:"D:\videos\serien\desperate housewives" --directory-to-sort-into:KEEP_IN_SAME_DIRECTORIES --match-files-named-showname-episodetitle:TRUE --xbmc-web-server: --fetch-images:FALSE
SortTV
~~~~~~
WARN: Couldn't open config file 'D:\Software\HTPC\SortTV\sorttv/sorttv.conf': No such file or directory
INFO: An example config file is available and can make using SortTV easier
14:21:1, 14-10-2010 Sorting D:\videos\serien\desperate housewives/ into KEEP_IN_SAME_DIRECTORIES
Use of uninitialized value $matchtype in string eq at sorttv.pl line 137.
Use of uninitialized value $matchtype in string eq at sorttv.pl line 137.

but no files are renamed Sad

regards,
nicx...

Please try:
Code:
perl sorttv.pl "--directory-to-sort:D:\videos\serien\desperate housewives" --directory-to-sort-into:KEEP_IN_SAME_DIRECTORIES --match-files-named-showname-episodetitle:TRUE --xbmc-web-server: --fetch-images:FALSE --verbose:TRUE
find quote
CoinTos Offline
Member
Posts: 90
Joined: Oct 2010
Reputation: 0
Location: Canada
Post: #164
cliffe Wrote:This is possible, and would be similar to how CoinTos got the "Show title - Episode title" matching working. Are you interested in having a go at implementing this? I can help you out and point you in the right direction. If you are not interested in perl programming then CoinTos or I may implement it later.

I have already written it, it will be in my next patch with a few other bug fixes including utf8 support for episode names. ie. NCIS - S02E12 - Doppelgänger.avi

Cliffe, there is a little problem in the perl TVDB::API with changing the maxEpisode with setConf() and having it register in getEpisode(), I written quick fix for sorttv script for the time being but it not what I would call the best solution.

Edit: Also, looked into the image issues with windows and unless a patch is submitted to TVDB::API it will never work. If you look at the source for the api you can see that when creating the image files it doesn't write in binmode so windows mucks them up.
(This post was last modified: 2010-11-14 17:48 by CoinTos.)
find quote
cliffe Offline
Senior Member
Posts: 185
Joined: Jun 2010
Reputation: 8
Post: #165
CoinTos Wrote:I have already written it, it will be in my next patch with a few other bug fixes including utf8 support for episode names. ie. NCIS - S02E12 - Doppelgänger.avi

Cliffe, there is a little problem in the perl TVDB::API with changing the maxEpisode with setConf() and having it register in getEpisode(), I written quick fix for sorttv script for the time being but it not what I would call the best solution.

Edit: Also, looked into the image issues with windows and unless a patch is submitted to TVDB::API it will never work. If you look at the source for the api you can see that when creating the image files it doesn't write in binmode so windows mucks them up.

Cool. I am looking forward to the patch (no rush though). Sounds like you’ve added some nice features.

Regarding the TVDB API module, there have been quite a few comments where people have come across issues. Hopefully the author will be happy to receive patches or constructive feedback. I encourage you to contact him with a small patch for the images bug. Let me know how that goes. By contributing to that project you will be helping to improve any scripts that use that module.

Thanks!
find quote
Post Reply