Auto-create audio_library folder and improve scanner error handling
This commit is contained in:
@@ -13,9 +13,26 @@ export class AudioScanner {
|
|||||||
|
|
||||||
async scanLibrary() {
|
async scanLibrary() {
|
||||||
console.log(`🔍 Scanning library: ${this.libraryPath}`);
|
console.log(`🔍 Scanning library: ${this.libraryPath}`);
|
||||||
|
|
||||||
|
// Check if directory exists, create if not
|
||||||
|
try {
|
||||||
|
await fs.access(this.libraryPath);
|
||||||
|
} catch (error) {
|
||||||
|
console.log(`📁 Creating library directory: ${this.libraryPath}`);
|
||||||
|
await fs.mkdir(this.libraryPath, { recursive: true });
|
||||||
|
console.log(`⚠️ Directory was empty. Add audio files to ${this.libraryPath} and scan again.`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
const files = await this.findAudioFiles(this.libraryPath);
|
const files = await this.findAudioFiles(this.libraryPath);
|
||||||
console.log(`📁 Found ${files.length} audio files`);
|
console.log(`📁 Found ${files.length} audio files`);
|
||||||
|
|
||||||
|
if (files.length === 0) {
|
||||||
|
console.log(`⚠️ No audio files found in ${this.libraryPath}`);
|
||||||
|
console.log(` Add .mp3, .m4a, .flac, .wav, .aac, or .ogg files and scan again.`);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
let processed = 0;
|
let processed = 0;
|
||||||
for (const filePath of files) {
|
for (const filePath of files) {
|
||||||
try {
|
try {
|
||||||
|
|||||||
Reference in New Issue
Block a user