feat: bootstrap NAS music deduper

This commit is contained in:
OpenClaw Agent
2026-09-18 04:48:47 +08:00
commit 6154cd0752
17 changed files with 481 additions and 0 deletions
+24
View File
@@ -0,0 +1,24 @@
from __future__ import annotations
from pathlib import Path
try:
from tinytag import TinyTag
except ImportError: # optional until metadata phase is invoked
TinyTag = None
def read_metadata(path: Path) -> dict:
if TinyTag is None:
return {}
tag = TinyTag.get(str(path), image=False)
return {
"duration": tag.duration,
"artist": tag.artist,
"title": tag.title,
"album": tag.album,
"format": path.suffix.lower().lstrip("."),
"bitrate": int(tag.bitrate) if tag.bitrate else None,
"sample_rate": int(tag.samplerate) if tag.samplerate else None,
"bit_depth": int(tag.bitdepth) if tag.bitdepth else None,
}