Fix scan qui échoue
This commit is contained in:
@@ -97,7 +97,40 @@ def scan_library_task(directory: str, db: Session):
|
|||||||
).first()
|
).first()
|
||||||
|
|
||||||
if existing:
|
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
|
scan_status["processed"] += 1
|
||||||
continue
|
continue
|
||||||
|
|
||||||
@@ -211,7 +244,7 @@ async def scan_library(
|
|||||||
)
|
)
|
||||||
|
|
||||||
# Use default music directory if not provided
|
# 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():
|
if not Path(scan_dir).exists():
|
||||||
raise HTTPException(
|
raise HTTPException(
|
||||||
|
|||||||
@@ -86,6 +86,8 @@ class AudioTrack(Base):
|
|||||||
return {
|
return {
|
||||||
"id": str(self.id),
|
"id": str(self.id),
|
||||||
"filepath": self.filepath,
|
"filepath": self.filepath,
|
||||||
|
"stream_filepath": self.stream_filepath,
|
||||||
|
"waveform_filepath": self.waveform_filepath,
|
||||||
"filename": self.filename,
|
"filename": self.filename,
|
||||||
"duration_seconds": self.duration_seconds,
|
"duration_seconds": self.duration_seconds,
|
||||||
"file_size_bytes": self.file_size_bytes,
|
"file_size_bytes": self.file_size_bytes,
|
||||||
|
|||||||
@@ -33,8 +33,8 @@ services:
|
|||||||
ports:
|
ports:
|
||||||
- "8001:8000"
|
- "8001:8000"
|
||||||
volumes:
|
volumes:
|
||||||
# Mount your audio library (read-only)
|
# Mount your audio library (read-write for transcoding and waveforms)
|
||||||
- ${AUDIO_LIBRARY_PATH:-./audio_samples}:/audio:ro
|
- ${AUDIO_LIBRARY_PATH:-./audio_samples}:/audio
|
||||||
# Mount models directory
|
# Mount models directory
|
||||||
- ./backend/models:/app/models
|
- ./backend/models:/app/models
|
||||||
restart: unless-stopped
|
restart: unless-stopped
|
||||||
|
|||||||
Reference in New Issue
Block a user