Cancel superseded Enigma2 startup and select programs throughout playback
This commit is contained in:
19
server/services/mpegTsProgram.js
Normal file
19
server/services/mpegTsProgram.js
Normal 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 };
|
||||
@ -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)
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user