remove json config use in add new download. rely on cli options.
This commit is contained in:
parent
1bda1893e4
commit
ac119db644
2 changed files with 41 additions and 56 deletions
|
|
@ -22,7 +22,7 @@
|
||||||
<div class="select is-fullwidth">
|
<div class="select is-fullwidth">
|
||||||
<select id="preset" class="is-fullwidth"
|
<select id="preset" class="is-fullwidth"
|
||||||
:disabled="!socket.isConnected || addInProgress || hasFormatInConfig" v-model="selectedPreset"
|
:disabled="!socket.isConnected || addInProgress || hasFormatInConfig" v-model="selectedPreset"
|
||||||
v-tooltip.bottom="hasFormatInConfig ? 'Presets are disabled. Format key is present in the config.' : ''">
|
v-tooltip.bottom="hasFormatInConfig ? 'Presets are disabled. Format key is present in the Command arguments for yt-dlp.' : ''">
|
||||||
<option v-for="item in config.presets" :key="item.name" :value="item.name">
|
<option v-for="item in config.presets" :key="item.name" :value="item.name">
|
||||||
{{ item.name }}
|
{{ item.name }}
|
||||||
</option>
|
</option>
|
||||||
|
|
@ -59,16 +59,18 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="columns is-multiline is-mobile" v-if="showAdvanced && !config.app.basic_mode">
|
<div class="columns is-multiline is-mobile" v-if="showAdvanced && !config.app.basic_mode">
|
||||||
<div class="column is-12">
|
|
||||||
|
<div class="column is-6-tablet is-12-mobile">
|
||||||
<div class="field">
|
<div class="field">
|
||||||
<label class="label is-inline" for="output_format"
|
<label class="label is-inline" for="output_format"
|
||||||
v-tooltip="'Default Format: ' + config.app.output_template">
|
v-tooltip="'Default Format: ' + config.app.output_template">
|
||||||
Output Template
|
Output Template
|
||||||
</label>
|
</label>
|
||||||
<div class="control">
|
<div class="control has-icons-left">
|
||||||
<input type="text" class="input" v-model="output_template" id="output_format"
|
<input type="text" class="input" v-model="output_template" id="output_format"
|
||||||
:disabled="!socket.isConnected || addInProgress"
|
:disabled="!socket.isConnected || addInProgress"
|
||||||
placeholder="Uses default output template naming if empty.">
|
placeholder="Uses default output template naming if empty.">
|
||||||
|
<span class="icon is-small is-left"><i class="fa-solid fa-file" /></span>
|
||||||
</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>
|
||||||
|
|
@ -77,32 +79,31 @@
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div class="column is-6-tablet is-12-mobile">
|
<div class="column is-6-tablet is-12-mobile">
|
||||||
<div class="field">
|
<div class="field">
|
||||||
<label class="label is-inline" for="ytdlpConfig"
|
<label class="label is-inline" for="cli_options">
|
||||||
v-tooltip="'Extends current global yt-dlp config. (JSON)'">
|
Command arguments for yt-dlp
|
||||||
JSON yt-dlp config or CLI options.
|
|
||||||
<NuxtLink v-if="ytdlpConfig && ytdlpConfig.trim() && !ytdlpConfig.trim().startsWith('{')"
|
|
||||||
@click="convertOptions()">
|
|
||||||
Convert to JSON
|
|
||||||
</NuxtLink>
|
|
||||||
</label>
|
</label>
|
||||||
<div class="control">
|
<div class="control has-icons-left">
|
||||||
<textarea class="textarea" id="ytdlpConfig" v-model="ytdlpConfig"
|
<input type="text" class="input" v-model="ytdlp_cli" id="cli_options"
|
||||||
:disabled="!socket.isConnected || addInProgress || convertInProgress"
|
:disabled="!socket.isConnected || addInProgress"
|
||||||
placeholder="--no-embed-metadata --no-embed-thumbnail"></textarea>
|
placeholder="command options to use, e.g. --no-embed-metadata --no-embed-thumbnail">
|
||||||
|
<span class="icon is-small is-left"><i class="fa-solid fa-terminal" /></span>
|
||||||
</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>Extends current global yt-dlp config with given options. Some fields are ignored like
|
<span>yt-dlp cli arguments. Check <NuxtLink target="_blank"
|
||||||
<code>cookiefile</code>, <code>paths</code>, and <code>outtmpl</code> etc. Warning: Use with caution
|
to="https://github.com/yt-dlp/yt-dlp?tab=readme-ov-file#general-options">this page</NuxtLink>.
|
||||||
some of those options can break yt-dlp or the frontend. If <code>Format</code> key is present
|
For more info. <span class="has-text-danger">Not all options are supported some are ignored. Use
|
||||||
in the config, <span class="has-text-danger">the preset and all it's options will be
|
with caution those arguments can break yt-dlp or the frontend.</span>
|
||||||
ignored</span>.</span>
|
</span>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="column is-6-tablet is-12-mobile">
|
|
||||||
|
<div class="column is-12">
|
||||||
<div class="field">
|
<div class="field">
|
||||||
<label class="label is-inline" for="ytdlpCookies" v-tooltip="'Netscape HTTP Cookie format'">
|
<label class="label is-inline" for="ytdlpCookies" v-tooltip="'Netscape HTTP Cookie format'">
|
||||||
Cookies
|
Cookies
|
||||||
|
|
@ -152,7 +153,6 @@
|
||||||
|
|
||||||
<script setup>
|
<script setup>
|
||||||
import { useStorage } from '@vueuse/core'
|
import { useStorage } from '@vueuse/core'
|
||||||
import { request } from '~/utils/index'
|
|
||||||
|
|
||||||
const emitter = defineEmits(['getInfo'])
|
const emitter = defineEmits(['getInfo'])
|
||||||
const config = useConfigStore()
|
const config = useConfigStore()
|
||||||
|
|
@ -160,31 +160,25 @@ const socket = useSocketStore()
|
||||||
const toast = useToast()
|
const toast = useToast()
|
||||||
|
|
||||||
const selectedPreset = useStorage('selectedPreset', config.app.default_preset)
|
const selectedPreset = useStorage('selectedPreset', config.app.default_preset)
|
||||||
const ytdlpConfig = useStorage('ytdlp_config', '')
|
|
||||||
const ytdlpCookies = useStorage('ytdlp_cookies', '')
|
const ytdlpCookies = useStorage('ytdlp_cookies', '')
|
||||||
|
const ytdlp_cli = useStorage('ytdlp_cli', '')
|
||||||
const output_template = useStorage('output_template', null)
|
const output_template = useStorage('output_template', null)
|
||||||
const downloadPath = useStorage('downloadPath', null)
|
const downloadPath = useStorage('downloadPath', null)
|
||||||
const url = useStorage('downloadUrl', null)
|
const url = useStorage('downloadUrl', null)
|
||||||
const showAdvanced = useStorage('show_advanced', false)
|
const showAdvanced = useStorage('show_advanced', false)
|
||||||
const addInProgress = ref(false)
|
const addInProgress = ref(false)
|
||||||
const convertInProgress = ref(false)
|
|
||||||
|
|
||||||
const addDownload = async () => {
|
const addDownload = async () => {
|
||||||
// -- send request to convert cli options to JSON
|
// -- send request to convert cli options to JSON
|
||||||
if (ytdlpConfig.value && !ytdlpConfig.value.trim().startsWith('{')) {
|
if (ytdlp_cli.value && '' !== ytdlp_cli.value) {
|
||||||
await convertOptions()
|
const options = await convertOptions(ytdlp_cli.value)
|
||||||
}
|
if (null === options) {
|
||||||
|
|
||||||
if (ytdlpConfig.value) {
|
|
||||||
try {
|
|
||||||
JSON.parse(ytdlpConfig.value)
|
|
||||||
} catch (e) {
|
|
||||||
toast.error(`Invalid JSON yt-dlp config. ${e.message}`)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
addInProgress.value = true
|
addInProgress.value = true
|
||||||
|
|
||||||
url.value.split(',').forEach(url => {
|
url.value.split(',').forEach(url => {
|
||||||
if (!url.trim()) {
|
if (!url.trim()) {
|
||||||
return
|
return
|
||||||
|
|
@ -193,9 +187,9 @@ const addDownload = async () => {
|
||||||
url: url,
|
url: url,
|
||||||
preset: config.app.basic_mode ? config.app.default_preset : selectedPreset.value,
|
preset: config.app.basic_mode ? config.app.default_preset : selectedPreset.value,
|
||||||
folder: config.app.basic_mode ? null : downloadPath.value,
|
folder: config.app.basic_mode ? null : downloadPath.value,
|
||||||
config: config.app.basic_mode ? '' : ytdlpConfig.value,
|
|
||||||
cookies: config.app.basic_mode ? '' : ytdlpCookies.value,
|
cookies: config.app.basic_mode ? '' : ytdlpCookies.value,
|
||||||
template: config.app.basic_mode ? null : output_template.value,
|
template: config.app.basic_mode ? null : output_template.value,
|
||||||
|
cli: config.app.basic_mode ? null : ytdlp_cli.value,
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
@ -206,7 +200,6 @@ const resetConfig = () => {
|
||||||
}
|
}
|
||||||
|
|
||||||
selectedPreset.value = config.app.default_preset.value
|
selectedPreset.value = config.app.default_preset.value
|
||||||
ytdlpConfig.value = ''
|
|
||||||
ytdlpCookies.value = ''
|
ytdlpCookies.value = ''
|
||||||
output_template.value = null
|
output_template.value = null
|
||||||
url.value = null
|
url.value = null
|
||||||
|
|
@ -239,27 +232,24 @@ const unlockDownload = async stream => {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const convertOptions = async () => {
|
const convertOptions = async args => {
|
||||||
if (convertInProgress.value) {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
convertInProgress.value = true
|
const response = await convertCliOptions(args)
|
||||||
const response = await convertCliOptions(ytdlpConfig.value)
|
|
||||||
ytdlpConfig.value = JSON.stringify(response.opts, null, 2)
|
|
||||||
if (response.output_template) {
|
if (response.output_template) {
|
||||||
output_template.value = response.output_template
|
output_template.value = response.output_template
|
||||||
}
|
}
|
||||||
|
|
||||||
if (response.download_path) {
|
if (response.download_path) {
|
||||||
downloadPath.value = response.download_path
|
downloadPath.value = response.download_path
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return response.opts
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
toast.error(e.message)
|
toast.error(e.message)
|
||||||
} finally {
|
|
||||||
convertInProgress.value = false
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
onMounted(() => {
|
onMounted(() => {
|
||||||
|
|
@ -276,14 +266,11 @@ onUnmounted(() => {
|
||||||
})
|
})
|
||||||
|
|
||||||
const hasFormatInConfig = computed(() => {
|
const hasFormatInConfig = computed(() => {
|
||||||
if (!ytdlpConfig.value) {
|
if (!ytdlp_cli.value) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
try {
|
if (ytdlp_cli.value.includes('-f') || ytdlp_cli.value.includes('--format')) {
|
||||||
const config = JSON.parse(ytdlpConfig.value)
|
return true
|
||||||
return "format" in config
|
|
||||||
} catch (e) {
|
|
||||||
return false
|
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
|
||||||
|
|
@ -84,7 +84,8 @@
|
||||||
<div class="control has-icons-left">
|
<div class="control has-icons-left">
|
||||||
<div class="select is-fullwidth">
|
<div class="select is-fullwidth">
|
||||||
<select id="preset" class="is-fullwidth" v-model="form.preset"
|
<select id="preset" class="is-fullwidth" v-model="form.preset"
|
||||||
:disabled="addInProgress || hasFormatInConfig">
|
:disabled="addInProgress || hasFormatInConfig"
|
||||||
|
v-tooltip.bottom="hasFormatInConfig ? 'Presets are disabled. Format key is present in the command arguments for yt-dlp.' : ''">
|
||||||
<option v-for="item in config.presets" :key="item.name" :value="item.name">
|
<option v-for="item in config.presets" :key="item.name" :value="item.name">
|
||||||
{{ item.name }}
|
{{ item.name }}
|
||||||
</option>
|
</option>
|
||||||
|
|
@ -176,15 +177,12 @@
|
||||||
<span class="icon"><i class="fa-solid fa-info" /></span>
|
<span class="icon"><i class="fa-solid fa-info" /></span>
|
||||||
<span>yt-dlp cli arguments. Check <NuxtLink target="_blank"
|
<span>yt-dlp cli arguments. Check <NuxtLink target="_blank"
|
||||||
to="https://github.com/yt-dlp/yt-dlp?tab=readme-ov-file#general-options">this page</NuxtLink>.
|
to="https://github.com/yt-dlp/yt-dlp?tab=readme-ov-file#general-options">this page</NuxtLink>.
|
||||||
For more info. Some arguments are ignored by default. Warning: Use with
|
For more info. <span class="has-text-danger">Not all options are supported some are ignored. Use
|
||||||
caution some of those options can break yt-dlp or the frontend. <span class="has-text-danger">If
|
with caution those arguments can break yt-dlp or the frontend.</span>
|
||||||
<code>-f, --format</code> argument is present, the preset and all it's options will be
|
|
||||||
ignored</span>.
|
|
||||||
</span>
|
</span>
|
||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue