add deprecated notice.
This commit is contained in:
parent
deed79b8d2
commit
fd999211ef
5 changed files with 110 additions and 13 deletions
|
|
@ -388,6 +388,10 @@ def arg_converter(
|
||||||
|
|
||||||
default_opts = _default_opts([]).ydl_opts
|
default_opts = _default_opts([]).ydl_opts
|
||||||
|
|
||||||
|
if args:
|
||||||
|
# important to ignore external config files.
|
||||||
|
args = "--ignore-config " + args
|
||||||
|
|
||||||
opts = yt_dlp.parse_options(shlex.split(args)).ydl_opts
|
opts = yt_dlp.parse_options(shlex.split(args)).ydl_opts
|
||||||
diff = {k: v for k, v in opts.items() if default_opts[k] != v} if not keep_defaults else opts.items()
|
diff = {k: v for k, v in opts.items() if default_opts[k] != v} if not keep_defaults else opts.items()
|
||||||
if "postprocessors" in diff:
|
if "postprocessors" in diff:
|
||||||
|
|
|
||||||
|
|
@ -384,23 +384,16 @@ class Config:
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
LOG.error(f"Error starting debugpy server at '0.0.0.0:{self.debugpy_port}'. {e}")
|
LOG.error(f"Error starting debugpy server at '0.0.0.0:{self.debugpy_port}'. {e}")
|
||||||
|
|
||||||
ytdl_options = {}
|
|
||||||
opts_file: Path = Path(self.config_path) / "ytdlp.cli"
|
opts_file: Path = Path(self.config_path) / "ytdlp.cli"
|
||||||
if opts_file.exists() and opts_file.stat().st_size > 2:
|
if opts_file.exists() and opts_file.stat().st_size > 2:
|
||||||
LOG.info(f"Loading yt-dlp custom options from '{opts_file}'.")
|
LOG.error("The global config file 'ytdlp.cli' file is deprecated and will be removed in future releases.")
|
||||||
with open(opts_file) as f:
|
with open(opts_file) as f:
|
||||||
self.ytdlp_cli = f.read().strip()
|
self.ytdlp_cli = f.read().strip()
|
||||||
if self.ytdlp_cli:
|
if self.ytdlp_cli:
|
||||||
self._ytdlp_cli_mutable = self.ytdlp_cli
|
self._ytdlp_cli_mutable = self.ytdlp_cli
|
||||||
try:
|
try:
|
||||||
removed_options = []
|
removed_options: list = []
|
||||||
ytdl_options = arg_converter(args=self.ytdlp_cli, level=True, removed_options=removed_options)
|
arg_converter(args=self.ytdlp_cli, level=True, removed_options=removed_options)
|
||||||
|
|
||||||
try:
|
|
||||||
LOG.debug("Parsed yt-dlp cli options '%s'.", ytdl_options)
|
|
||||||
except Exception:
|
|
||||||
pass
|
|
||||||
|
|
||||||
if len(removed_options) > 0:
|
if len(removed_options) > 0:
|
||||||
LOG.warning(
|
LOG.warning(
|
||||||
"Removed the following options: '%s' from '%s'", ", ".join(removed_options), opts_file
|
"Removed the following options: '%s' from '%s'", ", ".join(removed_options), opts_file
|
||||||
|
|
@ -410,8 +403,6 @@ class Config:
|
||||||
raise ValueError(msg) from e
|
raise ValueError(msg) from e
|
||||||
else:
|
else:
|
||||||
LOG.warning(f"Empty yt-dlp custom options file '{opts_file}'.")
|
LOG.warning(f"Empty yt-dlp custom options file '{opts_file}'.")
|
||||||
else:
|
|
||||||
LOG.info(f"No yt-dlp custom options found at '{opts_file}'.")
|
|
||||||
|
|
||||||
self._ytdlp_cli_mutable += f"\n--socket-timeout {self.socket_timeout}"
|
self._ytdlp_cli_mutable += f"\n--socket-timeout {self.socket_timeout}"
|
||||||
|
|
||||||
|
|
|
||||||
67
ui/app/components/DeprecatedNotice.vue
Normal file
67
ui/app/components/DeprecatedNotice.vue
Normal file
|
|
@ -0,0 +1,67 @@
|
||||||
|
<template>
|
||||||
|
<div v-if="isLoaded && !isDismissed">
|
||||||
|
<Message :message_class="messageClass" :title="title" :icon="icon" :useClose="true" @close="dismiss">
|
||||||
|
<slot />
|
||||||
|
</Message>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
|
|
||||||
|
<script setup lang="ts">
|
||||||
|
import { computed, ref, watchEffect } from 'vue'
|
||||||
|
import { useStorage, type RemovableRef } from '@vueuse/core'
|
||||||
|
import Message from "~/components/Message.vue";
|
||||||
|
|
||||||
|
const props = withDefaults(defineProps<{
|
||||||
|
version: string
|
||||||
|
storageKey?: string
|
||||||
|
title?: string
|
||||||
|
icon?: string
|
||||||
|
tone?: 'warning' | 'danger' | 'info' | 'success'
|
||||||
|
}>(), {
|
||||||
|
storageKey: 'deprecated-notice',
|
||||||
|
title: 'Deprecated Feature',
|
||||||
|
icon: 'fas fa-exclamation-triangle',
|
||||||
|
tone: 'warning',
|
||||||
|
})
|
||||||
|
|
||||||
|
const config = useConfigStore()
|
||||||
|
const isDev = computed(() => 'development' === config.app?.app_env)
|
||||||
|
const isLoaded = computed(() => config.is_loaded)
|
||||||
|
|
||||||
|
const storageKeyComputed = computed<string>(() => `${props.storageKey}:${props.version}`)
|
||||||
|
|
||||||
|
const dismissedDev = ref<boolean>(false)
|
||||||
|
let dismissedProd: RemovableRef<boolean> | null = null
|
||||||
|
|
||||||
|
watchEffect(() => {
|
||||||
|
if (!isLoaded.value || isDev.value) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
dismissedProd = useStorage<boolean>(storageKeyComputed, false)
|
||||||
|
})
|
||||||
|
|
||||||
|
const isDismissed = computed(() => {
|
||||||
|
// include dependencies so recompute on env/load/version changes
|
||||||
|
void isLoaded.value; void isDev.value; void storageKeyComputed.value
|
||||||
|
return isDev.value ? dismissedDev.value : (dismissedProd?.value ?? false)
|
||||||
|
})
|
||||||
|
|
||||||
|
const dismiss = () => {
|
||||||
|
if (isDev.value) dismissedDev.value = true
|
||||||
|
else if (dismissedProd) dismissedProd.value = true
|
||||||
|
}
|
||||||
|
|
||||||
|
const messageClass = computed(() => {
|
||||||
|
switch (props.tone) {
|
||||||
|
case 'danger':
|
||||||
|
return 'is-danger has-background-danger-90 has-text-dark'
|
||||||
|
case 'info':
|
||||||
|
return 'is-info has-background-info-90 has-text-dark'
|
||||||
|
case 'success':
|
||||||
|
return 'is-success has-background-success-90 has-text-dark'
|
||||||
|
case 'warning':
|
||||||
|
default:
|
||||||
|
return 'is-warning has-background-warning-90 has-text-dark'
|
||||||
|
}
|
||||||
|
})
|
||||||
|
</script>
|
||||||
|
|
@ -63,6 +63,38 @@
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div v-if="config.is_loaded" class="columns is-multiline">
|
||||||
|
<div class="column is-12">
|
||||||
|
<DeprecatedNotice :version="config.app.app_version" title="Deprecation Notice" tone="warning"
|
||||||
|
icon="fas fa-exclamation-triangle fa-fade fa-spin-10">
|
||||||
|
<p>
|
||||||
|
The following environment variables and features are deprecated and will be removed in future releases:
|
||||||
|
</p>
|
||||||
|
<ul>
|
||||||
|
<li>
|
||||||
|
The environment variables <code>YTP_KEEP_ARCHIVE</code> and <code>YTP_SOCKET_TIMEOUT</code> will no
|
||||||
|
longer be user-configurable. Their behavior will be part of the <strong>default presets</strong>. To keep
|
||||||
|
your current behavior <strong>and avoid re-downloading</strong>, please add the following <strong>Command
|
||||||
|
options for yt-dlp</strong> to your presets:
|
||||||
|
<code>--socket-timeout 30 --download-archive /config/archive.log</code>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
The global yt-dlp config file <code>/config/ytdlp.cli</code> is deprecated and will be removed. Please
|
||||||
|
migrate any global options into your presets.
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
The <strong>Basic mode</strong> (which limited the interface to the new download form) is being removed.
|
||||||
|
Everything except what is available behind configurable flag will become part of the standard interface.
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
|
<p>
|
||||||
|
These changes help reduce confusion from multiple sources of truth. Going forward, <strong>presets</strong>
|
||||||
|
and the <strong>Command options for yt-dlp</strong> will be the single source of truth.
|
||||||
|
</p>
|
||||||
|
</DeprecatedNotice>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<NewDownload v-if="config.showForm || config.app.basic_mode"
|
<NewDownload v-if="config.showForm || config.app.basic_mode"
|
||||||
@getInfo="(url: string, preset: string = '') => view_info(url, false, preset)" :item="item_form"
|
@getInfo="(url: string, preset: string = '') => view_info(url, false, preset)" :item="item_form"
|
||||||
@clear_form="item_form = {}" @remove_archive="" />
|
@clear_form="item_form = {}" @remove_archive="" />
|
||||||
|
|
@ -81,6 +113,7 @@
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { useStorage } from '@vueuse/core'
|
import { useStorage } from '@vueuse/core'
|
||||||
|
import DeprecatedNotice from '~/components/DeprecatedNotice.vue'
|
||||||
import type { item_request } from '~/types/item'
|
import type { item_request } from '~/types/item'
|
||||||
import type { StoreItem } from '~/types/store'
|
import type { StoreItem } from '~/types/store'
|
||||||
|
|
||||||
|
|
|
||||||
4
ui/app/types/config.d.ts
vendored
4
ui/app/types/config.d.ts
vendored
|
|
@ -45,7 +45,9 @@ type AppConfig = {
|
||||||
/** App branch name, e.g. "main" or "develop" */
|
/** App branch name, e.g. "main" or "develop" */
|
||||||
app_branch: string
|
app_branch: string
|
||||||
/** When the app started */
|
/** When the app started */
|
||||||
started: number
|
started: number,
|
||||||
|
/** Application environment, e.g. "production", "development" */
|
||||||
|
app_env: string
|
||||||
}
|
}
|
||||||
|
|
||||||
type Preset = {
|
type Preset = {
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue