Skip to content

Commit

Permalink
Added check to opensubtitles.com for SDH subtitles being classified a…
Browse files Browse the repository at this point in the history
…s forced
  • Loading branch information
Xewdy444 authored Dec 26, 2024
1 parent b71daad commit 4809b40
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions custom_libs/subliminal_patch/providers/opensubtitlescom.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,10 @@ def search_titles(self, title):
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:
Expand Down Expand Up @@ -363,11 +367,11 @@ def query(self, languages, video):

# 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")

Expand Down Expand Up @@ -407,7 +411,7 @@ def query(self, languages, video):
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'],
Expand Down

0 comments on commit 4809b40

Please sign in to comment.