Reflect preset settings in new download form.
This commit is contained in:
parent
691f0d5bfc
commit
88451f8044
1 changed files with 35 additions and 4 deletions
|
|
@ -64,7 +64,7 @@
|
|||
</div>
|
||||
<div class="control is-expanded">
|
||||
<input type="text" class="input is-fullwidth" id="path" v-model="form.folder"
|
||||
:placeholder="get_download_folder()" :disabled="!socket.isConnected || addInProgress"
|
||||
:placeholder="getDefault('folder', '/')" :disabled="!socket.isConnected || addInProgress"
|
||||
list="folders">
|
||||
</div>
|
||||
</div>
|
||||
|
|
@ -105,7 +105,7 @@
|
|||
|
||||
<DLInput id="output_template" type="string" label="Output template" v-model="form.template"
|
||||
icon="fa-solid fa-file" :disabled="!socket.isConnected || addInProgress"
|
||||
:placeholder="get_output_template()">
|
||||
:placeholder="getDefault('template', config.app.output_template || '%(title)s.%(ext)s')">
|
||||
<template #help>
|
||||
<span class="help is-bold is-unselectable">
|
||||
<span class="icon"><i class="fa-solid fa-info" /></span>
|
||||
|
|
@ -123,7 +123,7 @@
|
|||
<span>Command options for yt-dlp</span>
|
||||
</label>
|
||||
<TextareaAutocomplete id="cli_options" v-model="form.cli" :options="ytDlpOpt"
|
||||
:disabled="!socket.isConnected || addInProgress" />
|
||||
:placeholder="getDefault('cli', '')" :disabled="!socket.isConnected || addInProgress" />
|
||||
<span class="help is-bold">
|
||||
<span class="icon"><i class="fa-solid fa-info" /></span>
|
||||
<span>
|
||||
|
|
@ -138,7 +138,8 @@
|
|||
|
||||
<div class="column is-6-tablet is-12-mobile">
|
||||
<DLInput id="ytdlpCookies" type="text" label="Cookies for yt-dlp" v-model="form.cookies"
|
||||
icon="fa-solid fa-cookie" :disabled="!socket.isConnected || addInProgress">
|
||||
icon="fa-solid fa-cookie" :disabled="!socket.isConnected || addInProgress"
|
||||
:placeholder="getDefault('cookies', '')">
|
||||
<template #help>
|
||||
<span class="help is-bold">
|
||||
<span class="icon"><i class="fa-solid fa-info" /></span>
|
||||
|
|
@ -503,5 +504,35 @@ const get_download_folder = (): string => {
|
|||
return '/'
|
||||
}
|
||||
|
||||
const getDefault = (type: 'cookies' | 'cli' | 'template' | 'folder', ret: string = '') => {
|
||||
if (false !== hasFormatInConfig.value || !form.value.preset) {
|
||||
return ret
|
||||
}
|
||||
|
||||
const preset = config.presets.find(p => p.name === form.value.preset)
|
||||
|
||||
if (!preset) {
|
||||
return ret
|
||||
}
|
||||
|
||||
if (type === 'cookies' && preset.cookies) {
|
||||
return preset.cookies
|
||||
}
|
||||
|
||||
if (type === 'cli' && preset.cli) {
|
||||
return preset.cli
|
||||
}
|
||||
|
||||
if (type === 'template' && preset.template) {
|
||||
return preset.template
|
||||
}
|
||||
|
||||
if (type === 'folder' && preset.folder) {
|
||||
return preset.folder.replace(config.app.download_path, '') || ret
|
||||
}
|
||||
|
||||
return ret
|
||||
}
|
||||
|
||||
const sortedDLFields = computed(() => config.dl_fields.sort((a, b) => (a.order || 0) - (b.order || 0)))
|
||||
</script>
|
||||
|
|
|
|||
Loading…
Reference in a new issue