fix(metadata): find audiobook series through hardcover when audible leaves them untagged
Build image / image (push) Successful in 51s
Build image / image (push) Successful in 51s
This commit is contained in:
1 parent
c8d4d239ec
commit
91ad7ff98b
4 files changed
+72
-16
No files matched your search
@@ -82,3 +82,42 @@ def test_a_broken_fallback_never_breaks_the_search(monkeypatch):
|
||||
monkeypatch.setattr(metadata.musicbrainz, "search", boom)
|
||||
results = asyncio.run(metadata.audiobook_search("Toteninsel"))
|
||||
assert [r.title for r in results] == ["Da"]
|
||||
|
||||
|
||||
def test_audiobook_search_appends_hardcover_series_as_audiobooks(monkeypatch):
|
||||
from wordarr.metadata.base import MetadataResult
|
||||
|
||||
async def fake_audible(query, language=""):
|
||||
return [MetadataResult(media_type="audiobook", title="Die letzte Witwe")]
|
||||
|
||||
async def no_hits(query, language=""):
|
||||
return []
|
||||
|
||||
async def fake_hardcover(query, language=""):
|
||||
return [MetadataResult(media_type="ebook", source="hardcover",
|
||||
title="Die verstummte Frau", series="Will Trent",
|
||||
series_id="3670", volume=10)]
|
||||
|
||||
monkeypatch.setattr(metadata.audible, "search", fake_audible)
|
||||
monkeypatch.setattr(metadata.musicbrainz, "search", no_hits)
|
||||
monkeypatch.setattr(metadata.hardcover, "search", fake_hardcover)
|
||||
results = asyncio.run(metadata.audiobook_search("Karin Slaughter", "german"))
|
||||
assert [r.source for r in results] == ["audible", "hardcover"]
|
||||
assert results[1].media_type == "audiobook"
|
||||
|
||||
|
||||
def test_audiobook_series_goes_to_the_provider_of_the_hit(monkeypatch):
|
||||
from wordarr.metadata.base import MetadataResult
|
||||
|
||||
async def fake_series_books(series_id, language=""):
|
||||
return [MetadataResult(media_type="ebook", source="hardcover",
|
||||
title="Triptych", volume=1)]
|
||||
|
||||
async def audible_must_not_run(series_id, title):
|
||||
raise AssertionError("a hardcover id is no audible series asin")
|
||||
|
||||
monkeypatch.setattr(metadata.hardcover, "series_books", fake_series_books)
|
||||
monkeypatch.setattr(metadata.audible, "series_episodes", audible_must_not_run)
|
||||
lookup = metadata.SERIES_PROVIDERS["audiobook"]
|
||||
books = asyncio.run(lookup("3670", "Will Trent", "german", "hardcover"))
|
||||
assert [(b.title, b.media_type) for b in books] == [("Triptych", "audiobook")]
|
||||
Reference in new issue
Block a user