Fix scanner to use AudioTrack model with correct column names

Change Track → AudioTrack
Change file_path → filepath
Remove non-existent columns (spectral_rolloff, spectral_bandwidth)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
2025-12-03 00:08:03 +01:00
parent 4f5f68da09
commit fbc9d4822b

View File

@@ -15,7 +15,8 @@ sys.path.insert(0, str(Path(__file__).parent.parent.parent))
from src.core.audio_processor import extract_all_features
from src.core.essentia_classifier import EssentiaClassifier
from src.models.database import SessionLocal, Track
from src.models.database import SessionLocal
from src.models.schema import AudioTrack
from src.utils.logging import get_logger
logger = get_logger(__name__)
@@ -67,7 +68,7 @@ def analyze_and_store(file_path: Path, classifier: EssentiaClassifier, db) -> bo
logger.info(f"Processing: {file_path}")
# Check if already in database
existing = db.query(Track).filter(Track.file_path == str(file_path)).first()
existing = db.query(AudioTrack).filter(AudioTrack.filepath == str(file_path)).first()
if existing:
logger.info(f"Already in database, skipping: {file_path}")
return True
@@ -85,8 +86,8 @@ def analyze_and_store(file_path: Path, classifier: EssentiaClassifier, db) -> bo
instruments = classifier.predict_instruments(str(file_path))
# Create track record
track = Track(
file_path=str(file_path),
track = AudioTrack(
filepath=str(file_path),
filename=file_path.name,
duration_seconds=features['duration_seconds'],
tempo_bpm=features['tempo_bpm'],
@@ -98,8 +99,6 @@ def analyze_and_store(file_path: Path, classifier: EssentiaClassifier, db) -> bo
loudness_lufs=features['loudness_lufs'],
spectral_centroid=features['spectral_centroid'],
zero_crossing_rate=features['zero_crossing_rate'],
spectral_rolloff=features['spectral_rolloff'],
spectral_bandwidth=features['spectral_bandwidth'],
genre_primary=genre_result['primary'],
genre_secondary=genre_result['secondary'],
genre_confidence=genre_result['confidence'],