aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authormorpheus65535 <[email protected]>2023-06-02 20:47:55 -0400
committermorpheus65535 <[email protected]>2023-06-02 20:47:55 -0400
commitead8a3892793351fb504a1ec8fd33fa54301d8f6 (patch)
tree3b48293b1a7896dbcdcd68f32bba35956434861e
parentbbdb61a51413af8a0ad70191b091f62fb1ae367c (diff)
downloadbazarr-ead8a3892793351fb504a1ec8fd33fa54301d8f6.tar.gz
bazarr-ead8a3892793351fb504a1ec8fd33fa54301d8f6.zip
Added support for Portuguese and Simplified Chinese to opensubtitles.com. #2159
-rw-r--r--libs/subliminal_patch/providers/opensubtitlescom.py25
1 files changed, 23 insertions, 2 deletions
diff --git a/libs/subliminal_patch/providers/opensubtitlescom.py b/libs/subliminal_patch/providers/opensubtitlescom.py
index 7f2a9a1dc..2d735746c 100644
--- a/libs/subliminal_patch/providers/opensubtitlescom.py
+++ b/libs/subliminal_patch/providers/opensubtitlescom.py
@@ -50,6 +50,27 @@ def fix_movie_naming(title):
}, 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):
provider_name = 'opensubtitlescom'
hash_verifiable = False
@@ -279,7 +300,7 @@ class OpenSubtitlesComProvider(ProviderRetryMixin, Provider):
if not title_id:
return []
- lang_strings = [str(lang.basename) for lang in languages]
+ lang_strings = [to_opensubtitlescom(lang.basename) for lang in languages]
langs = ','.join(lang_strings)
logging.debug(f'Searching for this languages: {lang_strings}')
@@ -367,7 +388,7 @@ class OpenSubtitlesComProvider(ProviderRetryMixin, Provider):
if len(item['attributes']['files']):
subtitle = OpenSubtitlesComSubtitle(
- language=Language.fromietf(item['attributes']['language']),
+ language=Language.fromietf(from_opensubtitlescom(item['attributes']['language'])),
forced=item['attributes']['foreign_parts_only'],
hearing_impaired=item['attributes']['hearing_impaired'],
page_link=item['attributes']['url'],