From b5c66e1470991ac6896b311096a78c8bef21ef9e Mon Sep 17 00:00:00 2001 From: Vitiko Date: Tue, 14 Dec 2021 15:58:50 -0400 Subject: Embedded Subtitles Provider: rebuild language if forced --- libs/subliminal_patch/providers/embeddedsubtitles.py | 3 +++ tests/subliminal_patch/test_embeddedsubtitles.py | 1 + 2 files changed, 4 insertions(+) diff --git a/libs/subliminal_patch/providers/embeddedsubtitles.py b/libs/subliminal_patch/providers/embeddedsubtitles.py index 3d9e64959..aa8927fd6 100644 --- a/libs/subliminal_patch/providers/embeddedsubtitles.py +++ b/libs/subliminal_patch/providers/embeddedsubtitles.py @@ -30,6 +30,9 @@ class EmbeddedSubtitle(Subtitle): def __init__(self, stream, container, matches): super().__init__(stream.language, stream.disposition.hearing_impaired) + if stream.disposition.forced: + self.language = Language.rebuild(stream.language, forced=True) + self.stream: FFprobeSubtitleStream = stream self.container: FFprobeVideoContainer = container self.forced = stream.disposition.forced diff --git a/tests/subliminal_patch/test_embeddedsubtitles.py b/tests/subliminal_patch/test_embeddedsubtitles.py index ee1c8d6eb..6c546a61f 100644 --- a/tests/subliminal_patch/test_embeddedsubtitles.py +++ b/tests/subliminal_patch/test_embeddedsubtitles.py @@ -82,6 +82,7 @@ def test_list_subtitles_also_forced(video_single_language): language_2 = Language.rebuild(language_1, forced=True) subs = provider.list_subtitles(video_single_language, {language_1, language_2}) assert any(language_1 == sub.language for sub in subs) + assert any(not sub.language.forced for sub in subs) def test_list_subtitles_single_language(video_single_language): -- cgit v1.2.3