Add wordarr: request & import manager for ebooks, comics and audiobooks
FastAPI + SQLite backend with vanilla-JS web UI. Requests via Open Library / Audible / AniList metadata search (or manual entry) with per-request target library selection. Manual import flow: scan the download dir, fuzzy-match files against missing requests, review, then move+rename into the library per configurable naming templates. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Fable 5
parent
3789ad0a37
commit
508ae5f26e
@@ -0,0 +1,38 @@
|
||||
from types import SimpleNamespace
|
||||
|
||||
from wordarr.importer.matcher import best_matches, normalize
|
||||
|
||||
|
||||
def req(id, title, authors="", media_type="ebook"):
|
||||
return SimpleNamespace(id=id, title=title, authors=authors, media_type=media_type)
|
||||
|
||||
|
||||
def test_normalize():
|
||||
assert normalize("J.R.R._Tolkien-The_Hobbit[retail].epub") == "j r r tolkien the hobbit"
|
||||
|
||||
|
||||
def test_match_finds_right_request():
|
||||
requests = [
|
||||
req(1, "The Hobbit", "J.R.R. Tolkien"),
|
||||
req(2, "Dune", "Frank Herbert"),
|
||||
]
|
||||
items = [{"path": "/d/x.epub", "name": "Frank Herbert - Dune (1965) retail", "media_type": "ebook",
|
||||
"is_dir": False, "files": ["/d/x.epub"]}]
|
||||
out = best_matches(items, requests)
|
||||
assert out[0]["suggested_request_id"] == 2
|
||||
|
||||
|
||||
def test_no_match_for_unrelated_file():
|
||||
requests = [req(1, "The Hobbit", "Tolkien")]
|
||||
items = [{"path": "/d/y.epub", "name": "Cooking for Dummies 2019", "media_type": "ebook",
|
||||
"is_dir": False, "files": ["/d/y.epub"]}]
|
||||
out = best_matches(items, requests)
|
||||
assert out[0]["suggested_request_id"] is None
|
||||
|
||||
|
||||
def test_media_type_filter():
|
||||
requests = [req(1, "Dune", "Herbert", media_type="audiobook")]
|
||||
items = [{"path": "/d/dune.epub", "name": "Herbert - Dune", "media_type": "ebook",
|
||||
"is_dir": False, "files": ["/d/dune.epub"]}]
|
||||
out = best_matches(items, requests)
|
||||
assert out[0]["suggested_request_id"] is None
|
||||
Reference in New Issue
Block a user