diff --git a/libs/subliminal_patch/providers/utils.py b/libs/subliminal_patch/providers/utils.py index 42b3ca4e5..0158abfee 100644 --- a/libs/subliminal_patch/providers/utils.py +++ b/libs/subliminal_patch/providers/utils.py @@ -82,6 +82,10 @@ def get_subtitle_from_archive( return None +def is_episode(content): + return "episode" in guessit(content, {"type": "episode"}) + + def get_archive_from_bytes(content: bytes): """Get RarFile/ZipFile object from bytes. Return None is something else is found.""" diff --git a/tests/subliminal_patch/test_utils.py b/tests/subliminal_patch/test_utils.py index de082a0bc..e4a8b4efb 100644 --- a/tests/subliminal_patch/test_utils.py +++ b/tests/subliminal_patch/test_utils.py @@ -53,3 +53,10 @@ def test_update_matches(movies): matches, movies["dune"], "Subs for dune 2021 bluray x264\nDune webrip x264" ) assert "source" in matches + + +@pytest.mark.parametrize( + "content,expected", [("the.wire.s01e01", True), ("taxi driver 1976", False)] +) +def test_is_episode(content, expected): + assert utils.is_episode(content) is expected