add(metadata): filter audible results by library language
This commit is contained in:
@@ -647,3 +647,43 @@ def test_append_without_the_flag_is_still_refused(client):
|
||||
assert not res["ok"]
|
||||
assert "bereits importiert" in res["error"]
|
||||
assert (second / "c.mp3").exists()
|
||||
|
||||
|
||||
def test_library_language_round_trip(client):
|
||||
lib = client.post("/api/libraries", json={
|
||||
"name": "english", "media_type": "audiobook",
|
||||
"root_path": str(client.tmp_path / "en"), "language": "english",
|
||||
}).json()
|
||||
assert lib["language"] == "english"
|
||||
assert client.get("/api/libraries").json()[0]["language"] == "english"
|
||||
|
||||
# libraries without a language keep working and stay unrestricted
|
||||
other = client.post("/api/libraries", json={
|
||||
"name": "adults", "media_type": "audiobook",
|
||||
"root_path": str(client.tmp_path / "de"),
|
||||
}).json()
|
||||
assert other["language"] == ""
|
||||
|
||||
updated = client.put(f"/api/libraries/{other['id']}", json={
|
||||
"name": "adults", "media_type": "audiobook",
|
||||
"root_path": str(client.tmp_path / "de"), "language": "german",
|
||||
}).json()
|
||||
assert updated["language"] == "german"
|
||||
|
||||
|
||||
def test_search_passes_language_to_the_provider(client, monkeypatch):
|
||||
from wordarr.metadata.base import MetadataResult
|
||||
seen = {}
|
||||
|
||||
async def fake(query, language=""):
|
||||
seen["query"], seen["language"] = query, language
|
||||
return [MetadataResult(media_type="audiobook", title="A Game of Thrones",
|
||||
language="english")]
|
||||
|
||||
monkeypatch.setitem(
|
||||
__import__("wordarr.metadata", fromlist=["PROVIDERS"]).PROVIDERS, "audiobook", fake)
|
||||
res = client.get("/api/search", params={
|
||||
"media_type": "audiobook", "q": "Game of Thrones", "language": "english",
|
||||
}).json()
|
||||
assert seen == {"query": "Game of Thrones", "language": "english"}
|
||||
assert res[0]["language"] == "english"
|
||||
|
||||
Reference in New Issue
Block a user