• 1
  • 35
  • 36
  • 37(current)
  • 38
  • 39
  • 49
SortTV: Sort TV episodes, movies, and music into directories for xbmc (Linux/Win/Mac)
I have tried all I can and now Im in over my head. There has to be an easier way of doing what I want. Time to try another script.
Reply
(2012-10-30, 17:30)Lord_Kami Wrote: Found a bug in the latest stable version. Multi volume rar-archives where files are named .*part[number].rar, sorttv extracts each and every .rar resulting in a very time and space consuming operation.

Is it possible to work from a list of files in this situation and only extract once?

You can use something like this, or list archives with unrar and then make a list in perl.
Code:
unrar lt -v <file> | grep -E '^Volume' | colrm 1 7

I'm not sure if this applies to other types of archives. I usually run sorttv in a cron-job.

Sounds like a good idea. I'll add it to the TODO list, patches welcome!
Reply
Sorry I haven't had a chance to reply earlier. Anyway, here are some short responses.

(2012-11-03, 09:14)Topgunn Wrote: Hi, I am new to this script and Ive been having a few problems and hence have a few questions. I have been playing around with linux for a little while but Im still a novice with Google being my best friend. After my list of problems you will probably think why bother but the lure of completely automating my system and the fact Im always up for a challenge has me wanting to get it all sorted.
The plan is to run the script when a torrent completes in transmission but for now I just have it sorting my existing download directory.
Ill start with the same problem Lord_Kami is having. Any folder with multipart rars is being unrared times how ever many parts there are so I completely agree its a very time and space consuming operation.
Another problem Im having has been mentioned before in this thread but Im not sure how to fix it. I have both compressed and normal files in my download location and if I set sort-by=COPY so I can keep seeding it leaves a (extracted by sorttv) folder that Transmission wont remove when the torrent ends. I have tried to put (extracted by sorttv) in the delete section of the config but I cant get the script to delete it.

The pattern matching is case sensitive, so a delete config line would have to be something like:

delete=*(extracted by SortTV)

However, the deletes happen after extractions and before the sorting happens, so you would have to run the script to extract and sort, and then again to delete. Then again, what you want is so specific that it might be easiest to just write a short Bash/Perl script to do that.

Ignoring for the moment multipart rar files, if the extraction works properly and you use sort-by MOVE, then the extracted by SortTV directory is removed by SortTV once it is empty.

(2012-11-03, 09:14)Topgunn Wrote: My current work around that I came up with is two copies of the script with different configs, one that processes normal files and copies them and the other that processes rars and moves them. I made a basic shell script that calls the normal/copy one first and when that finishes the next rar/move one does any that the first one didnt do. This works but I know it is far from ideal and I would rather have it setup so the one script works by copying all actual files (including whats in the rars) but after a successful copy deleting the rar files it creates and I was wondering what it is exactly I have to put in the script config to delete them?
Also when I run the script back over the same folder and files it seems to uncompress them again before it realises that its already done that file and proceeds to skip it. Thats also putting a lot of unnecessary load on my server along with it processing multipart rars individually. I can see in verbose mode that it can see the file name before it attempts to uncompress it so it should compare then and not after. If my planned integration with transmission works that should take care of it but it might be something that needs looking at.
Sounds reasonable...

(2012-11-03, 09:14)Topgunn Wrote: Now to my next question,
When Transmission finishes downloading it can call a script and pass on a few parameters including the downloaded torrents name. If I can use the torrent name when calling the script for eg. perl /path/to/script/sorttv.pl "$TORRENT_NAME" would that work to call the script on that file? I think thats the right way to pull the file name out but if I try to call the script onto an actual file name as a test with no other parameters it makes a folder in the source files directory and not in the destination that I put in the config. Surely I dont have to put the paths to each directory when I call the script? I saw in the readme that you can do perl sorttv.pl --directory-to-sort=/home/me/Downloads --directory-to-sort-into=/home/me/Videos/TV --non-episode-dir=/home/me/Videos/Non-episodes but what about movies or music etc?
If I use the argument file-to-sort= "$TORRENT_NAME" in the config and then just Transmission to call perl /path/to/script/sorttv.pl when a download completes would that work or would it still just put it into the directory where the source file came from?
You can put settings in the sorttv.conf file and then override some with command line arguments. For example, put all the directories you always want to sort into in the config file, and leave the source directory blank.

From transmission set it to run
perl sorttv.pl file-to-sort=$TORRENT_NAME

And you can do your usual sorts with:
perl sorttv.pl directory-to-sort=/your_source_directory

(2012-11-03, 09:14)Topgunn Wrote: At the moment the script cant seem to find specials against standard scene release names on the TvDb such as Show Name.S01.Special.Episode title.HDTV.x264-Scene.Group.mp4. I have all the matching and renaming options still at default and I can find it manually on the TvDb listed as a special in Season 1. It picked up the normal episodes ok so I dont know what to change there or if thats a bug.
I realise Im asking for a fair bit here but hopefully I can help somewhat aswell.
I hope I have explained myself properly.
Thanks so much for any help.
edit: just trying to think of different ways of doing what I want

