Rename cover files: frontcover.jpg → front.jpg, backcover.jpg → back.jpg

Shorter, cleaner filenames consistent with Jellyfin conventions.
Updated all references in source, tests, and documentation.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Dieter Schlüter 2026-02-20 09:56:12 +01:00
commit 1ca88b0d6d
9 changed files with 145 additions and 68 deletions

View file

@ -23,22 +23,22 @@ class TestFindCover:
"""Tests für find_cover."""
def test_finds_frontcover_jpg(self, tmp_path: Path) -> None:
(tmp_path / "frontcover.jpg").touch()
assert find_cover(tmp_path, "front") == tmp_path / "frontcover.jpg"
(tmp_path / "front.jpg").touch()
assert find_cover(tmp_path, "front") == tmp_path / "front.jpg"
def test_finds_frontcover_png(self, tmp_path: Path) -> None:
(tmp_path / "frontcover.png").touch()
assert find_cover(tmp_path, "front") == tmp_path / "frontcover.png"
(tmp_path / "front.png").touch()
assert find_cover(tmp_path, "front") == tmp_path / "front.png"
def test_jpg_preferred_over_png(self, tmp_path: Path) -> None:
(tmp_path / "frontcover.jpg").touch()
(tmp_path / "frontcover.png").touch()
(tmp_path / "front.jpg").touch()
(tmp_path / "front.png").touch()
# .jpg wird zuerst geprüft
assert find_cover(tmp_path, "front") == tmp_path / "frontcover.jpg"
assert find_cover(tmp_path, "front") == tmp_path / "front.jpg"
def test_finds_backcover(self, tmp_path: Path) -> None:
(tmp_path / "backcover.jpg").touch()
assert find_cover(tmp_path, "back") == tmp_path / "backcover.jpg"
(tmp_path / "back.jpg").touch()
assert find_cover(tmp_path, "back") == tmp_path / "back.jpg"
def test_returns_none_if_missing(self, tmp_path: Path) -> None:
assert find_cover(tmp_path, "front") is None
@ -47,7 +47,7 @@ class TestFindCover:
def test_follows_symlink(self, tmp_path: Path) -> None:
real = tmp_path / "original.jpg"
real.touch()
link = tmp_path / "frontcover.jpg"
link = tmp_path / "front.jpg"
link.symlink_to(real)
assert find_cover(tmp_path, "front") == link
@ -95,33 +95,33 @@ class TestCopyCovers:
def test_copies_front_cover(self, tmp_path: Path) -> None:
src = _make_image(tmp_path / "src.jpg")
copy_covers(src, None, tmp_path)
assert (tmp_path / "frontcover.jpg").exists()
assert (tmp_path / "front.jpg").exists()
def test_copies_back_cover(self, tmp_path: Path) -> None:
src = _make_image(tmp_path / "src.jpg")
copy_covers(None, src, tmp_path)
assert (tmp_path / "backcover.jpg").exists()
assert (tmp_path / "back.jpg").exists()
def test_copies_both_covers(self, tmp_path: Path) -> None:
front = _make_image(tmp_path / "front.jpg")
back = _make_image(tmp_path / "back.jpg")
copy_covers(front, back, tmp_path)
assert (tmp_path / "frontcover.jpg").exists()
assert (tmp_path / "backcover.jpg").exists()
assert (tmp_path / "front.jpg").exists()
assert (tmp_path / "back.jpg").exists()
def test_skips_nonexistent_front(self, tmp_path: Path) -> None:
copy_covers(tmp_path / "nope.jpg", None, tmp_path)
assert not (tmp_path / "frontcover.jpg").exists()
assert not (tmp_path / "front.jpg").exists()
def test_skips_nonexistent_back(self, tmp_path: Path) -> None:
copy_covers(None, tmp_path / "nope.jpg", tmp_path)
assert not (tmp_path / "backcover.jpg").exists()
assert not (tmp_path / "back.jpg").exists()
def test_existing_frontcover_not_overwritten_when_no_source(self, tmp_path: Path) -> None:
existing = _make_image(tmp_path / "frontcover.jpg")
existing = _make_image(tmp_path / "front.jpg")
original_mtime = existing.stat().st_mtime
copy_covers(None, None, tmp_path)
assert (tmp_path / "frontcover.jpg").stat().st_mtime == original_mtime
assert (tmp_path / "front.jpg").stat().st_mtime == original_mtime
def _fake_image_bytes() -> bytes:
@ -151,10 +151,10 @@ class TestDownloadCaaCovers:
with patch("musiksammlung.cover.httpx.get", return_value=resp):
download_caa_covers("test-mbid", tmp_path)
assert (tmp_path / "frontcover.jpg").exists()
assert (tmp_path / "backcover.jpg").exists()
assert (tmp_path / "front.jpg").exists()
assert (tmp_path / "back.jpg").exists()
# Ergebnis ist ein gültiges JPEG
assert Image.open(tmp_path / "frontcover.jpg").format == "JPEG"
assert Image.open(tmp_path / "front.jpg").format == "JPEG"
def test_404_skips_cover(self, tmp_path: Path) -> None:
"""404 → kein Cover, kein Fehler."""
@ -163,8 +163,8 @@ class TestDownloadCaaCovers:
with patch("musiksammlung.cover.httpx.get", return_value=resp_404):
download_caa_covers("no-cover-mbid", tmp_path)
assert not (tmp_path / "frontcover.jpg").exists()
assert not (tmp_path / "backcover.jpg").exists()
assert not (tmp_path / "front.jpg").exists()
assert not (tmp_path / "back.jpg").exists()
def test_http_error_continues(self, tmp_path: Path) -> None:
"""Netzwerkfehler → Warnung, kein Abbruch."""
@ -174,12 +174,12 @@ class TestDownloadCaaCovers:
):
download_caa_covers("error-mbid", tmp_path)
assert not (tmp_path / "frontcover.jpg").exists()
assert not (tmp_path / "backcover.jpg").exists()
assert not (tmp_path / "front.jpg").exists()
assert not (tmp_path / "back.jpg").exists()
def test_skips_existing_cover(self, tmp_path: Path) -> None:
"""Bereits vorhandene Cover werden nicht überschrieben."""
existing = _make_image(tmp_path / "frontcover.jpg")
existing = _make_image(tmp_path / "front.jpg")
original_size = existing.stat().st_size
img_bytes = _fake_image_bytes()
@ -188,15 +188,15 @@ class TestDownloadCaaCovers:
with patch("musiksammlung.cover.httpx.get", return_value=resp) as mock_get:
download_caa_covers("test-mbid", tmp_path)
# frontcover.jpg bleibt unverändert
assert (tmp_path / "frontcover.jpg").stat().st_size == original_size
# backcover.jpg wird heruntergeladen (war nicht vorhanden)
assert (tmp_path / "backcover.jpg").exists()
# front.jpg bleibt unverändert
assert (tmp_path / "front.jpg").stat().st_size == original_size
# back.jpg wird heruntergeladen (war nicht vorhanden)
assert (tmp_path / "back.jpg").exists()
# Nur ein HTTP-Request (für back), nicht zwei
assert mock_get.call_count == 1
def test_front_only_on_back_404(self, tmp_path: Path) -> None:
"""Front 200, Back 404 → nur frontcover.jpg erstellt."""
"""Front 200, Back 404 → nur front.jpg erstellt."""
img_bytes = _fake_image_bytes()
resp_ok = _mock_caa_response(200, img_bytes)
resp_404 = _mock_caa_response(404)
@ -207,5 +207,5 @@ class TestDownloadCaaCovers:
):
download_caa_covers("mixed-mbid", tmp_path)
assert (tmp_path / "frontcover.jpg").exists()
assert not (tmp_path / "backcover.jpg").exists()
assert (tmp_path / "front.jpg").exists()
assert not (tmp_path / "back.jpg").exists()