[GUIDE] Automatically download subtitles

Support for Synology NAS and other Embedded Linux systems
Post Reply
maxoudela
Power User
Posts: 17
Joined: 31 Mar 2016, 12:16

[GUIDE] Automatically download subtitles

Post by maxoudela » 07 Apr 2016, 12:33

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

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 https://www.crisi.ch/automatically-down ... adstation/. 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 : 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 :lol: . 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 (https://www.youtube.com/watch?v=8N6hYNj ... tml5=False), 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 :

    Code: Select all

    java -version
    Image
  • Then identify where it's installed by typing :

    Code: Select all

    echo ${JAVA_HOME}
    Image

    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 :

    Code: Select all

    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 :

    Code: Select all

    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 :

    Code: Select all

    cd /var/services/homes/master
    filebot -script fn:suball /volume1/video/Series/ --def maxAgeDays=7
    Do not forget to use maxAgeDays as specified here : 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 ... 802#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.
    Image
    In my case I put it in video folder which is rather dumb but I like to spice things a little :roll:
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 :

Code: Select all

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!

Code: Select all

filebot -script fn:suball /volume1/video/Séries/ --lang fr --def maxAgeDays=7
Last edited by maxoudela on 11 Apr 2016, 11:56, edited 1 time in total.

User avatar
rednoah
The Source
Posts: 12457
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: [Synology] Download subtitles automatically

Post by rednoah » 07 Apr 2016, 13:23

Thanks for the rather excellent tutorial! Much appreciated! :ugeek:

Here's some additional tips:
  • My Java Installer can help you install Oracle Java 8 and avoid all the $PATH issues (may not work for older ARM devices though)
  • The OpenJDK runtime works, but it's known to be very slow on ARM devices
  • I recommend setting --def minAgeDays=1 as well so that it'll wait for a day before it'll search for subtitles because good subtitles may not be available until a few days after the release
My (very excellent) support depends on Windows Store and Mac App Store sales and PayPal donations. Paying users, donors and everyone who contributes to FileBot in one way or another will get the very best support.

Image

Please read the FAQ and How to Request Help. Donate if you'd like some extra developer love. :ugeek:

Post Reply

Who is online

Users browsing this forum: No registered users and 1 guest