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

  Thread Rating:
  • 6 Votes - 5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Post Reply
Xian Offline
Junior Member
Posts: 1
Joined: May 2014
Reputation: 0
Post: #646
Hei,
I'm using windows 8 and Strawberry Pearl. I end up with similar problem to Scorrsburg.

(2012-12-09 15:41)cliffe Wrote:  
(2012-12-09 06:55)Scottsburg Wrote:  
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

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.
(2012-12-10 01:07)Scottsburg Wrote:  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});

I don't get how to solve it. And I dont understand how to implement Scottsburg solution. Kinda new when it comes to programing,

Any help would be much appericiated.

Many Thx
find quote
zapho Offline
Junior Member
Posts: 2
Joined: Jun 2014
Reputation: 0
Post: #647
Hi cliffe,

Thanks for a wonderful script - it was exactly what I was looking for!

I've only been using the script (version 1.37) a short while and noticed a slight issue which I think is worth reporting. Its not exactly a bug but hopefully this might help you out in the future.
I was having trouble trying to match this file with name: "harry_potter_and_the_philosphers_stone" - it would find the right result but fail after "INFO: Comparing ......".

I noticed the problem was that the sub "fixtitle" was producing two different results from the $title and $moviename - and the reason was due to all the underscores.
Fixtitle won't remove the substrings "and" or "the" from my example filename because the regex you're using is looking for whitespaces on either side of the those substrings.

The simple fix was to add the following right before line 1044.
$title =~ s/_/ /ig;

Anyway, hope this helps.
Cheers!
find quote
mybrain87 Offline
Junior Member
Posts: 47
Joined: Dec 2008
Reputation: 0
Post: #648
What would I need to edit to make sorttv rename tv shows and movies all in lowcase.
I want all my files to be lowcase.

can somebody help me please?
find quote
Fox Offline
Senior Member
Posts: 134
Joined: Oct 2003
Reputation: 1
Post: #649
(2014-06-16 20:32)mybrain87 Wrote:  What would I need to edit to make sorttv rename tv shows and movies all in lowcase.
I want all my files to be lowcase.

can somebody help me please?

I don't think there is such an option right now, but if you feel like editing the code a bit it should be fairly simple.
Around row 1819 where you have the if($usedots eq "TRUE") {, I say around because I don't think I have the latest version, if you add
$newfilename = lc($newfilename);
just above I think that should do the trick, but thats the hard-coded and not so nice version. If you want to make it changeable from the config have a look at the
use-dots-instead-of-spaces bool and do something similar.

If you find any spelling mistakes you can keep them ;)
find quote
mybrain87 Offline
Junior Member
Posts: 47
Joined: Dec 2008
Reputation: 0
Post: #650
(2014-06-16 21:01)Fox Wrote:  
(2014-06-16 20:32)mybrain87 Wrote:  What would I need to edit to make sorttv rename tv shows and movies all in lowcase.
I want all my files to be lowcase.

can somebody help me please?

I don't think there is such an option right now, but if you feel like editing the code a bit it should be fairly simple.
Around row 1819 where you have the if($usedots eq "TRUE") {, I say around because I don't think I have the latest version, if you add
$newfilename = lc($newfilename);
just above I think that should do the trick, but thats the hard-coded and not so nice version. If you want to make it changeable from the config have a look at the
use-dots-instead-of-spaces bool and do something similar.

That worked great for tvshows. Thank you very much.

What do i need to change to make lowcase work for movies?
find quote
Fox Offline
Senior Member
Posts: 134
Joined: Oct 2003
Reputation: 1
Post: #651
(2014-06-16 21:14)mybrain87 Wrote:  That worked great for tvshows. Thank you very much.

What do i need to change to make lowcase work for movies?

Oh thought that would fix it for both, but then maybe you could change it in the cleanup_filename function instead.
If you add $title = lc($title); at the end of the function (but before the return) it should clean it up for both.

If you find any spelling mistakes you can keep them ;)
find quote
mybrain87 Offline
Junior Member
Posts: 47
Joined: Dec 2008
Reputation: 0
Post: #652
(2014-06-16 21:53)Fox Wrote:  
(2014-06-16 21:14)mybrain87 Wrote:  That worked great for tvshows. Thank you very much.

What do i need to change to make lowcase work for movies?

Oh thought that would fix it for both, but then maybe you could change it in the cleanup_filename function instead.
If you add $title = lc($title); at the end of the function (but before the return) it should clean it up for both.

Big Grin Thanks that did it
find quote
mrbrookz Offline
Junior Member
Posts: 2
Joined: Jul 2014
Reputation: 0
Post: #653
Hi! The script works well, thank you so much for this. I have encountered a problem and I'm not quite sure as to how I could go about resolving it:

I have installed the modules with cpan as explained in the tread and the readme. I installed the modules using the "sudo" option rather than "local:lib" as I wanted other users to be able to access them too in case they would want to run the script.

Here is the problem I encounter:
When I run the script as a user
Code:
perl ./sorttv.pl
I get the following:
Code:
DBM::Deep: Cannot write to a readonly filehandle at /usr/local/lib/perl5/site_perl/5.20.0/TVDB/API.pm line 458
But when I run the script with
Code:
sudo perl ./sorttv.pl
the script runs fine without any problems.
Is this caused by installation of modules with cpan using the "sudo" option? If so, should I reinstall them with cpan and the local:lib option?
I did have to force install the module "File::Glob".

The other problem I encounter is when running the other line of code recommended in the readme:
Code:
perl -MXML::SAX -e "XML::SAX->add_parser(q(XML::SAX::Expat))->save_parsers()"
I get the following error:
Code:
Can't locate XML/Parser.pm in @INC (you may need to install the XML::Parser module) (@INC contains: /usr/local/lib/perl5/site_perl/5.20.0/x86_64-linux /usr/local/lib/perl5/site_perl/5.20.0 /usr/local/lib/perl5/5.20.0/x86_64-linux /usr/local/lib/perl5/5.20.0 .) at /usr/local/lib/perl5/site_perl/5.20.0/XML/SAX/Expat.pm line 11.
BEGIN failed--compilation aborted at /usr/local/lib/perl5/site_perl/5.20.0/XML/SAX/Expat.pm line 11.
Compilation failed in require at /usr/local/lib/perl5/site_perl/5.20.0/XML/SAX.pm line 147.

Do I need to install other modules? Not sure this is essential since the script seems to run fine without it.

In case this is important, I am running this on ubuntu 12.04.
Any help is highly appreciated.


EDIT: I think I may not have had the right permissions on the script or contents in its folder.
Code:
sudo chmod -R user:user /opt/sorttv/
I think this may have fixed it for me. Still having the second problem, but not sure if it is essential for me?
(This post was last modified: 2014-07-19 00:03 by mrbrookz.)
find quote
mrbrookz Offline
Junior Member
Posts: 2
Joined: Jul 2014
Reputation: 0
Post: #654
I have been testing this script with cron, and using the README instructions I have:
Code:
0 * * * * nice perl /opt/sorttv/sorttv.pl

But I get the error message:
Code:
Can't locate WWW/TheMovieDB.pm in @INC (@INC contains: /etc/perl /usr/local/lib/perl/5.14.2 /usr/local/share/perl/5.14.2 /usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.14 /usr/share/perl/5.14 /usr/local/lib/site_perl +.) at /opt/sorttv/sorttv.pl line 58.

I have installed all the modules, when running cpan .... all required modules are installed successfully and are up to date. The script works fine when run from a user in the terminal. I have entered the information using "crontab -e" under the same user account. Not sure if this is a permissions problem?
find quote
Post Reply