summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorVitiko <[email protected]>2024-07-14 19:02:50 -0400
committerVitiko <[email protected]>2024-07-14 19:02:50 -0400
commit91a35317cc1f627030b7bae4d9776acef4745afd (patch)
treebd42bcde6c83379d0688ed0eb95aa02b2f6a509d
parent127a7aebadde462babba33d2115dc058a854954c (diff)
downloadbazarr-91a35317cc1f627030b7bae4d9776acef4745afd.tar.gz
bazarr-91a35317cc1f627030b7bae4d9776acef4745afd.zip
Subdl Provider: add tests and use standard utils
-rw-r--r--custom_libs/subliminal_patch/providers/subdl.py7
-rw-r--r--tests/subliminal_patch/test_subdl.py36
2 files changed, 38 insertions, 5 deletions
diff --git a/custom_libs/subliminal_patch/providers/subdl.py b/custom_libs/subliminal_patch/providers/subdl.py
index 66c5bf616..3c59f43a5 100644
--- a/custom_libs/subliminal_patch/providers/subdl.py
+++ b/custom_libs/subliminal_patch/providers/subdl.py
@@ -17,8 +17,7 @@ from .mixins import ProviderRetryMixin
from subliminal_patch.subtitle import Subtitle
from subliminal.subtitle import fix_line_ending
from subliminal_patch.providers import Provider
-from subliminal_patch.subtitle import guess_matches
-from guessit import guessit
+from subliminal_patch.providers import utils
logger = logging.getLogger(__name__)
@@ -57,7 +56,6 @@ class SubdlSubtitle(Subtitle):
def get_matches(self, video):
matches = set()
- type_ = "movie" if isinstance(video, Movie) else "episode"
# handle movies and series separately
if isinstance(video, Episode):
@@ -77,8 +75,7 @@ class SubdlSubtitle(Subtitle):
# imdb
matches.add('imdb_id')
- # other properties
- matches |= guess_matches(video, guessit(self.release_info, {"type": type_}))
+ utils.update_matches(matches, video, self.release_info)
self.matches = matches
diff --git a/tests/subliminal_patch/test_subdl.py b/tests/subliminal_patch/test_subdl.py
new file mode 100644
index 000000000..47fe7577d
--- /dev/null
+++ b/tests/subliminal_patch/test_subdl.py
@@ -0,0 +1,36 @@
+import os
+
+import pytest
+from subliminal_patch.providers.subdl import SubdlProvider
+from subliminal_patch.providers.subdl import SubdlSubtitle
+
+
[email protected](scope="session")
+def provider():
+ with SubdlProvider(os.environ["SUBDL_TOKEN"]) as provider:
+ yield provider
+
+
+def test_list_subtitles_movie(provider, movies, languages):
+ for sub in provider.list_subtitles(movies["dune"], {languages["en"]}):
+ assert sub.language == languages["en"]
+
+
+def test_download_subtitle(provider, languages):
+ data = {
+ "language": languages["en"],
+ "forced": False,
+ "hearing_impaired": False,
+ "page_link": "https://subdl.com/s/info/ebC6BrLCOC",
+ "download_link": "/subtitle/2808552-2770424.zip",
+ "file_id": "SUBDL::dune-2021-2770424.zip",
+ "release_names": ["Dune Part 1 WebDl"],
+ "uploader": "makoto77",
+ "season": 0,
+ "episode": None,
+ }
+
+ sub = SubdlSubtitle(**data)
+ provider.download_subtitle(sub)
+
+ assert sub.is_valid()