Fix scanner to read library path from config.json
This commit is contained in:
@@ -1,15 +1,25 @@
|
||||
import { AudioScanner } from '../services/audioScanner.js';
|
||||
import { initDatabase } from '../database/db.js';
|
||||
import { loadConfig } from '../routes/settings.js';
|
||||
import path from 'path';
|
||||
|
||||
const libraryPath = process.argv[2] || path.join(process.cwd(), 'audio_library');
|
||||
|
||||
console.log('🎵 CarPlay Audio Library Scanner');
|
||||
console.log('================================\n');
|
||||
|
||||
await initDatabase();
|
||||
|
||||
const scanner = new AudioScanner(libraryPath);
|
||||
// Load config to get library path
|
||||
const config = await loadConfig();
|
||||
const libraryPath = process.argv[2] || config.libraryPath;
|
||||
|
||||
// Resolve path
|
||||
const resolvedPath = path.isAbsolute(libraryPath)
|
||||
? libraryPath
|
||||
: path.join(process.cwd(), libraryPath);
|
||||
|
||||
console.log(`📂 Using library path: ${resolvedPath}\n`);
|
||||
|
||||
const scanner = new AudioScanner(resolvedPath);
|
||||
await scanner.scanLibrary();
|
||||
|
||||
console.log('\n✅ Library scan complete!');
|
||||
|
||||
Reference in New Issue
Block a user