32 lines
690 B
Python
32 lines
690 B
Python
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
|