Fix scan qui échoue
This commit is contained in:
@@ -97,7 +97,40 @@ def scan_library_task(directory: str, db: Session):
|
||||
).first()
|
||||
|
||||
if existing:
|
||||
logger.info(f"Already in database, skipping: {file_path.name}")
|
||||
# Check if needs transcoding/waveform
|
||||
needs_update = False
|
||||
|
||||
if not existing.stream_filepath or not Path(existing.stream_filepath).exists():
|
||||
logger.info(f" → Needs transcoding: {file_path.name}")
|
||||
needs_update = True
|
||||
|
||||
# Transcode to MP3 128kbps
|
||||
stream_path = transcoder.transcode_to_mp3(
|
||||
str(file_path),
|
||||
bitrate="128k",
|
||||
overwrite=False
|
||||
)
|
||||
if stream_path:
|
||||
existing.stream_filepath = stream_path
|
||||
|
||||
if not existing.waveform_filepath or not Path(existing.waveform_filepath).exists():
|
||||
logger.info(f" → Needs waveform: {file_path.name}")
|
||||
needs_update = True
|
||||
|
||||
# Pre-compute waveform
|
||||
waveform_dir = file_path.parent / "waveforms"
|
||||
waveform_dir.mkdir(parents=True, exist_ok=True)
|
||||
waveform_path = waveform_dir / f"{file_path.stem}.waveform.json"
|
||||
|
||||
if save_waveform_to_file(str(file_path), str(waveform_path), num_peaks=800):
|
||||
existing.waveform_filepath = str(waveform_path)
|
||||
|
||||
if needs_update:
|
||||
db.commit()
|
||||
logger.info(f"✓ Updated: {file_path.name}")
|
||||
else:
|
||||
logger.info(f"Already complete, skipping: {file_path.name}")
|
||||
|
||||
scan_status["processed"] += 1
|
||||
continue
|
||||
|
||||
@@ -211,7 +244,7 @@ async def scan_library(
|
||||
)
|
||||
|
||||
# Use default music directory if not provided
|
||||
scan_dir = directory if directory else "/music"
|
||||
scan_dir = directory if directory else "/audio"
|
||||
|
||||
if not Path(scan_dir).exists():
|
||||
raise HTTPException(
|
||||
|
||||
Reference in New Issue
Block a user