diff --git a/ui/components/PresetForm.vue b/ui/components/PresetForm.vue index b155187c..558dff89 100644 --- a/ui/components/PresetForm.vue +++ b/ui/components/PresetForm.vue @@ -208,21 +208,21 @@ const props = defineProps({ }, }) -const toast = useToast(); -const convertInProgress = ref(false); -const form = reactive(props.preset); -const opts = ref(''); -const json_preset = ref(''); -const importExpanded = ref(false); -const convertExpanded = ref(false); +const toast = useToast() +const convertInProgress = ref(false) +const form = reactive( JSON.parse(JSON.stringify(props.preset))) +const opts = ref('') +const json_preset = ref('') +const importExpanded = ref(false) +const convertExpanded = ref(false) onMounted(() => { if (props.preset?.args && (typeof props.preset.args === 'object')) { - form.args = JSON.stringify(props.preset.args, null, 2); + form.args = JSON.stringify(props.preset.args, null, 2) } if (props.preset?.postprocessors && (typeof props.preset.postprocessors === 'object')) { - form.postprocessors = JSON.stringify(props.preset.postprocessors, null, 2); + form.postprocessors = JSON.stringify(props.preset.postprocessors, null, 2) } }) @@ -231,7 +231,7 @@ const checkInfo = async () => { for (const key of required) { if (!form[key]) { toast.error(`The ${key} field is required.`); - return; + return } } diff --git a/ui/components/TaskForm.vue b/ui/components/TaskForm.vue index 338dbe53..e9b7393d 100644 --- a/ui/components/TaskForm.vue +++ b/ui/components/TaskForm.vue @@ -1,186 +1,188 @@ diff --git a/ui/pages/tasks.vue b/ui/pages/tasks.vue index 9fa32c7e..535e1a5f 100644 --- a/ui/pages/tasks.vue +++ b/ui/pages/tasks.vue @@ -79,11 +79,11 @@ div.is-centered {

- {{ calcPath(item.folder) }} + {{ item.folder ? calcPath(item.folder) : config.app.download_path }}

- {{ item.template ?? config.app.output_template }} + {{ item.template ? item.template : config.app.output_template }}

@@ -99,7 +99,7 @@ div.is-centered {

+ @@ -146,6 +152,7 @@ watch(() => config.app.basic_mode, async () => { watch(() => socket.isConnected, async () => { if (socket.isConnected && initialLoad.value) { + socket.on('status', statusHandler) await reloadContent(true) initialLoad.value = false } @@ -278,7 +285,13 @@ const calcPath = path => { return loc } -onMounted(async () => socket.isConnected ? await reloadContent(true) : '') +onMounted(async () => { + if (!socket.isConnected){ + return; + } + socket.on('status', statusHandler) + await reloadContent(true) +}); const tryParse = expression => { try { @@ -287,4 +300,53 @@ const tryParse = expression => { return "Invalid" } } + +const runNow = item => { + if (true !== confirm(`Run '${item.name}' now? it will also run at the scheduled time.`)) { + return + } + + let data = { + url: item.url, + preset: item.preset, + } + + if (item.folder) { + data.folder = item.folder + } + + if (item.template) { + data.template = item.template + } + + if (item.cookies) { + data.cookies = item.cookies + } + + if (item.config) { + if (typeof item.config === 'object') { + data.config = JSON.stringify(item.config) + } + + try { + JSON.parse(data.config) + } catch (e) { + toast.error(`Invalid JSON yt-dlp config. ${e.message}`) + return + } + } + + socket.emit('add_url', data) +} + +onUnmounted(() => socket.off('status', statusHandler)) + +const statusHandler = async stream => { + const { status, msg } = JSON.parse(stream) + + if ('error' === status) { + toast.error(msg) + return + } +}