fix(metadata): get series from api
This commit is contained in:
@@ -225,3 +225,42 @@ def test_scan_rel_dir_and_request_update(client):
|
||||
assert updated["narrator"] == "Rufus Beck"
|
||||
assert updated["series"] == "HP"
|
||||
assert client.get("/api/requests", params={"status": "missing"}).json()[0]["narrator"] == "Rufus Beck"
|
||||
|
||||
|
||||
def test_retag_after_update(client):
|
||||
from mutagen.id3 import ID3
|
||||
|
||||
root = client.tmp_path / "library" / "retag"
|
||||
lib_id = client.post("/api/libraries", json={
|
||||
"name": "Retag", "media_type": "audiobook", "root_path": str(root),
|
||||
}).json()["id"]
|
||||
req_id = client.post("/api/requests", json={
|
||||
"library_id": lib_id, "title": "Der Ickabog", "authors": "J.K. Rowling",
|
||||
}).json()["id"]
|
||||
|
||||
book_dir = client.downloads / "Der Ickabog"
|
||||
book_dir.mkdir()
|
||||
for i in range(2):
|
||||
(book_dir / f"t{i}.mp3").write_bytes(b"")
|
||||
items = client.get("/api/import/scan").json()["items"]
|
||||
client.post("/api/import", json={"items": [{
|
||||
"path": items[0]["path"], "is_dir": True,
|
||||
"files": items[0]["files"], "request_id": req_id,
|
||||
}]})
|
||||
|
||||
# no series yet -> tag absent
|
||||
dest = root / "J.K. Rowling" / "Der Ickabog"
|
||||
first = sorted(dest.iterdir())[0]
|
||||
assert "TXXX:SERIES" not in ID3(first)
|
||||
|
||||
# add series + narrator, then retag
|
||||
client.put(f"/api/requests/{req_id}", json={
|
||||
"library_id": lib_id, "title": "Der Ickabog", "authors": "J.K. Rowling",
|
||||
"narrator": "Ben Becker", "series": "Rowling Kinderbücher", "volume": 2,
|
||||
})
|
||||
res = client.post(f"/api/requests/{req_id}/retag").json()
|
||||
assert res == {"ok": True, "files": 2}
|
||||
tags = ID3(first)
|
||||
assert str(tags["TXXX:SERIES"]) == "Rowling Kinderbücher"
|
||||
assert str(tags["TXXX:SERIES-PART"]) == "2"
|
||||
assert str(tags["TCOM"]) == "Ben Becker"
|
||||
|
||||
Reference in New Issue
Block a user