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.
This commit is contained in:
cetiberiojr 2021-02-19 14:22:31 -03:00 committed by GitHub
parent cf0cc5df1d
commit 7d836749e1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 4 additions and 0 deletions

View File

@ -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