Fix: implement case-insensitive file matching for broadcast audio sequences to fix missing uppercase line and station names

This commit is contained in:
2026-08-01 22:54:10 +08:00
parent 2fae7305f6
commit 4b3bd91023
7 changed files with 19 additions and 6 deletions
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
+19 -6
View File
@@ -1235,6 +1235,14 @@ function getOrCreateHlsStreamState(streamName) {
return hlsStreams[streamName]; return hlsStreams[streamName];
} }
function findFileCaseInsensitive(dir, filename) {
if (!fs.existsSync(dir)) return null;
const files = fs.readdirSync(dir);
const lowerFilename = filename.toLowerCase();
const match = files.find(f => f.toLowerCase() === lowerFilename);
return match ? path.join(dir, match) : null;
}
function resolveSequenceFiles(seq) { function resolveSequenceFiles(seq) {
ensureSilenceWav(); ensureSilenceWav();
const files = []; const files = [];
@@ -1245,14 +1253,19 @@ function resolveSequenceFiles(seq) {
continue; continue;
} }
const candidates = [ const dirsToSearch = [
path.join(audioStationDir, `${item}.wav`), audioStationDir,
path.join(audioLineDir, `${item}.wav`), audioLineDir,
path.join(audioVoiceDir, `${item}.wav`), audioVoiceDir,
...getBeepAudioDirs().map(dir => path.join(dir, `${item}.wav`)) ...getBeepAudioDirs()
]; ];
const found = candidates.find(p => fs.existsSync(p)); let found = null;
for (const dir of dirsToSearch) {
found = findFileCaseInsensitive(dir, `${item}.wav`);
if (found) break;
}
if (found) { if (found) {
files.push(found); files.push(found);
} else { } else {