feat: Media Explorer duyệt toàn bộ folder và files (tree đệ quy)

This commit is contained in:
2026-08-02 14:31:42 +07:00
parent 1989bfb105
commit 4db777eb5d
5 changed files with 55 additions and 43 deletions
+12 -9
View File
@@ -118,16 +118,19 @@ async def browse_directory(path: str = Query(...)):
dirs.append({"name": name, "path": full, "is_dir": True})
else:
ext = os.path.splitext(name)[1].lower()
if ext in MEDIA_EXTS:
try:
size = os.path.getsize(full)
files.append({
"name": name,
"path": full,
"is_dir": False,
"size_mb": round(size / (1024 * 1024), 2),
"ext": ext,
"kind": "midi" if ext in MIDI_EXTS else "audio"
})
except OSError:
size = 0
kind = "midi" if ext in MIDI_EXTS else ("audio" if ext in AUDIO_EXTS else "other")
files.append({
"name": name,
"path": full,
"is_dir": False,
"size_mb": round(size / (1024 * 1024), 2),
"ext": ext,
"kind": kind
})
except OSError:
continue