From 51be07f07649c2c31223068c1696ea05aea709d4 Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 31 Mar 2026 19:48:28 -0400 Subject: [PATCH] Improve high-res file matching: use substring search instead of exact title match MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When searching for high-res files by Title metadata, now looks for files that CONTAIN the Title rather than requiring exact match. This handles cases like: - Title: 'File 1' → matches 'ZacIsCool--File 1.mp4' - Title: 'File 2' → matches 'ZacIsCool--File 2.mp4' Makes the fallback lookup more flexible and practical for real-world filename patterns. --- prproj-remapper.js | 27 +++++++++++++++++---------- 1 file changed, 17 insertions(+), 10 deletions(-) diff --git a/prproj-remapper.js b/prproj-remapper.js index 038c267..c7a15e0 100644 --- a/prproj-remapper.js +++ b/prproj-remapper.js @@ -250,20 +250,27 @@ function findHighResFileForGves(gvesPath, hiresTitle, hiresMediaFolder, fs) { // Normalize the folder path const searchFolder = hiresMediaFolder.replace(/\\/g, '/').replace(/\/$/, ''); - // If Title is provided, search for it + // If Title is provided, search for files containing that title if (hiresTitle) { - const videoExts = ['.mp4', '.mov', '.mxf', '.mov', '.wav', '.aif', '.aiff']; + try { + const files = fs.readdirSync(searchFolder); + const videoExts = new Set(['.mp4', '.mov', '.mxf', '.wav', '.aif', '.aiff']); + const titleLower = hiresTitle.toLowerCase(); - for (const ext of videoExts) { - const candidate = `${searchFolder}/${hiresTitle}${ext}`; - try { - if (fs.existsSync(candidate)) { - // Convert back to UNC format if it was a local path - return candidate.replace(/\//g, '\\'); + // Look for files that contain the title as a substring + for (const file of files) { + const ext = '.' + file.split('.').pop().toLowerCase(); + if (!videoExts.has(ext)) continue; + + const fileLower = file.toLowerCase(); + // Match if filename contains the title + if (fileLower.includes(titleLower)) { + const fullPath = `${searchFolder}/${file}`; + return fullPath.replace(/\//g, '\\'); } - } catch (e) { - // Ignore individual file check failures } + } catch (e) { + // Ignore folder read failures, fall through to secondary search } }