|
|
@ -8,9 +8,9 @@ from fese.exceptions import LanguageNotFound
|
|
|
|
import pytest
|
|
|
|
import pytest
|
|
|
|
from subliminal_patch.core import Episode
|
|
|
|
from subliminal_patch.core import Episode
|
|
|
|
from subliminal_patch.core import Movie
|
|
|
|
from subliminal_patch.core import Movie
|
|
|
|
|
|
|
|
from subliminal_patch.providers.embeddedsubtitles import _clean_ass_subtitles
|
|
|
|
from subliminal_patch.providers.embeddedsubtitles import (
|
|
|
|
from subliminal_patch.providers.embeddedsubtitles import (
|
|
|
|
_discard_possible_incomplete_subtitles,
|
|
|
|
_discard_possible_incomplete_subtitles,
|
|
|
|
_clean_ass_subtitles,
|
|
|
|
|
|
|
|
)
|
|
|
|
)
|
|
|
|
from subliminal_patch.providers.embeddedsubtitles import _get_pretty_release_name
|
|
|
|
from subliminal_patch.providers.embeddedsubtitles import _get_pretty_release_name
|
|
|
|
from subliminal_patch.providers.embeddedsubtitles import _MemoizedFFprobeVideoContainer
|
|
|
|
from subliminal_patch.providers.embeddedsubtitles import _MemoizedFFprobeVideoContainer
|
|
|
@ -127,7 +127,9 @@ def fake_streams():
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.parametrize("tags_", [{}, {"language": "und", "title": "Unknown"}])
|
|
|
|
@pytest.mark.parametrize("tags_", [{}, {"language": "und", "title": "Unknown"}])
|
|
|
|
def test_list_subtitles_unknown_as_fallback(mocker, tags_, video_single_language):
|
|
|
|
def test_list_subtitles_unknown_as_fallback(mocker, tags_, video_single_language):
|
|
|
|
with EmbeddedSubtitlesProvider(unknown_as_fallback=True, fallback_lang="en") as provider:
|
|
|
|
with EmbeddedSubtitlesProvider(
|
|
|
|
|
|
|
|
unknown_as_fallback=True, fallback_lang="en"
|
|
|
|
|
|
|
|
) as provider:
|
|
|
|
fake = FFprobeSubtitleStream(
|
|
|
|
fake = FFprobeSubtitleStream(
|
|
|
|
{"index": 3, "codec_name": "subrip", "tags": tags_}
|
|
|
|
{"index": 3, "codec_name": "subrip", "tags": tags_}
|
|
|
|
)
|
|
|
|
)
|
|
|
@ -144,7 +146,9 @@ def test_list_subtitles_unknown_as_fallback(mocker, tags_, video_single_language
|
|
|
|
def test_list_subtitles_unknown_as_fallback_w_real_english_subtitles(
|
|
|
|
def test_list_subtitles_unknown_as_fallback_w_real_english_subtitles(
|
|
|
|
video_single_language, mocker
|
|
|
|
video_single_language, mocker
|
|
|
|
):
|
|
|
|
):
|
|
|
|
with EmbeddedSubtitlesProvider(unknown_as_fallback=True, fallback_lang="en") as provider:
|
|
|
|
with EmbeddedSubtitlesProvider(
|
|
|
|
|
|
|
|
unknown_as_fallback=True, fallback_lang="en"
|
|
|
|
|
|
|
|
) as provider:
|
|
|
|
fakes = [
|
|
|
|
fakes = [
|
|
|
|
FFprobeSubtitleStream(
|
|
|
|
FFprobeSubtitleStream(
|
|
|
|
{"index": 3, "codec_name": "subrip", "tags": {"language": "und"}}
|
|
|
|
{"index": 3, "codec_name": "subrip", "tags": {"language": "und"}}
|
|
|
@ -165,7 +169,7 @@ def test_list_subtitles_unknown_as_fallback_w_real_english_subtitles(
|
|
|
|
|
|
|
|
|
|
|
|
@pytest.mark.parametrize("tags_", [{}, {"language": "und", "title": "Unknown"}])
|
|
|
|
@pytest.mark.parametrize("tags_", [{}, {"language": "und", "title": "Unknown"}])
|
|
|
|
def test_list_subtitles_unknown_as_fallback_disabled(tags_):
|
|
|
|
def test_list_subtitles_unknown_as_fallback_disabled(tags_):
|
|
|
|
with EmbeddedSubtitlesProvider(unknown_as_fallback=False,fallback_lang="en"):
|
|
|
|
with EmbeddedSubtitlesProvider(unknown_as_fallback=False, fallback_lang="en"):
|
|
|
|
with pytest.raises(LanguageNotFound):
|
|
|
|
with pytest.raises(LanguageNotFound):
|
|
|
|
assert FFprobeSubtitleStream(
|
|
|
|
assert FFprobeSubtitleStream(
|
|
|
|
{"index": 3, "codec_name": "subrip", "tags": tags_}
|
|
|
|
{"index": 3, "codec_name": "subrip", "tags": tags_}
|
|
|
@ -362,6 +366,21 @@ def test_download_subtitle_single(video_single_language):
|
|
|
|
assert subtitle.is_valid()
|
|
|
|
assert subtitle.is_valid()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_download_subtitle_single_is_ass(video_single_language):
|
|
|
|
|
|
|
|
with EmbeddedSubtitlesProvider() as provider:
|
|
|
|
|
|
|
|
subtitle = provider.list_subtitles(
|
|
|
|
|
|
|
|
video_single_language, {Language.fromalpha2("en")}
|
|
|
|
|
|
|
|
)[0]
|
|
|
|
|
|
|
|
provider.download_subtitle(subtitle)
|
|
|
|
|
|
|
|
assert subtitle.is_valid()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assert subtitle.format == "srt"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
subtitle.use_original_format = True
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
assert subtitle.format == "ass"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def test_memoized(video_single_language, mocker):
|
|
|
|
def test_memoized(video_single_language, mocker):
|
|
|
|
with EmbeddedSubtitlesProvider() as provider:
|
|
|
|
with EmbeddedSubtitlesProvider() as provider:
|
|
|
|
provider.list_subtitles(video_single_language, {Language.fromalpha2("en")})
|
|
|
|
provider.list_subtitles(video_single_language, {Language.fromalpha2("en")})
|
|
|
|