Page 1 of 1

REST search API: language attribute inconsistencies

Posted: Tue Jan 10, 2023 10:02 pm
by swishly
The search API "https://api.opensubtitles.com/api/v1/subtitles" takes a "language" query parameter, however it is unclear what values are supported.

Without making it explicit, the documentation makes it sounds like the ISO 639-1 should be used (2 character code, e.g "en" for English, "pt" for Portuguese) - however in some circumstances the API only responds if the BCP-47 code is used (e.g. "en-US" for American English or "pt-BR" for Brazilian Portuguese)

For example

Using ISO 639-1
40+ hits for languages=en (https://api.opensubtitles.com/api/v1/su ... _id=317219)
0 hits for languages=pt (https://api.opensubtitles.com/api/v1/su ... _id=317219)

Using BCP-47
0 hits for languages=en-US (https://api.opensubtitles.com/api/v1/su ... _id=317219)
20+ hits for languages=pt-BR (https://api.opensubtitles.com/api/v1/su ... _id=317219)


We have tested with 3 languages so far. It seems that English & French require a 2-character code, but Portuguese languages requires a BCP-47 code. Not sure about other languages at this point.

It would be great if this could be standardized so the 2-character code can be used for every language.

Re: REST search API: language attribute inconsistencies

Posted: Thu Jan 12, 2023 7:46 am
by os_dev
We do use a logic of 2 digits language when it is not localised, like "en" or "fr", and a 4 digits when it is, like "pt-BR" or "pt-PB"

We use the same logic and fallbacks as the internal localisation code (ruby i18n)

the list of languages can be queried here https://api.opensubtitles.com/api/v1/infos/languages

as documented here https://opensubtitles.stoplight.io/docs ... -languages