diff options
| author | Christophe Besson <cbesson@gmail.com> | 2026-08-26 18:09:49 +0200 |
|---|---|---|
| committer | Christophe Besson <cbesson@gmail.com> | 2026-08-26 18:09:49 +0200 |
| commit | e1f1b65cfac031096e4bae24ccf102ca0dbb86d9 (patch) | |
| tree | 1a783c4ed5dcf23bc65d6bb8825906473670d3aa /packages/meshbay-node/src/meshbay_node | |
| parent | 80cb6c4dc5f22336387f2ac74ef2cb85cf2cf7d4 (diff) | |
| parent | 6fb948045b9c563ce591da289cdac1df6bed360c (diff) | |
| download | meshbay-e1f1b65cfac031096e4bae24ccf102ca0dbb86d9.tar.gz | |
Merge branch 'fix/music-cover-mixed-folder'
Diffstat (limited to 'packages/meshbay-node/src/meshbay_node')
| -rw-r--r-- | packages/meshbay-node/src/meshbay_node/indexer/enrich_audio.py | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/packages/meshbay-node/src/meshbay_node/indexer/enrich_audio.py b/packages/meshbay-node/src/meshbay_node/indexer/enrich_audio.py index a93df51..4fa08ef 100644 --- a/packages/meshbay-node/src/meshbay_node/indexer/enrich_audio.py +++ b/packages/meshbay-node/src/meshbay_node/indexer/enrich_audio.py @@ -141,6 +141,18 @@ def _extract_cover(mf) -> bytes | None: _COVER_STEM_RANK = ("cover", "folder", "front", "albumart") _COVER_EXTS = (".jpg", ".jpeg", ".png") +# Windows Media Player's per-folder thumbnail cache: one `AlbumArt_{guid}_*` +# pair per *release* it ever cached art for in that folder, keyed by a GUID +# tied to that release — never to a track. Real folder, real GUIDs (module +# docstring's revision note): a ~500-track flat "chart ranking" rip mixing +# dozens of unrelated artists carried seven distinct guids here, each an art +# leftover from one different original album. `Folder.jpg`/`AlbumArtSmall.jpg` +# are WMP's own copy of just *one* arbitrary one of those for the folder icon +# — fine when a folder really is one release (one guid, or none), meaningless +# once two or more show up: there is no way to tell which track it belongs to, +# so no candidate in the folder can be trusted as "the" cover for any of them. +_WMP_ALBUMART_GUID_RE = re.compile(r"^albumart_\{([0-9a-f-]{36})\}_(large|small)$", re.IGNORECASE) + def _find_sibling_cover(folder: Path) -> Path | None: try: @@ -151,6 +163,11 @@ def _find_sibling_cover(folder: Path) -> Path | None: if not candidates: return None + guids = {m.group(1).lower() for p in candidates + if (m := _WMP_ALBUMART_GUID_RE.match(p.stem))} + if len(guids) >= 2: + return None + def rank(p: Path) -> int: stem = p.stem.lower() for i, name in enumerate(_COVER_STEM_RANK): |