mirror of
https://github.com/unshackle-dl/unshackle.git
synced 2026-11-29 20:45:11 +00:00
fix(providers): match a later season's year and TVDB translated names in metadata searches
This commit is contained in:
+30
-1
@@ -6,7 +6,8 @@ import pytest
|
||||
|
||||
from unshackle.core import providers
|
||||
from unshackle.core.config import config
|
||||
from unshackle.core.providers.tvdb import TVDBProvider, ids_from_remote, pick_match
|
||||
from unshackle.core.providers import result_matches
|
||||
from unshackle.core.providers.tvdb import TVDBProvider, ids_from_remote, pick_match, result_names
|
||||
from unshackle.core.utils.tags import build_tags_from_ids
|
||||
|
||||
REMOTE_IDS = [
|
||||
@@ -109,6 +110,34 @@ def test_pick_match_returns_nothing_when_no_year_fits() -> None:
|
||||
assert pick_match(BSG, "Battlestar Galactica", 1995)[0] is None
|
||||
|
||||
|
||||
EXAMPLE_HIT = {
|
||||
"name": "エグザンプル",
|
||||
"aliases": ["Eguzanpuru", "Eguzanpuru"],
|
||||
"translations": {"eng": "EXAMPLE Show", "jpn": "エグザンプル"},
|
||||
"year": "2020",
|
||||
"tvdb_id": "101",
|
||||
}
|
||||
|
||||
|
||||
def test_result_names_lists_each_name_once() -> None:
|
||||
assert result_names(EXAMPLE_HIT) == ("エグザンプル", "Eguzanpuru", "EXAMPLE Show")
|
||||
assert result_names({"name": "EXAMPLE", "aliases": [{"language": "eng", "name": "x"}, ""]}) == ("EXAMPLE",)
|
||||
|
||||
|
||||
def test_search_matches_on_a_translated_name(monkeypatch: pytest.MonkeyPatch) -> None:
|
||||
p = TVDBProvider()
|
||||
monkeypatch.setattr(p, "api_get", lambda path, params=None: [EXAMPLE_HIT])
|
||||
result = p.search("EXAMPLE Show", 2020, "tv")
|
||||
assert result is not None and result.external_ids.tvdb_id == 101
|
||||
assert result_matches(result, "EXAMPLE Show")
|
||||
assert not result_matches(result, "OTHER Show")
|
||||
|
||||
|
||||
def test_cached_tvdb_result_matches_on_a_translated_name() -> None:
|
||||
result = providers.cached_to_result(EXAMPLE_HIT, "tvdb", "tv")
|
||||
assert result is not None and result_matches(result, "EXAMPLE Show")
|
||||
|
||||
|
||||
def test_tvdb2_tag_follows_the_matroska_spec() -> None:
|
||||
# TVDB2 IDs are prefixed by entity type: matroska.org/technical/tagging.html
|
||||
from unshackle.core.providers import ExternalIds
|
||||
|
||||
Reference in New Issue
Block a user