From 4809b403ca3b98f0f38f4e7ef62565b5a40e9aed Mon Sep 17 00:00:00 2001 From: Xewdy Date: Thu, 26 Dec 2024 13:49:49 -0600 Subject: [PATCH] Added check to opensubtitles.com for SDH subtitles being classified as forced --- .../subliminal_patch/providers/opensubtitlescom.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/custom_libs/subliminal_patch/providers/opensubtitlescom.py b/custom_libs/subliminal_patch/providers/opensubtitlescom.py index 0f0c2eaff..39171b6af 100644 --- a/custom_libs/subliminal_patch/providers/opensubtitlescom.py +++ b/custom_libs/subliminal_patch/providers/opensubtitlescom.py @@ -290,6 +290,10 @@ class OpenSubtitlesComProvider(ProviderRetryMixin, Provider): if not title_id: logger.debug(f'No match found for {title}') + @staticmethod + def is_real_forced(attributes): + return attributes['foreign_parts_only'] and not attributes['hearing_impaired'] + def query(self, languages, video): self.video = video if self.use_hash: @@ -363,11 +367,11 @@ class OpenSubtitlesComProvider(ProviderRetryMixin, Provider): # filter out forced subtitles or not depending on the required languages if all([lang.forced for lang in languages]): # only forced - result['data'] = [x for x in result['data'] if x['attributes']['foreign_parts_only']] + result['data'] = [x for x in result['data'] if self.is_real_forced(x['attributes'])] elif any([lang.forced for lang in languages]): # also forced pass else: # not forced - result['data'] = [x for x in result['data'] if not x['attributes']['foreign_parts_only']] + result['data'] = [x for x in result['data'] if not self.is_real_forced(x['attributes'])] logger.debug(f"Query returned {len(result['data'])} subtitles") @@ -407,7 +411,7 @@ class OpenSubtitlesComProvider(ProviderRetryMixin, Provider): if len(item['attributes']['files']): subtitle = OpenSubtitlesComSubtitle( language=Language.fromietf(from_opensubtitlescom(item['attributes']['language'])), - forced=item['attributes']['foreign_parts_only'], + forced=self.is_real_forced(item['attributes']), hearing_impaired=item['attributes']['hearing_impaired'], page_link=item['attributes']['url'], file_id=item['attributes']['files'][0]['file_id'],