reflect preset options in tasks page.

This commit is contained in:
arabcoders 2025-09-03 19:25:08 +03:00
parent 063f62bebb
commit aab690a822
5 changed files with 89 additions and 98 deletions

4
FAQ.md
View file

@ -4,7 +4,8 @@ Certain configuration values can be set via environment variables, using the `-e
or the `environment:` section in `compose.yaml` file. or the `environment:` section in `compose.yaml` file.
| Environment Variable | Description | Default | | Environment Variable | Description | Default |
| ------------------------------ | ------------------------------------------------------------------ | ---------------------------------- | | ------------------------------ | ------------------------------------------------------------------ | -------------------------- |
| TZ | The timezone to use for the application | `(not_set)` |
| YTP_OUTPUT_TEMPLATE | The template for the filenames of the downloaded videos | `%(title)s.%(ext)s` | | YTP_OUTPUT_TEMPLATE | The template for the filenames of the downloaded videos | `%(title)s.%(ext)s` |
| YTP_DEFAULT_PRESET | The default preset to use for the download | `default` | | YTP_DEFAULT_PRESET | The default preset to use for the download | `default` |
| YTP_INSTANCE_TITLE | The title of the instance | `empty string` | | YTP_INSTANCE_TITLE | The title of the instance | `empty string` |
@ -45,7 +46,6 @@ or the `environment:` section in `compose.yaml` file.
| YTP_TEMP_DISABLED | Disable temp files handling. | `false` | | YTP_TEMP_DISABLED | Disable temp files handling. | `false` |
| YTP_DOWNLOAD_PATH_DEPTH | How many subdirectories to show in auto complete. | `1` | | YTP_DOWNLOAD_PATH_DEPTH | How many subdirectories to show in auto complete. | `1` |
# Browser extensions & bookmarklets # Browser extensions & bookmarklets
## Simple bookmarklet ## Simple bookmarklet

View file

@ -484,26 +484,6 @@ const filter_presets = (flag: boolean = true) => config.presets.filter(item => i
const get_preset = (name: string | undefined) => config.presets.find(item => item.name === name) const get_preset = (name: string | undefined) => config.presets.find(item => item.name === name)
const expand_description = (e: Event) => toggleClass(e.target as HTMLElement, ['is-ellipsis', 'is-pre-wrap']) const expand_description = (e: Event) => toggleClass(e.target as HTMLElement, ['is-ellipsis', 'is-pre-wrap'])
const get_output_template = () => {
if (form.value.preset && !hasFormatInConfig.value) {
const preset = config.presets.find(p => p.name === form.value.preset)
if (preset && preset.template) {
return preset.template
}
}
return config.app.output_template || '%(title)s.%(ext)s'
}
const get_download_folder = (): string => {
if (form.value.preset && false === hasFormatInConfig.value) {
const preset = config.presets.find(p => p.name === form.value.preset)
if (preset?.folder) {
return preset.folder.replace(config.app.download_path, '')
}
}
return '/'
}
const getDefault = (type: 'cookies' | 'cli' | 'template' | 'folder', ret: string = '') => { const getDefault = (type: 'cookies' | 'cli' | 'template' | 'folder', ret: string = '') => {
if (false !== hasFormatInConfig.value || !form.value.preset) { if (false !== hasFormatInConfig.value || !form.value.preset) {
return ret return ret

View file

@ -160,13 +160,13 @@
Save in Save in
</label> </label>
<div class="control"> <div class="control">
<input type="text" class="input" id="folder" placeholder="Leave empty to use default download path" <input type="text" class="input" id="folder" :placeholder="getDefault('folder', '/')"
v-model="form.folder" :disabled="addInProgress" list="folders"> v-model="form.folder" :disabled="addInProgress" list="folders">
</div> </div>
<span class="help"> <span class="help">
<span class="icon"><i class="fa-solid fa-info" /></span> <span class="icon"><i class="fa-solid fa-info" /></span>
<span class="is-bold">Current download folder: <code>{{ get_download_folder() }}</code>. All folders <span class="is-bold">All folders are sub-folders of
are sub-folders of <code>{{ config.app.download_path }}</code>.</span> <code>{{ config.app.download_path }}</code>.</span>
</span> </span>
</div> </div>
</div> </div>
@ -179,11 +179,12 @@
</label> </label>
<div class="control"> <div class="control">
<input type="text" class="input" id="output_template" :disabled="addInProgress" <input type="text" class="input" id="output_template" :disabled="addInProgress"
placeholder="Leave empty to use default template." v-model="form.template"> :placeholder="getDefault('template', config.app.output_template || '%(title)s.%(ext)s')"
v-model="form.template">
</div> </div>
<span class="help"> <span class="help">
<span class="icon"><i class="fa-solid fa-info" /></span> <span class="icon"><i class="fa-solid fa-info" /></span>
<span class="is-bold">Current output format: <code>{{ get_output_template() }}</code>.</span> <span class="is-bold">The template to use for the output file name.</span>
</span> </span>
</div> </div>
</div> </div>
@ -237,7 +238,7 @@
<span>Command options for yt-dlp</span> <span>Command options for yt-dlp</span>
</label> </label>
<TextareaAutocomplete id="cli_options" v-model="form.cli" :options="ytDlpOpt" <TextareaAutocomplete id="cli_options" v-model="form.cli" :options="ytDlpOpt"
:disabled="addInProgress" /> :placeholder="getDefault('cli', '')" :disabled="addInProgress" />
<span class="help is-bold"> <span class="help is-bold">
<span class="icon"><i class="fa-solid fa-info" /></span> <span class="icon"><i class="fa-solid fa-info" /></span>
<span> <span>
@ -282,10 +283,8 @@
<li>RSS monitoring runs every hour alongside the actual task execution. Regardless if the task has timer set <li>RSS monitoring runs every hour alongside the actual task execution. Regardless if the task has timer set
or not. To opt out of RSS monitoring for a specific task, simply disable the <code>Enable Handler</code> or not. To opt out of RSS monitoring for a specific task, simply disable the <code>Enable Handler</code>
option. To have the task only monitor RSS feed, <b>do not set timer</b>.</li> option. To have the task only monitor RSS feed, <b>do not set timer</b>.</li>
<li>RSS Feed monitoring will only work if you have <code>--download-archive</code> set in command options <li>RSS Feed monitoring will only work if you have <code>--download-archive</code> set in <code>Command options
for ytdlp.cli, preset or task. If you don't have <code>--download-archive</code> set but for yt-dlp</code> via the task itself, or preset. command options
<code>YTP_KEEP_ARCHIVE</code> environment option is set to <code>true</code> which is the default, It will
also work.
</li> </li>
</ul> </ul>
</span> </span>
@ -463,26 +462,6 @@ const hasFormatInConfig = computed<boolean>(() => !!form.cli && /(?<!\S)(-f|--fo
const filter_presets = (flag = true) => config.presets.filter(item => item.default === flag) const filter_presets = (flag = true) => config.presets.filter(item => item.default === flag)
const get_download_folder = (): string => {
if (form.preset && false === hasFormatInConfig.value) {
const preset = config.presets.find(p => p.name === form.preset)
if (preset?.folder) {
return preset.folder.replace(config.app.download_path, '')
}
}
return '/'
}
const get_output_template = (): string => {
if (form.preset && false === hasFormatInConfig.value) {
const preset = config.presets.find(p => p.name === form.preset)
if (preset?.template) {
return preset.template
}
}
return config.app.output_template || '%(title)s.%(ext)s'
}
const is_yt_handle = (url: string): boolean => { const is_yt_handle = (url: string): boolean => {
if (!url || '' === url) { if (!url || '' === url) {
return false return false
@ -513,7 +492,6 @@ const convert_url = async (url: string): Promise<string> => {
const resp = await request('/api/yt-dlp/url/info?' + params.toString()) const resp = await request('/api/yt-dlp/url/info?' + params.toString())
const body = await resp.json() const body = await resp.json()
const channel_id = ag(body, 'channel_id', null) const channel_id = ag(body, 'channel_id', null)
console.log('convert_url', { url, channel_id, body })
if (channel_id) { if (channel_id) {
return url.replace(`/@${m.groups.handle}`, `/channel/${channel_id}`) return url.replace(`/@${m.groups.handle}`, `/channel/${channel_id}`)
@ -528,4 +506,34 @@ const convert_url = async (url: string): Promise<string> => {
return url return url
} }
const getDefault = (type: 'cookies' | 'cli' | 'template' | 'folder', ret: string = '') => {
if (false !== hasFormatInConfig.value || !form.preset) {
return ret
}
const preset = config.presets.find(p => p.name === form.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
}
</script> </script>

View file

@ -67,7 +67,8 @@
<DeprecatedNotice :version="config.app.app_version" title="Deprecation Notice" tone="warning" <DeprecatedNotice :version="config.app.app_version" title="Deprecation Notice" tone="warning"
icon="fas fa-exclamation-triangle fa-fade fa-spin-10"> icon="fas fa-exclamation-triangle fa-fade fa-spin-10">
<p> <p>
The following environment variables and features are deprecated and will be removed in future releases: The following environment variables and features are deprecated and will be removed in
<strong class="has-text-danger">v0.10.x</strong>
</p> </p>
<ul> <ul>
<li> <li>

View file

@ -55,7 +55,8 @@
</div> </div>
<div class="is-hidden-mobile"> <div class="is-hidden-mobile">
<span class="subtitle"> <span class="subtitle">
The task runner is simple queue system that allows you to schedule downloads to run at the specific time. The task runner is simple queue system that allows you to poll channels or playlists for new content at
specified intervals.
</span> </span>
</div> </div>
</div> </div>
@ -361,9 +362,10 @@
<Message title="Tips" class="is-info is-background-info-80" icon="fas fa-info-circle"> <Message title="Tips" class="is-info is-background-info-80" icon="fas fa-info-circle">
<span> <span>
<ul> <ul>
<li>If you are adding a big channel or playlist and you want to skip all old videos, please click on <li>
<code>Actions > Archive All</code> button to mark all videos as downloaded. otherwise, it will try to If you don't wish to download <strong>ALL</strong> content from a channel or playlist, click on
download all videos. <code> <span class="icon"><i class="fa-solid fa-cogs" /></span> Actions > <span class="icon"><i
class="fa-solid fa-box-archive" /></span> Archive All</code> to archive all existing content.
</li> </li>
</ul> </ul>
</span> </span>