Cancel superseded Enigma2 startup and select programs throughout playback

This commit is contained in:
Technomancer702
2026-10-13 17:56:26 -07:00
parent f2effe0832
commit 53b65b6a0d
15 changed files with 309 additions and 51 deletions

View File

@ -0,0 +1,19 @@
/** Optional MPEG-TS service/program identifier; reject structured or malformed input. */
function parseProgram(value) {
if (value === undefined || value === null) return null;
if (!['string', 'number'].includes(typeof value) || !/^\d{1,5}$/.test(String(value))) {
throw new Error('Program must be an integer from 1 to 65535');
}
const program = Number(value);
if (program < 1 || program > 65535) throw new Error('Program must be an integer from 1 to 65535');
return String(program);
}
function selectProgramStreams(result, program) {
if (program === null) return result.streams || [];
const selected = result.programs?.find(item => String(item.program_id ?? item.program_num) === program);
if (!selected) throw new Error('Requested program was not found in the stream');
return selected.streams || [];
}
module.exports = { parseProgram, selectProgramStreams };

View File

@ -1,3 +1,4 @@
const { parseProgram } = require('./mpegTsProgram');
const { redactUrl, redactText, validateHttpUrl, FFMPEG_PROTOCOL_WHITELIST } = require('./urlSecurity');
/**
* Transcode Session Service
@ -103,7 +104,8 @@ class TranscodeSession extends EventEmitter {
upscaleEnabled: options.upscaleEnabled || false,
upscaleMethod: options.upscaleMethod || 'hardware', // 'hardware' or 'software'
upscaleTarget: options.upscaleTarget || '1080p',
...options
...options,
program: parseProgram(options.program)
};
}