diff --git a/media.db b/media.db index c07baf7..f623fbb 100644 Binary files a/media.db and b/media.db differ diff --git a/src/lib/scanner.ts b/src/lib/scanner.ts index 53a2c1e..c714dd1 100644 --- a/src/lib/scanner.ts +++ b/src/lib/scanner.ts @@ -34,21 +34,24 @@ const generatePhotoThumbnail = (photoPath: string, thumbnailPath: string) => { }; const scanLibrary = async (library: { id: number; path: string }) => { - // Scan videos - handle case variations - const videoPatterns = VIDEO_EXTENSIONS.flatMap(ext => [ - `${library.path}/**/*.${ext}`, - `${library.path}/**/*.${ext.toUpperCase()}`, - ]); - const videoFiles = await glob(videoPatterns, { nodir: true }); + // Scan videos - handle all case variations + const videoFiles = await glob(`${library.path}/**/*.*`, { nodir: true }); + + // Scan photos - handle all case variations + const photoFiles = await glob(`${library.path}/**/*.*`, { nodir: true }); + + // Filter files by extension (case-insensitive) + const filteredVideoFiles = videoFiles.filter(file => { + const ext = path.extname(file).toLowerCase().replace('.', ''); + return VIDEO_EXTENSIONS.includes(ext); + }); + + const filteredPhotoFiles = photoFiles.filter(file => { + const ext = path.extname(file).toLowerCase().replace('.', ''); + return PHOTO_EXTENSIONS.includes(ext); + }); - // Scan photos - handle case variations - const photoPatterns = PHOTO_EXTENSIONS.flatMap(ext => [ - `${library.path}/**/*.${ext}`, - `${library.path}/**/*.${ext.toUpperCase()}`, - ]); - const photoFiles = await glob(photoPatterns, { nodir: true }); - - const allFiles = [...videoFiles, ...photoFiles]; + const allFiles = [...filteredVideoFiles, ...filteredPhotoFiles]; for (const file of allFiles) { const stats = fs.statSync(file);