Download subtitles depending on audio language

Running FileBot from the console, Groovy scripting, shell scripts, etc
Post Reply
devster
Posts: 417
Joined: 06 Jun 2017, 22:56

Download subtitles depending on audio language

Post by devster »

The objective is to be able to download one or more subtitles depending on the language spoken in the file.
Examples:
  • The Mummy (1999) - file contains a single audio stream in English -> subtitles downloaded .eng
  • La dame dans l'auto avec des lunettes et un fusil (2015) - file contains single audio stream in French -> subtitles downloaded .fra and .eng
  • Lo chiamavano Jeeg Robot (2015) - file contains single audio stream in Italian -> subtitles downloaded .ita and .eng
  • Ghost in the Shell (1995) - file contains 2 audio streams in English and Japanese -> subtitles downloaded .eng and .jap
  • Shaolin Soccer (2001) - file contains single audio stream in Cantonese -> subtitle downloaded .eng
I'd like to almost aways download .eng subs, but conditionally download other languages as well depending on the audio streams present or the languages spoken.

Initially I thought about the possibility of extending the AMC script, but I would have to download and manually edit it, and not keep it up-to-date. Then I thought about using a shell script and calling AMC and suball after it but I don't know how to tell suball to only conditionally download certain languages.

Therefore here I am looking for advice.

My current command looks something like this:

Code: Select all

filebot -script fn:amc -no-xattr --output "$OUTPUT" --action test --conflict auto \
    --log-file amc.log --def unsorted=y artwork=y excludeList=".excludes" \
    --def subtitles=en exec="chmod 664 '{file}'" --def @/custom/scripts/pushover.txt \
    --def movieFormat=@/custom/scripts/movie.groovy \
    --def seriesFormat=@/custom/scripts/tvshows.groovy
I only work in black and sometimes very, very dark grey. (Batman)
User avatar
rednoah
The Source
Posts: 22999
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Download subtitles depending on audio language

Post by rednoah »

e.g.

Code: Select all

--def exec="/path/to/my-subtitle-download-script {quote file} {audioLanguages.join(' ')}"
Now your bash script is called with <filename> "eng" "spa" etc as argument array and you can run FileBot or any other tool to fetch subtitles for the given languages.

Since you can only use one --def exec you'll need to adjust permissions in this script as well.
:idea: Please read the FAQ and How to Request Help.
Post Reply