Page 1 of 1

[SOLVED] Subtitle download doesn't work from Cron

Posted: 13 Aug 2015, 00:08
by miguelitu
Hi, first of all, thank you rednoah for all your work and support.

I got my amc script working perfectly when I execute the command on a linux terminal, however, when automating it via cron or adding to torrent completion event in transmission, the subtitle download does not work.

From the log:

"Get [English] subtitles for 1 files
CmdlineException: OpenSubtitles: Please enter your login details by calling `filebot -script fn:configure`"

Of course, I already executed that command and it accepted the login details, thus why it is working when I execute the script from a command line.

Any idea how to fix this?

sys:info - Raspberry Pi 2
filebot -script fn:sysinfo
FileBot 4.6 (r3052)
JNA Native: 4.0.0
MediaInfo: MediaInfoLib - v0.7.58
p7zip: java.io.IOException: Cannot run program "7z": error=2, No such file or directory
chromaprint-tools: java.io.IOException: Cannot run program "fpcalc": error=2, No such file or directory
Extended Attributes: OK
Groovy Engine: 2.4.3
JRE: Java(TM) SE Runtime Environment 1.8.0_51 (headless)
JVM: 32-bit Java HotSpot(TM) Client VM
CPU/MEM: 4 Core / 208 MB Max Memory / 14 MB Used Memory
OS: Linux (arm)
uname: Linux hulk 3.18.13-v7+ #784 SMP PREEMPT Sat May 9 15:57:36 BST 2015 armv7l GNU/Linux

Re: Subtitle download doesn't work from Cron or Transmission

Posted: 13 Aug 2015, 01:08
by nytram
Hi

I suspect this is a permissios issue however to be sure
can you post a copy of your script so I can test this theory

Martyn

Re: Subtitle download doesn't work from Cron or Transmission

Posted: 13 Aug 2015, 13:20
by miguelitu
Thank you for your reply.

Not sure if that is the issue, as everything else works, the files get moved and renamed and artwork gets downloaded, the only issue is the opensubtitles login by the script when executed from cron or transmission.

Here it its:

filebot -script fn:amc --output "/mnt/usb_1/media/" --log-file amc.log --action move --conflict override -non-strict --def music=y artwork=y subtitles=en unsorted=y clean=y excludeList=amc.txt "ut_dir=/mnt/usb_1/downloads/complete/" "ut_kind=multi"

Re: Subtitle download doesn't work from Cron or Transmission

Posted: 13 Aug 2015, 19:28
by rednoah
filebot -script fn:configure will fix the issue. But only for the current user. So you'll need to call fn:configure as the same user that's running the script when called via cron.

Re: Subtitle download doesn't work from Cron or Transmission

Posted: 13 Aug 2015, 19:39
by miguelitu
Thank you for your reply.

Yup, that was done already.

I used that command to login, all went fine, and if I execute the amc script in a user terminal, it all works.

However, running from cron (from the same user) does not work, neither calling from transmission.

As it was suggested it could be a permission problems, I tried the same settings running as root, the issue still remains.

I'm out of ideas.

Re: Subtitle download doesn't work from Cron or Transmission

Posted: 13 Aug 2015, 19:53
by rednoah
cron and terminal is NOT the same. The ENVIRONMENT variables are completely different. The USER is not the same. You need to make sure that cron runs filebot as your user, and that USER environment variable is set correctly.


This call should give you the same output, in terminal and cron:

Code: Select all

filebot -script "g:println System.getProperty('user.name')"

Re: Subtitle download doesn't work from Cron or Transmission

Posted: 13 Aug 2015, 22:08
by miguelitu
When I said terminal, is because I'm logging into the Raspberry using SSH but I am sure the cron being edited is also from the same user, as also transmission-daemon is being run by it.

To confirm it, I created a new script just with the command you suggested and executed from Transmission and Cron and the outputted user was the same...

However, after some googling, I added "su - root - c "amc script command"" and now everything works...

For me it does not make sense, as your command confirmed that filebot was already being run as the same user. I'll try this fix with the regular user so I won't use root, however, for now this will do for me so I am marking this thread as solved.

Thank you for all your help.

Re: Subtitle download doesn't work from Cron or Transmission

Posted: 14 Aug 2015, 01:24
by nytram
Hi

Well done solving the probelm rednoah is right thou the shell env is the issuse

To explain when you pass su root -c what your essentially doing is logging in as root and using the root users shell env.

so in theory su to any user with a login would work. so you could su miguelitu -c "amc script command" assuming you have a valid login shell env
avoiding the need to use root.

Martyn