diff options
author | Vitiko <[email protected]> | 2022-05-16 23:56:52 -0400 |
---|---|---|
committer | Vitiko <[email protected]> | 2022-05-16 23:56:52 -0400 |
commit | b96fd9326979b08876ef9818bfab0a735dcc0f06 (patch) | |
tree | d1f40e475a7701deb131261a5405e4039221377f /libs | |
parent | 3d7fa06f410ef1dc491b2867212e402fda5af6b6 (diff) | |
download | bazarr-b96fd9326979b08876ef9818bfab0a735dcc0f06.tar.gz bazarr-b96fd9326979b08876ef9818bfab0a735dcc0f06.zip |
Embedded Subtitles provider: improve HI fallbackv1.0.5-beta.9
Diffstat (limited to 'libs')
-rw-r--r-- | libs/subliminal_patch/providers/embeddedsubtitles.py | 29 |
1 files changed, 17 insertions, 12 deletions
diff --git a/libs/subliminal_patch/providers/embeddedsubtitles.py b/libs/subliminal_patch/providers/embeddedsubtitles.py index 63e7c8fde..d738ee024 100644 --- a/libs/subliminal_patch/providers/embeddedsubtitles.py +++ b/libs/subliminal_patch/providers/embeddedsubtitles.py @@ -245,21 +245,26 @@ def _check_allowed_extensions(subtitle: FFprobeSubtitleStream): def _check_hi_fallback(streams, languages): for language in languages: - compatible_streams = [ - stream for stream in streams if stream.language == language - ] - if len(compatible_streams) == 1: - stream = compatible_streams[0] - logger.debug("HI fallback: updating %s HI to False", stream) - stream.disposition.hearing_impaired = False - - elif all(stream.disposition.hearing_impaired for stream in streams): - for stream in streams: - logger.debug("HI fallback: updating %s HI to False", stream) + logger.debug("Checking HI fallback for '%s' language", language) + + streams_ = [stream for stream in streams if stream.language == language] + if len(streams_) == 1 and streams_[0].disposition.hearing_impaired: + logger.debug( + "HI fallback: updating %s HI to False (only subtitle found is HI)", + streams_[0], + ) + streams_[0].disposition.hearing_impaired = False + + elif all(stream.disposition.hearing_impaired for stream in streams_): + for stream in streams_: + logger.debug( + "HI fallback: updating %s HI to False (all subtitles are HI)", + stream, + ) stream.disposition.hearing_impaired = False else: - logger.debug("HI fallback not needed: %s", compatible_streams) + logger.debug("HI fallback not needed: %s", streams_) def _discard_possible_incomplete_subtitles(streams): |