mirror of
https://github.com/4gray/iptvnator.git
synced 2026-10-13 20:56:19 -08:00
feat(settings): add external player arguments (#932)
* feat(settings): add external player arguments * fix(settings): address external player argument review * fix(settings): require external player argument settings * feat(settings): add external player argument placeholders Closes https://github.com/4gray/iptvnator/issues/835
This commit is contained in:
1 parent
2f9aef1578
commit
a40d5447e7
35 files changed
+584
-70
No files matched your search
@@ -6,6 +6,7 @@ export * from './lib/epg-channel-with-programs.interface';
|
||||
export * from './lib/epg-channel.model';
|
||||
export * from './lib/epg-item.interface';
|
||||
export * from './lib/epg-program.model';
|
||||
export * from './lib/external-player-arguments.utils';
|
||||
export * from './lib/external-player-session.interface';
|
||||
export * from './lib/indexed-db.config';
|
||||
export * from './lib/ipc-command.class';
|
||||
|
||||
@@ -0,0 +1,33 @@
|
||||
import {
|
||||
normalizeExternalPlayerArguments,
|
||||
parseExternalPlayerArguments,
|
||||
} from './external-player-arguments.utils';
|
||||
|
||||
describe('external player arguments utils', () => {
|
||||
it('parses one argument per non-empty trimmed line', () => {
|
||||
expect(
|
||||
parseExternalPlayerArguments(
|
||||
' --screen=1\n\n--geometry=1280x720\r\n --hwdec=auto-safe '
|
||||
)
|
||||
).toEqual(['--screen=1', '--geometry=1280x720', '--hwdec=auto-safe']);
|
||||
});
|
||||
|
||||
it('normalizes arguments to newline-separated trimmed lines', () => {
|
||||
expect(
|
||||
normalizeExternalPlayerArguments([
|
||||
' --screen=1 ',
|
||||
'',
|
||||
' --geometry=1280x720 ',
|
||||
])
|
||||
).toBe('--screen=1\n--geometry=1280x720');
|
||||
});
|
||||
|
||||
it('treats missing or unsupported values as empty arguments', () => {
|
||||
expect(parseExternalPlayerArguments(undefined)).toEqual([]);
|
||||
expect(parseExternalPlayerArguments(null)).toEqual([]);
|
||||
expect(parseExternalPlayerArguments(123 as unknown as string)).toEqual(
|
||||
[]
|
||||
);
|
||||
expect(normalizeExternalPlayerArguments(' \n ')).toBe('');
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,28 @@
|
||||
export type ExternalPlayerArgumentsInput =
|
||||
| string
|
||||
| readonly unknown[]
|
||||
| null
|
||||
| undefined;
|
||||
|
||||
export function parseExternalPlayerArguments(
|
||||
value: ExternalPlayerArgumentsInput
|
||||
): string[] {
|
||||
if (Array.isArray(value)) {
|
||||
return value.map((argument) => String(argument).trim()).filter(Boolean);
|
||||
}
|
||||
|
||||
if (typeof value !== 'string') {
|
||||
return [];
|
||||
}
|
||||
|
||||
return value
|
||||
.split(/\r?\n/)
|
||||
.map((argument) => argument.trim())
|
||||
.filter(Boolean);
|
||||
}
|
||||
|
||||
export function normalizeExternalPlayerArguments(
|
||||
value: ExternalPlayerArgumentsInput
|
||||
): string {
|
||||
return parseExternalPlayerArguments(value).join('\n');
|
||||
}
|
||||
@@ -37,8 +37,18 @@ export interface Settings {
|
||||
showExternalPlaybackBar?: boolean;
|
||||
theme: Theme;
|
||||
mpvPlayerPath: string;
|
||||
/**
|
||||
* Extra MPV CLI arguments entered one argument per line. Applied only when
|
||||
* starting a new external MPV process.
|
||||
*/
|
||||
mpvPlayerArguments: string;
|
||||
mpvReuseInstance: boolean;
|
||||
vlcPlayerPath: string;
|
||||
/**
|
||||
* Extra VLC CLI arguments entered one argument per line. Applied only when
|
||||
* starting a new external VLC process.
|
||||
*/
|
||||
vlcPlayerArguments: string;
|
||||
vlcReuseInstance: boolean;
|
||||
remoteControl: boolean;
|
||||
remoteControlPort: number;
|
||||
|
||||
Reference in new issue
Block a user