No one has mentioned sorting specials before. Looks like a reasonable feature request. I don't have time to code it at the moment, but again I really do welcome patches Smile

(2012-11-07, 01:43)Topgunn Wrote: Ok Ive played around with it a bit and had a bit more of a think and im starting to sort out my problems. I managed to find an expression that the script would pick up to delete the folder left behind from the extract process but then i got a :is a directory error so researched how perl deletes files and found the unlink command in the script and that it only deletes files. I then looked up how to delete non-empty directories instead and found the rmtree command so I changed unlink to rmtree in the script and added use File:Tongueath; to the top and bingo it worked. At this stage that folder is the only thing I want deleted so I can leave it like that for now. I doubt it will still delete files but I could add in another argument with unlink if I want that.
This is the first time Ive ever asked for help in a forum because I normally just work out how to do things for myself and I understand people arent here for my beckoned call so its probably a blessing that I havent received any help as yet. Obviously it would make it a lot easier for me but at the same time it feels so good to work things out for yourself. So either way I realise that was my first post here and it was a big one. As I work out the problems Ill post back just in case it can help anyone else in the future.

Yeah, no worries. SortTV also deletes empty directories, so I think you can probably just change the delete pattern to something like:
delete=*directory-name-to-delete/*

(2012-11-08, 01:36)Topgunn Wrote: I have tried all I can and now Im in over my head. There has to be an easier way of doing what I want. Time to try another script.

Well, hopefully this post helps. In the future, perhaps break your questions down more clearly so that it is easier to parse and respond.

Good luck!
Reply
Thanks so much for the replies to my problems. Sorry my questions were so jumbled too. There was a lot of playing around between posts and I got a bit lost, and carried away lol. I think your response has helped me a lot though.
I did try delete=*(extracted by SortTv)/* but it wouldnt delete the folder because it still had the data inside.
The other way I thought to do it is to have a transmission call a bash script that then executed a copy on complete script thats on their forums to move the data a temp folder on my storage drive combined with yours to unrar if needed and then move from the temp directory to the TV one and keep the original on my download/seeding drive to be deleted when it finishes.
If I can just get the scripts called on the torrent and not the whole directory by using $TORRENT-NAME and doing what you suggested with the config it should execute pretty quickly.
I guess ill try to integrate it both ways and see what works best for me.
Ill try to research how to get the specials working and try the code from Lord Kami for the multipart rars and if I can get all this autonomous I will be so happy!
Thanks again for working through my mess and giving me some pointers. I was going to try filebot next but getting that to do exactly what I want would probably be even harder and now hopefully I wont have to because this will be perfect Smile
Reply
So I'm setting up my first install of XBMC, and this script was exactly what I needed to move and sort my latest downloads. I really want this setup to happen, but I cannot get this script working. I'm running on 64bit Windows 7 SP1, using Strawberry Pearl 5.16.2.1

I had to do a force install of WWW::TheMovieDB::Search, as it failed the test initially, but I believe all of the modules are now installed. The error I'm getting is:

Code:
DBM::Deep: Cannot sysopen file '/.tvdb.db': Permission denied

I found reference to this error in the thread way back in 2010, but the only solution then was to setup the config file so the script doesn't require a connection to TheTVDB. However when I do that (no file renaming, no downloading artwork) I get this error message:

Code:
Can't call method "getSeries" on an undefined value at ./SortTV/sorttv.pl line 1705

Any help would be much appreciated.
Reply
(2012-12-09, 06:55)Scottsburg Wrote: So I'm setting up my first install of XBMC, and this script was exactly what I needed to move and sort my latest downloads. I really want this setup to happen, but I cannot get this script working. I'm running on 64bit Windows 7 SP1, using Strawberry Pearl 5.16.2.1

I had to do a force install of WWW::TheMovieDB::Search, as it failed the test initially, but I believe all of the modules are now installed. The error I'm getting is:

Code:
DBM::Deep: Cannot sysopen file '/.tvdb.db': Permission denied

I found reference to this error in the thread way back in 2010, but the only solution then was to setup the config file so the script doesn't require a connection to TheTVDB. However when I do that (no file renaming, no downloading artwork) I get this error message:

Code:
Can't call method "getSeries" on an undefined value at ./SortTV/sorttv.pl line 1705

Any help would be much appreciated.

Check the permissions on sorttv/.cache/.tvdb.db

Perhaps try setting the permissions as liberally as possible (Grant Everyone all permissions to everything in .cache). See if that helps, and set the permissions to something that makes sense afterwards.
Reply
I know just enough about scripting to get myself in trouble, but here's how I got it to work (probably not the best method, but...)

I debugged 'sorttv.pl' and the script was stopping at line #294
Code:
$tvdb = TVDB::API::new($TVDBAPIKEY);
The directory ".cache" and the file ".tvdb.db" were not being created at all. I looked through the code for TVDB::API and it tries to create it's database file as soon as an instance is called, using the default location "$ENV{HOME}/.tvdb.db"

In the code for 'sorttv.pl', after the new $tvdb instance is created, the script then creates the '.cache' directory and sets that folder as the location for the $tvdb database. I assumed there was some kind of permission issue going on that didn't allow the code in TVDB::API to create the database in the location it wanted, so I just commented out a line in '/strawberry/perl/site/lib/TVDB/API.pm' - line #74
Code:
$self->setCacheDB($args->{cache});

Script ran fine after that. Downloaded episode titles and everything.
Reply
(2012-11-10, 15:05)cliffe Wrote:
(2012-10-30, 17:30)Lord_Kami Wrote: Found a bug in the latest stable version. Multi volume rar-archives where files are named .*part[number].rar, sorttv extracts each and every .rar resulting in a very time and space consuming operation.

Is it possible to work from a list of files in this situation and only extract once?

You can use something like this, or list archives with unrar and then make a list in perl.
Code:
unrar lt -v <file> | grep -E '^Volume' | colrm 1 7

I'm not sure if this applies to other types of archives. I usually run sorttv in a cron-job.

Sounds like a good idea. I'll add it to the TODO list, patches welcome!

I have this problem too. Any progress? Filled the entire hd with one movie Big Grin

Thanks for the awesome program btw. Made everything so much easier!

Reply
I am having problems installing models in to perl. I run sudo perl -MCPAN -e 'install Debug::Simple'
and get this output:

Going to read '/home/logif/.cpan/Metadata'
Database was generated on Tue, 15 Jan 2013 13:53:03 GMT
Running install for module 'Debug::Simple'
Running make for B/BE/BEHANW/Debug-Simple-0.10.tar.gz
Checksum for /home/logif/.cpan/sources/authors/id/B/BE/BEHANW/Debug-Simple-0.10.tar.gz ok

CPAN.pm: Going to build B/BE/BEHANW/Debug-Simple-0.10.tar.gz

Checking if your kit is complete...
Looks good
Writing Makefile for Debug::Simple
Writing MYMETA.yml
BEHANW/Debug-Simple-0.10.tar.gz
make -- NOT OK
Running make test
Can't test without successful make
Running make install
Make had returned bad status, install seems impossible

it seems I have to have it installed to be able to install TVDB::ATI.
is there a lib for ubuntu or ... what am i doing wrong?

my system is Ubuntu server 12.04
Reply
Thanks for the script, works great here in OSX w/Plex + Transmission. But Ive been having problems sorting TDS lately

filename: The.Daily.Show.2013.02.07.Neil.Barofsky.720p.HDTV.x264-LMAO.mkv

results in it thinking its season 720 episode 264, and bails out because there's no folder: "The Daily Show 2013 02 07 Neil Barofsky"

any suggestions?
Reply
Trying to get this fantastic script working on my Win 7, 64-bit machine. I, too, am getting stuck when trying to install Switch. It keeps failing, even when I try to "force install" it.

Any suggestions? Thanks!
Reply
Switch seems to be gone in the newer versions of perl, if you grab switch.pm (in the perl/lib folder) from 5.12 and put in your folder it should work.
Thats what I did when I was trying out a new version of Strawberry at least.
If you find any spelling mistakes you can keep them ;)
Reply
I'm having a real problem getting the script to extract .rar files on OSX. Says there is an error and cannot find 7zip etc. I've tried a bunch of different extracting applications.. no luck. I've updated perl, and done whatever i could based on the other posts in this thread. Anyone else having this problem? Help!
Reply
(2013-02-25, 03:16)aestridge Wrote: I'm having a real problem getting the script to extract .rar files on OSX. Says there is an error and cannot find 7zip etc. I've tried a bunch of different extracting applications.. no luck. I've updated perl, and done whatever i could based on the other posts in this thread. Anyone else having this problem? Help!

The script won't/can't make use of any .app's you've installed. You need to find the command-line versions of those files and shove them in say /usr/bin (or somewhere on your PATH statement that sorttv.pl can find).
Reply
There is a problem with the script that occurs with one show.

When the show Tosh.0 exists in the watch folder, the script will start but then stall before moving any shows. It takes 100% of available CPU cycles but accomplishes nothing. It sits indefinitely. I have tried to make a rename in the .conf file to make this more tvdb friendly, but it still stalls the script.

I assume this is a problem with perl's syntax parsing dealing with the '.' (period) being part of the title. I assume the script uses the period as the delimiter between title and season which is what is throwing the script off.

Is this something anyone else has run into?
Reply
  • 1
  • 35
  • 36
  • 37(current)
  • 38
  • 39
  • 49

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