Fix: implement case-insensitive file matching for broadcast audio sequences to fix missing uppercase line and station names
This commit is contained in:
+19
-6
@@ -1235,6 +1235,14 @@ function getOrCreateHlsStreamState(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) {
|
||||
ensureSilenceWav();
|
||||
const files = [];
|
||||
@@ -1245,14 +1253,19 @@ function resolveSequenceFiles(seq) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const candidates = [
|
||||
path.join(audioStationDir, `${item}.wav`),
|
||||
path.join(audioLineDir, `${item}.wav`),
|
||||
path.join(audioVoiceDir, `${item}.wav`),
|
||||
...getBeepAudioDirs().map(dir => path.join(dir, `${item}.wav`))
|
||||
const dirsToSearch = [
|
||||
audioStationDir,
|
||||
audioLineDir,
|
||||
audioVoiceDir,
|
||||
...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) {
|
||||
files.push(found);
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user