Automatically download subtitles with FileBot

Tutorial initially written for FileBot forum : here

This tutorial is intended for people who wants to automatically download subtitles for their movies/series. Basically, everything is already written in the FileBot forums, but this tutorial aims at regrouping everything in one article.

I’m using Download Station of Synology combined to an RSS feed in order to automatically download some series (if you want to do that, it’s there). What I wanted was to also download subtitles automatically.

Prerequisites

  • You must have DSM 6.0 minimum on your Synology.
  • You must have (and know how) to have access to your NAS via SSH.

Installation

First of all, we will need to install Java 8 on the NAS. If this is not done yet, you must open the package center, then find the package “Java8” and install it. If you had Java7 installed, you can remove it (at least it’s what I did).

Once done, you can install FileBot :P. For that, simply follow the procedure but do not install FileBotNode, we don’t need it : http://www.filebot.net/forums/viewtopic.php?f=3&t=1802
At that point, you should have FileBot correctly installed and running.

Configuration

Let’s get into business. We first need to set up our OpenSubtitles account. The subtitles are going to be downloaded from the website http://www.opensubtitles.org/ so you need to create an account on it. Then you need to inform Filebot by following this procedure : https://www.filebot.net/forums/viewtopic.php?f=3&t=228

Then you will need to set the Java path correctly.

But why? I’ve already installed Java 8 on the nas!

Because :

Running commands from the login shell is not the same as using Synology DSM Task Scheduler or cron because they’ll not initialise with ~/.profile so PATH may be different.

Got it? No? Allright, it’s not a problem, neither did I 😆 . The point is that we will execute an automated task (download subtitles) with Synology Task Manager. This task will be executed by a user (usually the same you connect with SSH). But a command will fail when ran in a Task as it will succeed when ran in SSH. So we need to fix that.

The procedure is somehow explained here (video), but it’s simple in our case so I’ve detailed it :

  • Connect in SSH with the same user you will use for the task..
  • Verify that Java is correctly installed by typing :
    java -version
    

  • Then identify where it’s installed by typing :
    echo ${JAVA_HOME}


    You should have something similar to me. Now we just need to include Java for our user so that the Task can be ran!

  • You need to take the path you got from the previous command, remove jre at the end, and add bin/java, in my case it will be :
    sudo ln -s /var/packages/Java8/target/j2sdk-image/bin/java /usr/local/bin/java
  • Enter your password and it’s good.
  • Verify it went well by typing :
    which java

    and verify it points to the /usr/local/bin/java .

You can exit SSH and get back to DSM.

Adding the task

Before adding the Task, you need to identify where your movies and series are. In my case I have a folder named video which contains a folder named Series. In that folder, I have all my series. So for the Task, the path I will use will be /volume1/video/Series . That means that I want FileBot to download subtitles that are not present in any sub-folders of Series every time the task will be launched.

  • Go to Synology Control Panel, and to Task Scheduler, then click on create -> Scheduled task -> User defined script.
  • Give it a fancy name and select the same user you used in SSH.
  • On the schedule tab, program it daily for example.
  • On Task settings, write a command (examples are here : http://www.filebot.net/cli.html ), in order to download the missing subtitles for your series :
    cd /var/services/homes/master
    filebot -script fn:suball /volume1/video/Series/ --def maxAgeDays=7

    Do not forget to use maxAgeDays as specified here : https://www.filebot.net/forums/viewtopic.php?f=4&t=5#p8871

    I put a cd command just before calling FileBot because my user is different from admin and somehow, the taskManager is not at the right place when starting. If your user is admin, you should not need that command.

  • Click OK

I suggest that before testing on your root Series folder, test it on a sub-folder first. Because if something goes wrong, it won’t take much time before ending.
You can redirect the output log as specified here : http://www.filebot.net/forums/viewtopic.php?f=3&t=1802#p12015

But since you are noob like me 😕 , here is a simpler way to do that :

  • In the Control Panel, select the task you just created, then hit the Settings button.
  • You can now enable the output and select a folder where the results of the Task will be printed.

    In my case I put it in video folder which is rather dumb but I like to spice things a little 🙄

When everything is ready, you can click on Run in order to test your Task. Hopefully, you can check in the logs the output.

FAQ

But the task will be executed each day, I want it to be executed when my downloads are finished!

First of all, settle down cowboy. You are lucky someone like rednoah developed a tool allowing you to automatically do things. Then, the download station of Synology doesn’t allow (yet) to run scripts when a download is done. So the solution right now is to run periodically a Task that will download missing subtitles.

This is very cool for the future as everything will be automatically done but I have downloaded a Serie a long time ago, and I want to download the subtitles!

You are totally right. The script is working for future downloads as we indicated maxAgeDays to 7 and we do not download subtitles for files that are older that 7 days. In your case, you should connect in SSH, go to the folder where all your episodes are, and run the command manually :

filebot -script fn:suball /path/to/media 

BUT be aware that you removed the maxAgeDays so the location where you execute the command must be small because otherwise you will try to download too much subtitles and you will get banned from OpenSubtitles and then you will be sad.

Allright this is cool but I’m french, and as you know, french do not speak very good english

Hello there french fellow. I understand your pain since I’m also French. What you need is to add a little option that you can find here (http://www.filebot.net/cli.html) in order to specify that you want French subtitles!

filebot -script fn:suball /volume1/video/Séries/ --lang fr --def maxAgeDays=7

Leave a Reply

Your email address will not be published. Required fields are marked *