I've been looking for some time for an automatic subtitle downloader that would monitor new file in specific folder and I found out the CLI subliminal which is python based (this tool is really great if you don't know it). Next step was to trigger it everytime there is a new movie/TV show in a specified directory. That's why I picked incron which is a inotify cron system.
I've been trying to make it work since then and sadly without any chance at all. Here is my configuration:
incron.allow:
root@localhost:/home/marco/Téléchargements# more /etc/incron.allow
marco
root
incrontab:
root@localhost:/home/marco/Téléchargements# incrontab -e
/home/marco/Téléchargements IN_CREATE,IN_MOVED_TO /home/marco/Téléchargements/series $#
the script series:
root@localhost:/home/marco/Téléchargements# more series
#!/bin/bash
logger "argument is "$1
/usr/bin/python /usr/local/bin/subliminal -l en -q -s -- $1
syslog:
root@localhost:/home/marco/Téléchargements# tail /var/log/syslog
Jan 22 12:10:25 localhost incrond[3140]: (root) CMD (/home/marco/Téléchargements/series the.blacklist.112.hdtv-lol.mp4)
Jan 22 12:10:25 localhost logger: argument is the.blacklist.112.hdtv-lol.mp4
As you can see the incron job is executing as expected. The argument is given as wanted but when I check my "Téléchargement" folder nothing is inside. When I do execute the script from the CLI with the same argument it does the job.
Note, I thought it was maybe due to the current folder not being Téléchargements and so the file not being in this folder but if I do use the subliminal argurments to move it to the good folder -d /path/to/Téléchargements
There is still nothing in the folder.
Note 2, I also tried to remove /usr/bin/python
in the script but it doesn't change anything.
Any help would be really great.
Edit: I am on debian wheezy:
root@localhost:/home/marco/Téléchargements# uname -a
Linux localhost 3.2.0-4-amd64 #1 SMP Debian 3.2.51-1 x86_64 GNU/Linux
Edit 2:
Following some comments I did add the cmd path to my service script and I also removed -q
to --log-file
. Here is the new script for series:
#!/bin/bash
export PATH=$PATH:/usr/local/sbin:/usr/local/bin
/usr/local/bin/subliminal -l en -d /tmp --log-file /tmp/log -s -- $1
If I run the script from the cmd it works as expected and I can see it by reading the file in /tmp/log:
root@localhost:/home/marco/Téléchargements# more /tmp/log
2014-01-22 15:06:58,526 INFO: Listing subtitles for <Episode [u'the blacklist', 1x12]>
2014-01-22 15:07:04,839 INFO: Found 8 subtitles total
2014-01-22 15:07:04,950 INFO: Downloading subtitle <OpenSubtitlesSubtitle [en]> with score 71
2014-01-22 15:07:05,885 INFO: Saving <OpenSubtitlesSubtitle [en]> to u'/tmp/the.blacklist.112.hdtv-lol.srt'
If I run the incron task nothing will happen. There won't be any /tmp/log file aswell.
/usr/local/bin/subliminal -l en -q -s -- $1
work from the cmd line? If yes,env > cmd_line.env
; and the same inside theincron
environment. Something likeenv > incron.env
. Compare the two files to see what are the differences in PATH and other env vars. Good luck. – shellter/usr/local/bin/subliminal -l en -q -s -- $1
work from the cmd line. incron.env: PATH=/sbin:/bin:/usr/sbin:/usr/bin cmd env: PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin – zipp-q
option means quiet, take that out so you can look at the output. Also, please update your question with this information rather than make people read thru an ever-growing thread of comments. Please? ;-) – shellter