Question

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.

Was it helpful?

Solution

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
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top