From 7d836749e164c5a20eb1c83376a112b7ac27f4df Mon Sep 17 00:00:00 2001 From: cetiberiojr <59163902+cetiberiojr@users.noreply.github.com> Date: Fri, 19 Feb 2021 14:22:31 -0300 Subject: [PATCH 1/2] Add Brazilian Portuguese name check When getting information from subtitles, normally, Portuguese and Brazilian Portuguese are often considered as the same language (por, in this case), the only difference we have is when the name of them has some additional information. For Brazilian Portuguese, this additional information is most of the time (Brazilian or Brasil). So add the check when the language is por and try to differ Brazilian Portuguese from Portuguese. --- bazarr/embedded_subs_reader.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/bazarr/embedded_subs_reader.py b/bazarr/embedded_subs_reader.py index b70487ba1..173c71694 100644 --- a/bazarr/embedded_subs_reader.py +++ b/bazarr/embedded_subs_reader.py @@ -21,6 +21,7 @@ class EmbeddedSubsReader: data = api.know(file) traditional_chinese = ["cht", "tc", "traditional", "zht", "hant", "big5", u"繁", u"雙語"] + brazilian_portuguese = ["pt-br", "pob", "pb", "Brazilian", "Brasil"] if 'subtitle' in data: for detected_language in data['subtitle']: @@ -29,6 +30,9 @@ class EmbeddedSubsReader: if language == 'zho' and 'name' in detected_language: if any (ext in (detected_language['name'].lower()) for ext in traditional_chinese): language = 'zht' + if language == 'por' and 'name' in detected_language: + if any (ext in (detected_language['name'].lower()) for ext in brazilian_portuguese): + language = 'pob' forced = detected_language['forced'] if 'forced' in detected_language else False hearing_impaired = detected_language['hearing_impaired'] if 'hearing_impaired' in \ detected_language else False From 7432e07089a4a73a59a84124e0ddf1eeee12eed2 Mon Sep 17 00:00:00 2001 From: cetiberiojr <59163902+cetiberiojr@users.noreply.github.com> Date: Fri, 19 Feb 2021 16:35:52 -0300 Subject: [PATCH 2/2] Fix uppercase typo on brazilian_portuguese We are comparing the lowercase of the vector, so all the parameters should be lowecase. --- bazarr/embedded_subs_reader.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bazarr/embedded_subs_reader.py b/bazarr/embedded_subs_reader.py index 173c71694..ee5b3b278 100644 --- a/bazarr/embedded_subs_reader.py +++ b/bazarr/embedded_subs_reader.py @@ -21,7 +21,7 @@ class EmbeddedSubsReader: data = api.know(file) traditional_chinese = ["cht", "tc", "traditional", "zht", "hant", "big5", u"繁", u"雙語"] - brazilian_portuguese = ["pt-br", "pob", "pb", "Brazilian", "Brasil"] + brazilian_portuguese = ["pt-br", "pob", "pb", "brazilian", "brasil"] if 'subtitle' in data: for detected_language in data['subtitle']: