Add working crate parser and filesystem scanner
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
from pathlib import Path
|
||||
|
||||
from serato_doctor.models import DiskTrack
|
||||
|
||||
AUDIO_SUFFIXES = {".mp3", ".m4a", ".wav", ".aif", ".aiff", ".flac"}
|
||||
|
||||
|
||||
def scan_audio(folder: Path) -> list[DiskTrack]:
|
||||
tracks = []
|
||||
|
||||
for path in folder.rglob("*"):
|
||||
if not path.is_file():
|
||||
continue
|
||||
if path.suffix.lower() not in AUDIO_SUFFIXES:
|
||||
continue
|
||||
|
||||
try:
|
||||
stat = path.stat()
|
||||
except OSError:
|
||||
continue
|
||||
|
||||
tracks.append(
|
||||
DiskTrack(
|
||||
path=path,
|
||||
filename=path.name,
|
||||
size=stat.st_size,
|
||||
suffix=path.suffix.lower(),
|
||||
)
|
||||
)
|
||||
|
||||
return tracks
|
||||
|
||||
Reference in New Issue
Block a user