Skip to content

Commit

Permalink
Fixed forced subtitles download loop
Browse files Browse the repository at this point in the history
Searching for the best forced subtitles for a given language was
resulting in all forced subtitles for that language being downloaded in
descending score order until the minimum score was reached.

Not only did this burn through any download limits imposed by providers,
it left poor quality subtitles downloaded (which could later be
automatically upgraded to the first choice).

This change uses the string conversion of Language objects instead of
their basenames when working out when to stop downloading subtitles, as
this takes into account the forced flag while still ignoring the hearing
impaired flag.
  • Loading branch information
lawadr authored Feb 2, 2024
1 parent fb660a0 commit 4029c9f
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions libs/subliminal_patch/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -574,12 +574,12 @@ def download_best_subtitles(self, subtitles, video, languages, min_score=0, hear
break

# stop when all languages are downloaded
if set(s.language.basename for s in downloaded_subtitles) == languages:
if set(str(s.language) for s in downloaded_subtitles) == languages:
logger.debug('All languages downloaded')
break

# check downloaded languages
if subtitle.language in set(s.language.basename for s in downloaded_subtitles):
if subtitle.language in set(str(s.language) for s in downloaded_subtitles):
logger.debug('%r: Skipping subtitle: already downloaded', subtitle.language)
continue

Expand Down

0 comments on commit 4029c9f

Please sign in to comment.