summaryrefslogtreecommitdiffstats
path: root/packages/meshbay-node/src/meshbay_node/indexer/enrich_audio.py
diff options
context:
space:
mode:
Diffstat (limited to 'packages/meshbay-node/src/meshbay_node/indexer/enrich_audio.py')
-rw-r--r--packages/meshbay-node/src/meshbay_node/indexer/enrich_audio.py17
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):