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)



- CoinTos - 2010-10-24

Quote:Could you explain how the naming for these works (is it just that it contains those words? proper/repack), as I have come across these but never given it much thought. As implemented, if it contains "proper" or "repack" it overwrites existing files with the same resulting sorted name.

You are only going to see these once in a while unless there is a release war, that is when you see Real Proper, etc. But most of the time at least with the rss feed I deal with I only see the occational proper or repack trump their original release listing.

Quote:That is fixed now in v1.10, and seems to sort fine. Can't seem to get details from thetvdb for that particular show, but for now that doesn't seem to be a big deal.

So with show-name-substitute:Shit My Dad Says-->$#*! My Dad Says
it sorts for you? For me it still fails with the same error.
Here is my diff file just incase it is my little mod's fault. Diff File


- Malexx - 2010-10-25

Just tried the script the first time and running into following Problem.
I have some Tv recordings which are titled in german.
When i run the script i get this error:

Sorting D:\Download\Series/ into Z:\/
INFO: trying to move Malcolm Mittendrin season 7 episode 1
INFO: found a matching show:
Z:\/Malcolm Mittendrin
INFO: found a matching season:
Z:\/Malcolm Mittendrin/Season 7
INFO: Fetching episode title for Malcolm Mittendrin Season 7 Episode 1.
←[33mWarning: TBDB::API: No series id found for: Malcolm Mittendrin
WARN: Could not get episode title for Malcolm Mittendrin Season 7 Episode 1.

"Malcolm mittendrin" is in English "Malcolm in the Middle"
So do all my Shows have to be labeled in English to get this to work?

I looked into TVDB for this Show and its labeld in German there like this:
Showtitle:Malcolm mittendrin LanguageBig Grineutsch ID:7383

What is causing the problem here,can anybody gimme some help on this?Really like to use this script ....

Modules are loaded ok
CPAN: CPAN::SQLite loaded ok (v0.199)
Database was generated on Sun, 24 Oct 2010 23:29:41 GMT
CPAN: Module::CoreList loaded ok (v2.36)
File::Copy::Recursive is up to date (0.38).
File::Glob is up to date (1.07).
LWP::Simple is up to date (5.835).
TVDB::API is up to date (0.33).

thanks for any help!!!

Edit:
Found a littlr workaround but its not really satisfying.
What i did was add this to config file:

show-name-substitute:Malcolm mittendrin-->Malcolm in the middle

and now i get this :

Sorting D:\Download\Series/ into Z:\/
INFO: trying to move Malcolm mittendrin season 7 episode 1
INFO: found a matching show:
Z:\/Malcolm mittendrin
INFO: found a matching season:
Z:\/Malcolm mittendrin/Season 7
INFO: Fetching episode title for Malcolm in the middle Season 7 Episode 1.
COPY: sorting D:\Download\Series/Malcolm mittendrin.7x01.Burning Man.sdtv.
avi to Z:\/Malcolm mittendrin/Season 7/Malcolm in the middle.7x01.Burning Man.av

My Problem is now thatall my Shows are labeled in English.

Would it be possible that this script support multiple Languages?


- cliffe - 2010-10-25

CoinTos Wrote:You are only going to see these once in a while unless there is a release war, that is when you see Real Proper, etc. But most of the time at least with the rss feed I deal with I only see the occational proper or repack trump their original release listing.



So with show-name-substitute:Shit My Dad Says-->$#*! My Dad Says
it sorts for you? For me it still fails with the same error.
Here is my diff file just incase it is my little mod's fault. Diff File

Yeah it should work...

Try it without your modifications.

Here is what I get with
force-windows-compatible-filenames:TRUE
and
show-name-substitute:Shit My Dad Says-->$#*! My Dad Says

(Create test files...)
Code:
cliffe@linux-beco:~/sorttv> touch '/home/cliffe/Files/Downloads/Unsorted/$#*! My Dad Says s1e1.avi'
cliffe@linux-beco:~/sorttv> touch '/home/cliffe/Files/Downloads/Unsorted/Shit My Dad Says s1e2.avi'
(Run SortTV...)
Code:
cliffe@linux-beco:~/sorttv> perl sorttv.pl
SortTV
~~~~~~
15:32:55, 25-9-2010
Sorting /home/cliffe/Files/Downloads/Unsorted/ into /home/cliffe/Files/Media/TV/
INFO: making show directory: /home/cliffe/Files/Media/TV/$#-! My Dad Says
DOWNLOAD: downloading images for $#*! My Dad Says
INFO: making season directory: /home/cliffe/Files/Media/TV/$#-! My Dad Says/Season 1
DOWNLOAD: downloading season image for $#*! My Dad Says
WARN: Could not get episode title for $#*! My Dad Says Season 1 Episode 1.
MOVE: sorting /home/cliffe/Files/Downloads/Unsorted/$#*! My Dad Says s1e1.avi to /home/cliffe/Files/Media/TV/$#-! My Dad Says/Season 1/$#-! My Dad Says - S01E01.avi
WARN: Could not get episode title for $#*! My Dad Says Season 1 Episode 2.
MOVE: sorting /home/cliffe/Files/Downloads/Unsorted/Shit My Dad Says s1e2.avi to /home/cliffe/Files/Media/TV/$#-! My Dad Says/Season 1/$#-! My Dad Says - S01E02.avi
(Check contents of sorted directory...)
Code:
cliffe@linux-beco:~/sorttv> ls -R /home/cliffe/Files/Media/TV/
/home/cliffe/Files/Media/TV/:
$#-! My Dad Says

/home/cliffe/Files/Media/TV/$#-! My Dad Says:
Season 1

/home/cliffe/Files/Media/TV/$#-! My Dad Says/Season 1:
$#-! My Dad Says - S01E01.avi  $#-! My Dad Says - S01E02.avi

After you have checked that v1.10 works you can try adding capitalisation to titles. Do this where directories are created, and where episodes are being renamed. If that works, please send me a patch. Then try adding the renaming thing. At first glance, your substitution code looks ok.


- cliffe - 2010-10-25

v1.11:

New feature:
--lookup-language:[en|...]
Set language for thetvdb lookups, this effects episode titles etc
Valid values include: it, zh, es, hu, nl, pl, sl, da, de, el, he, sv, eng, fi, no, fr, ru, cs, en, ja, hr, tr, ko, pt
If not specified, en (English)

This should work with any of the languages supported by the thetvdb.com

Malexx Wrote:Would it be possible that this script support multiple Languages?

I don't know whether that includes German. I searched on thetvdb.com for "Malcolm mittendrin" and it was found as Dutch.

You may want to have it scheduled to try German, then Dutch, then English.

Good luck.

Update: I see you mentioned that it is available in German on thetvdb.com, so hopefully it should work... Not sure which abbreviation is for German though.


- Targettio - 2010-10-25

cliffe Wrote:v1.10:

I did a quick test on Windows and it seems to work on my system (Win7 32bit Strawberry Perl v5.10.1). However, it was very slow at downloading the images and they did not display properly. So for now I recommend Windows users disable the download images feature by editing the sorttv.conf file to include:

fetch-images:FALSE
(rather than "fetch-images:NEW_SHOWS")

Since I cannot replicate the problem reported earlier (DBM: Deep : Cannot sysopen file '/.tvdb' : Permission denied) I haven't sorted that out yet. Maybe you could try to figure out which line it is crashing on by simply adding some
Code:
print "hasn't crashed yet 1";
lines. And see how far it gets before you get the error message.
.

OK I will have a go at de-bugging it tonight and let you know how I get on. Wink


- CoinTos - 2010-10-25

Quote:Yeah it should work...

Try it without your modifications.

Humm... I tried a clean 1.11 and I still get the error about the file already existing in the log, as I got in 1.10 with my mods.
Code:
INFO: making show directory: /raid/Media/TV_Shows/$#-! My Dad Says
INFO: making show directory: /raid/Media/TV_Shows/$#-! My Dad Says
WARN: Could not create show dir: /raid/Media/TV_Shows/$#-! My Dad Says:File exists
Checking if the file really exists:
Code:
root@lucy:/home/deluge/unsorted/tv_shows#  ls -l /raid/Media/TV_Shows/\$#-\!\ My\ Dad\ Says/
total 0
Nope, just the folder and it didn't get as far as Season # either.

This is the only show it does it for. If you leave it without the name sub to $#*! it sorts fine. After work today I will have to see if it something flakey in debian causing this, it's weird since it works fine on your system.


- Targettio - 2010-10-25

Using 1.11 modified as shown in the paste bin file

http://pastebin.com/02dajX3R

Quote:Got thorough the declirationsSortTV
~~~~~~~~~
DBM:: Deep: Cannot sysopen file '/.tvdb.db' : Permission denies
Got through the first if

So I guess it is around
Quote:my $TVDBAPIKEY = "FDDBDB916D936956";
my $tvdb = TVDB::API::new($TVDBAPIKEY);



- CoinTos - 2010-10-25

Ok, so now that I have work over with I now have solution for my problem with Shit My Dads Says. If I have a folder called Shit My Dad Says, it will sort $##! My Dad Says - S01E05.avi, no problem even with my mod. It doesn't like the folder being called $#-! or $##! or $#*! which for me is fine, I can always look into it at a later date.

Here my patch:
It adds the Text::Capitalize library, using the capitalize_title function it will format the show title properly even if the release group didn't. It will only change the show title as long as you do not have a name-subsitution otherwise the name-sub overrides it.

Patch Here

Text::Capitalize CPAN Doc


- Malexx - 2010-10-26

cliffe Wrote:v1.11:

New feature:
--lookup-language:[en|...]
Set language for thetvdb lookups, this effects episode titles etc
Valid values include: it, zh, es, hu, nl, pl, sl, da, de, el, he, sv, eng, fi, no, fr, ru, cs, en, ja, hr, tr, ko, pt
If not specified, en (English)

This should work with any of the languages supported by the thetvdb.com



I don't know whether that includes German. I searched on thetvdb.com for "Malcolm mittendrin" and it was found as Dutch.

You may want to have it scheduled to try German, then Dutch, then English.

Good luck.

Update: I see you mentioned that it is available in German on thetvdb.com, so hopefully it should work... Not sure which abbreviation is for German though.

Thank you very much,its working like a charm.
You do a great Job with this script and your support is superb !!!
Do you think somehow,someday there willl be a way for faster copy or move with TVDB lookups?
If i move now files to my Western Digital over USB it transfer files with about 300-400kb.
Anyway ,thx again ...


- cliffe - 2010-10-26

Malexx Wrote:Thank you very much,its working like a charm.
You do a great Job with this script and your support is superb !!!
Do you think somehow,someday there willl be a way for faster copy or move with TVDB lookups?
If i move now files to my Western Digital over USB it transfer files with about 300-400kb.
Anyway ,thx again ...

Thanks. I am glad that works for you Smile

The lookups do slow down the sort, so if you want a really fast sort, the easy solution is to not include the episode title in renaming, and don't download images. One of the reasons it slows it down is because it all happens in one thread; that is, only one thing happens at once. It would certainly be possible to include multiple threads to allow it to download images in one thread and do the renaming and sorting in another thread. Separating the episode title lookups into a separate thread from the sorting is a bit more complicated, but could be done (where the sorting would have to wait on the lookups, but could happen concurrently). These improvements are not high on my priorities at the moment, unless someone wanted to have a go at implementing it.


New version available - cliffe - 2010-10-26

A new version of SortTV is now available.

Version 1.12 now capitalises show names, and should provide a work around for the earlier reported problem.

Thanks Targettio and CoinTos.

If you are updating you may need to install another module.
Run:
Code:
sudo cpan Text::Capitalize
Leave out the "sudo" if you are using Windows.

You can get the new version from:
https://sourceforge.net/projects/sorttv/files/

Targettio Wrote:Using 1.11 modified as shown in the paste bin file
http://pastebin.com/02dajX3R
So I guess it is around

Thanks. I restructured it so that if you disable the tvdb features it should work for you, to avoid the mysterious problem you have with the tvdb api module.

If you get this error message:
Code:
DBM: Deep : Cannot sysopen file '/.tvdb' : Permission denied
Disable the tvdb features in sorttv.conf:
Code:
fetch-images:FALSE
rename-format:[SHOW_NAME] - [EP1]
I.e. Turn off image downloading and set the rename to not include the episode title. Alternatively, turn off renaming by setting:
Code:
fetch-images:FALSE
rename-episodes:FALSE


CoinTos Wrote:Ok, so now that I have work over with I now have solution for my problem with Shit My Dads Says. If I have a folder called Shit My Dad Says, it will sort $##! My Dad Says - S01E05.avi, no problem even with my mod. It doesn't like the folder being called $#-! or $##! or $#*! which for me is fine, I can always look into it at a later date.

Ok. Glad you found a work around; create a directory named the title to substitute.

CoinTos Wrote:Here my patch:
It adds the Text::Capitalize library, using the capitalize_title function it will format the show title properly even if the release group didn't. It will only change the show title as long as you do not have a name-subsitution otherwise the name-sub overrides it.

Patch Here

Text::Capitalize CPAN Doc

Thanks. I made some changes: I added capitalisation for show directories created during directory sorts, and added preserve caps, so, for example, CSI doesn't become Csi.


- Targettio - 2010-10-26

I currently have the renaming and image downloading set to FALSE (all I want to do is move the tv shows to the right folder), so maybe that has something to do with it? Either I will check the new version tonight.

I will try with renaming/images on and off and let you know.


- CoinTos - 2010-10-26

cliffe Wrote:Thanks. I made some changes: I added capitalisation for show directories created during directory sorts, and added preserve caps, so, for example, CSI doesn't become Csi.

Yeah, I thought about that too and had that in my first mod, the only problem with that is if a filename is in all caps it will ignore them and if CSI is all lower case it will only fix the C without name sub over riding it.


- cliffe - 2010-10-26

CoinTos Wrote:Yeah, I thought about that too and had that in my first mod, the only problem with that is if a filename is in all caps it will ignore them and if CSI is all lower case it will only fix the C without name sub over riding it.

Good point. Thanks. v1.13 fixes that by being case insensitive for substitutions.

That is, "CSI" or "csi" would be substituted by "CSI: Crime Scene Investigation"
Due to this line in the config file:
show-name-substitute:CSI-->CSI: Crime Scene Investigation

Cheers.


- nicx76 - 2010-10-26

hi,

this tool sound great. one question: is it possible to scape episode and season numbers by episode and show name from thetvdb.com? that would be THE toll i am looking for weeks now Wink

nicx...