aboutsummaryrefslogtreecommitdiffstats
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.py18
1 files changed, 11 insertions, 7 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 397f760..ecc3b5e 100644
--- a/packages/meshbay-node/src/meshbay_node/indexer/enrich_audio.py
+++ b/packages/meshbay-node/src/meshbay_node/indexer/enrich_audio.py
@@ -60,11 +60,13 @@ image-file fallback for cover art, same as everything else.
import asyncio
import logging
+import os
import re
from collections.abc import Awaitable, Callable
from pathlib import Path
import blake3
+from meshbay_common.paths import long_path
from meshbay_common.protocol import IndexEntry
from mutagen import File as MutagenFile
from mutagen.asf import ASF
@@ -155,8 +157,9 @@ _WMP_ALBUMART_GUID_RE = re.compile(r"^albumart_\{([0-9a-f-]{36})\}_(large|small)
def _find_sibling_cover(folder: Path) -> Path | None:
try:
- candidates = [p for p in folder.iterdir()
- if p.is_file() and p.suffix.lower() in _COVER_EXTS]
+ with os.scandir(long_path(folder)) as listing:
+ candidates = [folder / e.name for e in listing
+ if e.is_file() and Path(e.name).suffix.lower() in _COVER_EXTS]
except OSError:
return None
if not candidates:
@@ -240,12 +243,12 @@ def _read_format_specific_tags(path: Path) -> tuple[dict, float | None] | None:
suffix = path.suffix.lower()
if suffix == ".wma":
try:
- return _asf_tags_from_object(ASF(str(path)))
+ return _asf_tags_from_object(ASF(long_path(path)))
except Exception:
return {}, None
if suffix == ".mpc":
try:
- return _musepack_tags_from_object(Musepack(str(path)))
+ return _musepack_tags_from_object(Musepack(long_path(path)))
except Exception:
return {}, None
return None
@@ -257,7 +260,7 @@ def _read_generic_tags_and_cover(
tags: dict = {}
duration: float | None = None
try:
- easy = MutagenFile(str(path), easy=True)
+ easy = MutagenFile(long_path(path), easy=True)
except Exception:
easy = None
if easy is not None:
@@ -277,7 +280,7 @@ def _read_generic_tags_and_cover(
cover: bytes | None = None
if not skip_cover:
try:
- raw = MutagenFile(str(path))
+ raw = MutagenFile(long_path(path))
except Exception:
raw = None
if raw is not None:
@@ -339,7 +342,8 @@ def _read_sibling_cover(path: Path) -> bytes | None:
if sibling is None:
return None
try:
- return sibling.read_bytes()
+ with open(long_path(sibling), "rb") as f:
+ return f.read()
except OSError:
return None