diff --git a/media.db b/media.db index d6cbc9c..c07baf7 100644 Binary files a/media.db and b/media.db differ diff --git a/src/app/api/files/route.ts b/src/app/api/files/route.ts index 9092650..ffcfea0 100644 --- a/src/app/api/files/route.ts +++ b/src/app/api/files/route.ts @@ -31,9 +31,10 @@ export async function GET(request: Request) { const ext = path.extname(file).toLowerCase(); let type = 'file'; - if (VIDEO_EXTENSIONS.some(v => ext.includes(v))) { + const cleanExt = ext.replace('.', '').toLowerCase(); + if (VIDEO_EXTENSIONS.some(v => v.toLowerCase() === cleanExt)) { type = 'video'; - } else if (PHOTO_EXTENSIONS.some(p => ext.includes(p))) { + } else if (PHOTO_EXTENSIONS.some(p => p.toLowerCase() === cleanExt)) { type = 'photo'; } diff --git a/src/lib/scanner.ts b/src/lib/scanner.ts index b16fccf..53a2c1e 100644 --- a/src/lib/scanner.ts +++ b/src/lib/scanner.ts @@ -34,15 +34,19 @@ const generatePhotoThumbnail = (photoPath: string, thumbnailPath: string) => { }; const scanLibrary = async (library: { id: number; path: string }) => { - // Scan videos - const videoFiles = await glob(`${library.path}/**/*.{${VIDEO_EXTENSIONS.join(",")}}`, { - nodir: true, - }); + // 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 photos - const photoFiles = await glob(`${library.path}/**/*.{${PHOTO_EXTENSIONS.join(",")}}`, { - nodir: true, - }); + // 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]; @@ -50,8 +54,9 @@ const scanLibrary = async (library: { id: number; path: string }) => { const stats = fs.statSync(file); const title = path.basename(file); const ext = path.extname(file).toLowerCase(); - const isVideo = VIDEO_EXTENSIONS.some(v => ext.includes(v)); - const isPhoto = PHOTO_EXTENSIONS.some(p => ext.includes(p)); + const cleanExt = ext.replace('.', '').toLowerCase(); + const isVideo = VIDEO_EXTENSIONS.some(v => v.toLowerCase() === cleanExt); + const isPhoto = PHOTO_EXTENSIONS.some(p => p.toLowerCase() === cleanExt); const mediaType = isVideo ? "video" : "photo"; const thumbnailFileName = `${path.parse(title).name}_${Date.now()}.png`;