From 6e521143e1de1f720dd9cf908aa7c907696187f0 Mon Sep 17 00:00:00 2001 From: vitiko98 Date: Fri, 2 Sep 2022 23:35:56 -0400 Subject: Embedded Subtitles provider: improve ASS subtitles filtering --- tests/subliminal_patch/test_embeddedsubtitles.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'tests') diff --git a/tests/subliminal_patch/test_embeddedsubtitles.py b/tests/subliminal_patch/test_embeddedsubtitles.py index d858581f8..ab0dc1c41 100644 --- a/tests/subliminal_patch/test_embeddedsubtitles.py +++ b/tests/subliminal_patch/test_embeddedsubtitles.py @@ -10,6 +10,7 @@ from subliminal_patch.core import Episode from subliminal_patch.core import Movie from subliminal_patch.providers.embeddedsubtitles import ( _discard_possible_incomplete_subtitles, + _clean_ass_subtitles, ) from subliminal_patch.providers.embeddedsubtitles import _get_pretty_release_name from subliminal_patch.providers.embeddedsubtitles import _MemoizedFFprobeVideoContainer @@ -283,6 +284,20 @@ def test_get_pretty_release_name(): assert _get_pretty_release_name(stream, container) == "foo.en.forced.srt" +def test_clean_ass_subtitles(data, tmp_path): + path = os.path.join(data, "subs.ass") + + with open(path, "r") as f: + og_lines_len = len(f.readlines()) + + output_path = os.path.join(tmp_path, "subs.ass") + + _clean_ass_subtitles(path, output_path) + + with open(output_path, "r") as f: + assert og_lines_len > len(f.readlines()) + + def test_download_subtitle_multiple(video_multiple_languages): with EmbeddedSubtitlesProvider() as provider: languages = {Language.fromalpha2(code) for code in ("en", "it", "fr")} | { -- cgit v1.2.3