mirror of
https://github.com/morpheus65535/bazarr
synced 2024-12-23 16:23:41 +00:00
Added support for Portuguese and Simplified Chinese to opensubtitles.com. #2159
This commit is contained in:
parent
bbdb61a514
commit
ead8a38927
1 changed files with 23 additions and 2 deletions
|
@ -50,6 +50,27 @@ def fix_movie_naming(title):
|
||||||
}, True)
|
}, True)
|
||||||
|
|
||||||
|
|
||||||
|
custom_languages = {
|
||||||
|
'pt': 'pt-PT',
|
||||||
|
'zh': 'zh-CN',
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def to_opensubtitlescom(lang):
|
||||||
|
if lang in custom_languages.keys():
|
||||||
|
return custom_languages[lang]
|
||||||
|
else:
|
||||||
|
return lang
|
||||||
|
|
||||||
|
|
||||||
|
def from_opensubtitlescom(lang):
|
||||||
|
from_custom_languages = {v: k for k, v in custom_languages.items()}
|
||||||
|
if lang in from_custom_languages.keys():
|
||||||
|
return from_custom_languages[lang]
|
||||||
|
else:
|
||||||
|
return lang
|
||||||
|
|
||||||
|
|
||||||
class OpenSubtitlesComSubtitle(Subtitle):
|
class OpenSubtitlesComSubtitle(Subtitle):
|
||||||
provider_name = 'opensubtitlescom'
|
provider_name = 'opensubtitlescom'
|
||||||
hash_verifiable = False
|
hash_verifiable = False
|
||||||
|
@ -279,7 +300,7 @@ class OpenSubtitlesComProvider(ProviderRetryMixin, Provider):
|
||||||
if not title_id:
|
if not title_id:
|
||||||
return []
|
return []
|
||||||
|
|
||||||
lang_strings = [str(lang.basename) for lang in languages]
|
lang_strings = [to_opensubtitlescom(lang.basename) for lang in languages]
|
||||||
langs = ','.join(lang_strings)
|
langs = ','.join(lang_strings)
|
||||||
logging.debug(f'Searching for this languages: {lang_strings}')
|
logging.debug(f'Searching for this languages: {lang_strings}')
|
||||||
|
|
||||||
|
@ -367,7 +388,7 @@ class OpenSubtitlesComProvider(ProviderRetryMixin, Provider):
|
||||||
|
|
||||||
if len(item['attributes']['files']):
|
if len(item['attributes']['files']):
|
||||||
subtitle = OpenSubtitlesComSubtitle(
|
subtitle = OpenSubtitlesComSubtitle(
|
||||||
language=Language.fromietf(item['attributes']['language']),
|
language=Language.fromietf(from_opensubtitlescom(item['attributes']['language'])),
|
||||||
forced=item['attributes']['foreign_parts_only'],
|
forced=item['attributes']['foreign_parts_only'],
|
||||||
hearing_impaired=item['attributes']['hearing_impaired'],
|
hearing_impaired=item['attributes']['hearing_impaired'],
|
||||||
page_link=item['attributes']['url'],
|
page_link=item['attributes']['url'],
|
||||||
|
|
Loading…
Reference in a new issue