Improve high-res file matching: use substring search instead of exact title match
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.
This commit is contained in:
parent
205ef3f50a
commit
51be07f076
1 changed files with 17 additions and 10 deletions
|
|
@ -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'];
|
||||
|
||||
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, '\\');
|
||||
const files = fs.readdirSync(searchFolder);
|
||||
const videoExts = new Set(['.mp4', '.mov', '.mxf', '.wav', '.aif', '.aiff']);
|
||||
const titleLower = hiresTitle.toLowerCase();
|
||||
|
||||
// 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
|
||||
}
|
||||
// Ignore folder read failures, fall through to secondary search
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue