- Fix WebDAV service to find all 4,101 MP3 files instead of 1,023 - Add support for AIFF files (.aif, .aiff) in audio detection - Update audioMetadataService to recognize AIFF formats - Simplify BackgroundJobProgress component polling logic - Add maxDepth parameter to WebDAV directory listing - Add comprehensive test scripts for debugging WebDAV integration The WebDAV integration now correctly processes all 4,257 audio files from the music collection, including 4,101 MP3 files and 156 other audio formats (FLAC, WAV, AIFF, M4A, OGG).
93 lines
3.2 KiB
JavaScript
93 lines
3.2 KiB
JavaScript
import { WebDAVService } from './src/services/webdavService.js';
|
|
import fs from 'fs';
|
|
|
|
async function testWebDAVService() {
|
|
try {
|
|
// Load configuration
|
|
const configData = fs.readFileSync('storage-config.json', 'utf-8');
|
|
const config = JSON.parse(configData);
|
|
|
|
console.log('🔍 Testing WebDAV Service:');
|
|
console.log('URL:', config.url);
|
|
console.log('Username:', config.username);
|
|
console.log('Base Path:', config.basePath);
|
|
console.log('');
|
|
|
|
// Create WebDAV service
|
|
const webdavService = new WebDAVService(config);
|
|
|
|
console.log('🔗 Testing connection...');
|
|
const connectionTest = await webdavService.testConnection();
|
|
console.log('Connection test:', connectionTest ? '✅ Success' : '❌ Failed');
|
|
console.log('');
|
|
|
|
if (connectionTest) {
|
|
console.log('📁 Testing listAllFiles...');
|
|
const startTime = Date.now();
|
|
const allFiles = await webdavService.listAllFiles();
|
|
const endTime = Date.now();
|
|
|
|
console.log(`✅ listAllFiles completed in ${endTime - startTime}ms`);
|
|
console.log('Total files found:', allFiles.length);
|
|
console.log('');
|
|
|
|
// Filter for MP3 files
|
|
const mp3Files = allFiles.filter(file => {
|
|
const filename = file.key.split('/').pop() || file.key;
|
|
return filename.toLowerCase().endsWith('.mp3');
|
|
});
|
|
|
|
console.log('🎵 MP3 Files found by service:', mp3Files.length);
|
|
console.log('');
|
|
|
|
// Show first 20 MP3 files
|
|
console.log('🎵 First 20 MP3 files from service:');
|
|
mp3Files.slice(0, 20).forEach((file, index) => {
|
|
console.log(` ${index + 1}. ${file.key} (${file.size} bytes)`);
|
|
});
|
|
|
|
if (mp3Files.length > 20) {
|
|
console.log(` ... and ${mp3Files.length - 20} more MP3 files`);
|
|
}
|
|
|
|
// Check directory distribution
|
|
console.log('');
|
|
console.log('📁 Directory distribution of MP3 files:');
|
|
const dirCounts = new Map();
|
|
mp3Files.forEach(file => {
|
|
const dir = file.key.split('/')[0];
|
|
dirCounts.set(dir, (dirCounts.get(dir) || 0) + 1);
|
|
});
|
|
|
|
const sortedDirs = Array.from(dirCounts.entries()).sort((a, b) => b[1] - a[1]);
|
|
sortedDirs.forEach(([dir, count]) => {
|
|
console.log(` 📁 ${dir}: ${count} MP3 files`);
|
|
});
|
|
|
|
// Test with different prefixes
|
|
console.log('');
|
|
console.log('🔍 Testing with different prefixes...');
|
|
|
|
const testPrefixes = ['', 'Gekocht', 'Merijn Music', 'Musica'];
|
|
for (const prefix of testPrefixes) {
|
|
try {
|
|
const prefixFiles = await webdavService.listAllFiles(prefix);
|
|
const prefixMp3Files = prefixFiles.filter(file => {
|
|
const filename = file.key.split('/').pop() || file.key;
|
|
return filename.toLowerCase().endsWith('.mp3');
|
|
});
|
|
console.log(` 📁 Prefix "${prefix}": ${prefixMp3Files.length} MP3 files`);
|
|
} catch (error) {
|
|
console.log(` ❌ Prefix "${prefix}": Error - ${error.message}`);
|
|
}
|
|
}
|
|
}
|
|
|
|
} catch (error) {
|
|
console.error('❌ Failed to test WebDAV service:', error);
|
|
}
|
|
}
|
|
|
|
// Run the test
|
|
testWebDAVService().catch(console.error);
|