Get the first perfect match from a list of all available langs

Any questions? Need some help?
Post Reply
dougbup
Posts: 3
Joined: 20 May 2017, 09:25

Get the first perfect match from a list of all available langs

Post by dougbup »

Making some tests I noticed that if don't specify in (--lang) the default search for subtitles will use "en" by the norm in getSubtitles() command.
I would like to find any subtitle with a perfect match for the video being searched and fetch one of them (the first result would be enough), it doesn't matter the language if it exists at least one perfect match.
The idea is to not limit the search to a specific language, but detect if there is a sub for that hash (something like using "SubLanguageId-all" in OpenSubtitles website), and download the first synced sub.
How could I achieve something like this? Or maybe I'm wrong and if there are no English subs available, it will search for others by default?
User avatar
rednoah
The Source
Posts: 22923
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Get the first perfect match from a list of all available langs

Post by rednoah »

--lang en is default unless specified otherwise.

FileBot command-line tools or scripting doesn't give you options to search by "all" or multiple languages, even though it's probably possible as far as the OpenSubtitles API is concerned.

Currently, if you want to search for subtitles in multiple languages, you'd have to perform multiple subtitle lookups.
:idea: Please read the FAQ and How to Request Help.
dougbup
Posts: 3
Joined: 20 May 2017, 09:25

Re: Get the first perfect match from a list of all available langs

Post by dougbup »

rednoah wrote: Currently, if you want to search for subtitles in multiple languages, you'd have to perform multiple subtitle lookups.
Some advice for a possible workaround then? I'm using filebot to fetch subtitles, and this tool https://github.com/kaegi/aligner to align/resync any sub that is not a perfect match. Currently, i pick the English sub as the possible correct one, but sometimes neither the English or the sub in my language are synced. So, if I could pick a correct synced from any language (the important here is to have one available with the correct timecode) and use it, possibly the chances of resyncing to a wrong timecode would be much lower.
User avatar
rednoah
The Source
Posts: 22923
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Get the first perfect match from a list of all available langs

Post by rednoah »

AFAIK, there is no workaround other than trying with one language after another until you get a match.

I'm not sure how active people are for non-English subtitles. If there's no English match, then the chances of there being a non-English match are not exactly high.
:idea: Please read the FAQ and How to Request Help.
dougbup
Posts: 3
Joined: 20 May 2017, 09:25

Re: Get the first perfect match from a list of all available langs

Post by dougbup »

Any way to know the available languages? I mean, unless I put every language supported by OpenSubs and use a ton of resources to just find a single sub, currently I'm clueless about doing this.
Well, not every show or movie in the world come from an English native speaking country and the subs sometimes are made for near country's, so yeah, English should not be always the default case.
User avatar
rednoah
The Source
Posts: 22923
Joined: 16 Nov 2011, 08:59
Location: Taipei
Contact:

Re: Get the first perfect match from a list of all available langs

Post by rednoah »

That's true. But other than English and Original Language, the others aren't really worth checking. You can get the original language from xattr after files have been processed by FileBot. Unfortunately, there's no built-in function for checking which hash yields subtitles in which languages.

There might be other tools that give you more fine-grained control over the OpenSubtitles API.
:idea: Please read the FAQ and How to Request Help.
Post Reply