mirror of https://github.com/morpheus65535/bazarr
Subdl Provider: add tests and use standard utils
This commit is contained in:
parent
127a7aebad
commit
91a35317cc
|
@ -17,8 +17,7 @@ from .mixins import ProviderRetryMixin
|
||||||
from subliminal_patch.subtitle import Subtitle
|
from subliminal_patch.subtitle import Subtitle
|
||||||
from subliminal.subtitle import fix_line_ending
|
from subliminal.subtitle import fix_line_ending
|
||||||
from subliminal_patch.providers import Provider
|
from subliminal_patch.providers import Provider
|
||||||
from subliminal_patch.subtitle import guess_matches
|
from subliminal_patch.providers import utils
|
||||||
from guessit import guessit
|
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
@ -57,7 +56,6 @@ class SubdlSubtitle(Subtitle):
|
||||||
|
|
||||||
def get_matches(self, video):
|
def get_matches(self, video):
|
||||||
matches = set()
|
matches = set()
|
||||||
type_ = "movie" if isinstance(video, Movie) else "episode"
|
|
||||||
|
|
||||||
# handle movies and series separately
|
# handle movies and series separately
|
||||||
if isinstance(video, Episode):
|
if isinstance(video, Episode):
|
||||||
|
@ -77,8 +75,7 @@ class SubdlSubtitle(Subtitle):
|
||||||
# imdb
|
# imdb
|
||||||
matches.add('imdb_id')
|
matches.add('imdb_id')
|
||||||
|
|
||||||
# other properties
|
utils.update_matches(matches, video, self.release_info)
|
||||||
matches |= guess_matches(video, guessit(self.release_info, {"type": type_}))
|
|
||||||
|
|
||||||
self.matches = matches
|
self.matches = matches
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,36 @@
|
||||||
|
import os
|
||||||
|
|
||||||
|
import pytest
|
||||||
|
from subliminal_patch.providers.subdl import SubdlProvider
|
||||||
|
from subliminal_patch.providers.subdl import SubdlSubtitle
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture(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()
|
Loading…
Reference in New Issue