Files
yt-dlp-webui/frontend/src/features/core/argsParser.ts
2023-01-12 12:05:53 +01:00

61 lines
1.3 KiB
TypeScript

export class CliArguments {
private _extractAudio: boolean;
private _noMTime: boolean;
private _proxy: string;
constructor(extractAudio = false, noMTime = false) {
this._extractAudio = extractAudio;
this._noMTime = noMTime;
this._proxy = ""
}
public get extractAudio(): boolean {
return this._extractAudio;
}
public toggleExtractAudio() {
this._extractAudio = !this._extractAudio;
return this;
}
public disableExtractAudio() {
this._extractAudio = false;
return this;
}
public get noMTime(): boolean {
return this._noMTime;
}
public toggleNoMTime() {
this._noMTime = !this._noMTime;
return this;
}
public toString(): string {
let args = '';
if (this._extractAudio) {
args += '-x '
}
if (this._noMTime) {
args += '--no-mtime '
}
return args.trim();
}
public fromString(str: string): CliArguments {
if (str) {
if (str.includes('-x')) {
this._extractAudio = true;
}
if (str.includes('--no-mtime')) {
this._noMTime = true;
}
}
return this;
}
}