mirror of https://github.com/morpheus65535/bazarr
no log: add update_matches() providers util
This commit is contained in:
parent
d95d6b9d35
commit
a95086555f
|
@ -9,8 +9,12 @@ from guessit import guessit
|
||||||
|
|
||||||
from subliminal.subtitle import fix_line_ending
|
from subliminal.subtitle import fix_line_ending
|
||||||
|
|
||||||
|
from subliminal_patch.core import Episode
|
||||||
|
from subliminal_patch.subtitle import guess_matches
|
||||||
|
|
||||||
from ._agent_list import FIRST_THOUSAND_OR_SO_USER_AGENTS
|
from ._agent_list import FIRST_THOUSAND_OR_SO_USER_AGENTS
|
||||||
|
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
|
|
||||||
|
@ -90,3 +94,16 @@ def get_archive_from_bytes(content: bytes):
|
||||||
|
|
||||||
logger.debug("Unknown compression format")
|
logger.debug("Unknown compression format")
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
def update_matches(matches, video, release_info: str, **guessit_options):
|
||||||
|
"Update matches set from release info string. New lines are iterated."
|
||||||
|
guessit_options["type"] = "episode" if isinstance(video, Episode) else "movie"
|
||||||
|
logger.debug("Guessit options to update matches: %s", guessit_options)
|
||||||
|
|
||||||
|
for release in release_info.split("\n"):
|
||||||
|
logger.debug("Updating matches from release info: %s", release)
|
||||||
|
matches |= guess_matches(video, guessit(release.strip(), guessit_options))
|
||||||
|
logger.debug("New matches: %s", matches)
|
||||||
|
|
||||||
|
return matches
|
||||||
|
|
|
@ -45,3 +45,11 @@ def test_get_archive_from_bytes_zip(data, filename):
|
||||||
|
|
||||||
def test_get_archive_from_bytes_none():
|
def test_get_archive_from_bytes_none():
|
||||||
assert utils.get_archive_from_bytes(bytes()) is None
|
assert utils.get_archive_from_bytes(bytes()) is None
|
||||||
|
|
||||||
|
|
||||||
|
def test_update_matches(movies):
|
||||||
|
matches = set()
|
||||||
|
utils.update_matches(
|
||||||
|
matches, movies["dune"], "Subs for dune 2021 bluray x264\nDune webrip x264"
|
||||||
|
)
|
||||||
|
assert "source" in matches
|
||||||
|
|
Loading…
Reference in New Issue