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
|
// Normalize the folder path
|
||||||
const searchFolder = hiresMediaFolder.replace(/\\/g, '/').replace(/\/$/, '');
|
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) {
|
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) {
|
// Look for files that contain the title as a substring
|
||||||
const candidate = `${searchFolder}/${hiresTitle}${ext}`;
|
for (const file of files) {
|
||||||
try {
|
const ext = '.' + file.split('.').pop().toLowerCase();
|
||||||
if (fs.existsSync(candidate)) {
|
if (!videoExts.has(ext)) continue;
|
||||||
// Convert back to UNC format if it was a local path
|
|
||||||
return candidate.replace(/\//g, '\\');
|
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
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue