[GUIDE] Automatically download subtitles

Support for Synology NAS, QNAP 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: 14363
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
:idea: Please read the FAQ and How to Request Help.

kunato
Posts: 3
Joined: 22 Jun 2018, 04:07

Re: [GUIDE] Automatically download subtitles

Post by kunato » 22 Jun 2018, 04:09

This guide does NOT WORK.
It was 45 mins waste of time.
You must have custom-specificed something that works only for you but noone else.

Also, your SSH command is incorrect.
Input: /var/packages/Java7/target/j2sdk-image/bin/java /usr/local/bin/java
Output: Error: Could not find or load main class .usr.local.bin.java

:oops: :cry: :oops:

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

Re: [GUIDE] Automatically download subtitles

Post by rednoah » 22 Jun 2018, 07:07

kunato wrote:
22 Jun 2018, 04:09

Code: Select all

$ /var/packages/Java7/target/j2sdk-image/bin/java /usr/local/bin/java
Error: Could not find or load main class .usr.local.bin.java
How did you come up with this? Java 7 does not work. FileBot requires Java 8 and FileBot will not work with Java 7.


Here's what the guide says: symlink the java executable to /usr/local/bin

Code: Select all

sudo ln -s /var/packages/Java8/target/j2sdk-image/bin/java /usr/local/bin/java

Here's what you're doing: execute the java executable and pass in /usr/local/bin/java as first argument

Code: Select all

/var/packages/Java7/target/j2sdk-image/bin/java /usr/local/bin/java

I guess you forgot to write sudo ln -s before the <target> <link> arguments and thus ended up doing something completely different. Though it wouldn't have worked anyway because Java 7 can't run FileBot in the first place, even if linked correctly. :roll:
:idea: Please read the FAQ and How to Request Help.

kunato
Posts: 3
Joined: 22 Jun 2018, 04:07

Re: [GUIDE] Automatically download subtitles

Post by kunato » 23 Jun 2018, 23:16

Your guide works for you because you likely have ONLY one versions of java installed: Java8 - commonly multiple versions of Java are installed since packets can be picky in which Java version they required.

The guide should state: "You MUST/HAVE TO delete Java 7, otherwise, the guide below WILL NOT work without some editing". "CAN" means, possibility, not a requirement. "MUST" means a requirement.

The user MUST deinstall Java7 AND reboot NAS to proceed.

It is quite possible that JAVA_HOME still points to Java 7, even AFTER Java7 is de-installed! Users need to REBOOT NAS to refresh JAVA_HOME (otherwise manual pointing is required).

If user has Java7, Java8 -> then running echo ${JAVA_HOME} will produce the first instance, which is Java7, and the output will be
/var/packages/Java7/target/j2sdk-image/jre
NOT
/var/packages/Java8/target/j2sdk-image/jre

The user will have to manually change number 7 to 8 to proceed with guide, which makes it "messy" to follow.
Last edited by kunato on 24 Jun 2018, 00:16, edited 2 times in total.

kunato
Posts: 3
Joined: 22 Jun 2018, 04:07

Re: [Synology] Download subtitles automatically

Post by kunato » 23 Jun 2018, 23:57

Please note that when "Unofficial Java Installer" is used to install Java, it is not resolving the issue from this guide.
Even when Java 7 is de-installed, echo ${JAVA_HOME} still returns
/var/packages/Java7/target/j2sdk-image/jre

JAVA_HOME needs to be manually set to point to Java 8 vs Java 7.
OR
Java 7 needs to be de-installed AND NAS rebooted for changes to take effect.
rednoah wrote:
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

Nellybauer
Posts: 2
Joined: 20 Jul 2018, 13:40

Re: [GUIDE] Automatically download subtitles

Post by Nellybauer » 20 Jul 2018, 14:33

I'm trying to manually grab some subtitles for an older season, approx 2 years old. When I run

Code: Select all

filebot -script fn:suball /mypath/season2
i.e. without specifying --def maxAgeDays & each episode comes back with "Ignore old:"

Is the --def maxAgeDays=30 flag set by default & can't be overwritten? I tried forcing it to be very high & it says 30 is the max value.

Update:
I'm getting around it as this is only a 1 off activity by using the Windows client instead on of my Synology direct, which works great but would still be interested to know if the command line version is limited to 30d max age even if you dont specify the flag

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

Re: [GUIDE] Automatically download subtitles

Post by rednoah » 20 Jul 2018, 20:10

What you're asking for is possible, but due to abuse, it's only for those who spend a bit of time reading the code:
https://github.com/filebot/scripts/blob ... all.groovy
:idea: Please read the FAQ and How to Request Help.

Nellybauer
Posts: 2
Joined: 20 Jul 2018, 13:40

Re: [GUIDE] Automatically download subtitles

Post by Nellybauer » 20 Jul 2018, 23:32

rednoah wrote:
20 Jul 2018, 20:10
What you're asking for is possible, but due to abuse, it's only for those who spend a bit of time reading the code:
https://github.com/filebot/scripts/blob ... all.groovy
Thanks, I stumbled on to that myself earlier as well. So I take it I'm looking at the maxagedayslimit field.

As I updated in my earlier post, I just used the windows version instead for this 1 off task but thanks for confirming how it can be done.

Bought a licence today after being a user on Synology for a long time. It through me a bit after just installing the latest update in the package center that no files were getting processed, checked the AMC log and saw the messages of needing a licence, happy to pay the 6 dollars. Will teach me to just blindly update without reading the changes first!

gac550
Posts: 1
Joined: 16 Oct 2018, 21:40

Re: [GUIDE] Automatically download subtitles

Post by gac550 » 16 Oct 2018, 21:53

Hi gents,
I need your help, I installed properly FileBot Nodes & Java so that I can use the Filebot interface rather the SSH terminal. I would like to SEARCH only subtitles (OpenSource) in English and Spanish as well, and I have working licenses for both. My Synology is installed abroad, for that, I have only remote access via the web interface (I do not have access to SSH/Terminal).

So, how I can download ONLY subtitles (Spanish and English) using FileBot Node? Or which is the CODE that I need to add in Synology Scheduled Task? The videos are located in:
\volume1\videos\movies

Many thanks in advance!

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

Re: [GUIDE] Automatically download subtitles

Post by rednoah » 17 Oct 2018, 14:04

Unfortunately, FileBot Node only supports amc script calls, and thus cannot be used to only fetch subtitles.

You can however create your own script, and call filebot from there, and once you've got it working you can have Scheduler call the script regularly:
viewtopic.php?f=4&t=5#p8871
:idea: Please read the FAQ and How to Request Help.

Post Reply

Who is online

Users browsing this forum: No registered users and 3 guests