feat: Media Explorer duyệt toàn bộ folder và files (tree đệ quy)
This commit is contained in:
+12
-9
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user