2
votes

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.

1
does the cmd /usr/local/bin/subliminal -l en -q -s -- $1 work from the cmd line? If yes, env > cmd_line.env ; and the same inside the incron environment. Something like env > incron.env. Compare the two files to see what are the differences in PATH and other env vars. Good luck.shellter
Yes the cmd /usr/local/bin/subliminal -l en -q -s -- $1work 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:/binzipp
New serie script: #!/bin/bash export PATH=$PATH:/usr/local/sbin:/usr/local/bin /usr/local/bin/subliminal -l en -d /tmp -q -s -- $1 Nothing in /tmp folder.zipp
does that cmd put something in the tmp dir if you run it from cmdline? If the -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
Tried it and even put --log-file instead but as you can see in my edited original post. Nothing happen when I trigger it from incron. By the way, I don't think that I need /usr/local/bin/subliminal anymore but just sbuliminal would be enough. Still won't change a thing.zipp

1 Answers

1
votes

Ok finally fixed it by running the incron task with my user marco and not root. Don't really get why but it works this way. Thanks for your help.

Still need to escape the character "é" to move it into the Téléchargement folder.

  marco@localhost:~/WindowsShare/Series$ /bin/ls -ld /tmp /tmp/the.blacklist.112.hdtv-lol.mp4.log /home/marco/WindowsShare/Series/the.blacklist.112.hdtv-lol.mp4 
  -rw-r--r--  1 marco marco 269597467 janv. 22 23:13 /home/marco/WindowsShare/Series/the.blacklist.112.hdtv-lol.mp4
  drwxrwxrwt 11 root  root       4096 janv. 22 23:41 /tmp
  -rw-r--r--  1 marco marco       370 janv. 22 23:37 /tmp/the.blacklist.112.hdtv-lol.mp4.log