FEAT: Update default presets

This commit is contained in:
arabcoders 2025-09-03 23:49:19 +03:00
parent 881b7373eb
commit bdb6d0e36a
6 changed files with 42 additions and 29 deletions

View file

@ -19,33 +19,34 @@ DEFAULT_PRESETS: list[dict[int, dict[str, str | bool]]] = [
"id": "3e163c6c-64eb-4448-924f-814b629b3810", "id": "3e163c6c-64eb-4448-924f-814b629b3810",
"name": "default", "name": "default",
"default": True, "default": True,
"cli": "--socket-timeout 30 --download-archive %(config_path)s/archive.log",
"description": "Default preset for yt-dlp. It will download whatever yt-dlp decides is the best quality for the video and audio.", "description": "Default preset for yt-dlp. It will download whatever yt-dlp decides is the best quality for the video and audio.",
}, },
{ {
"id": "441675ed-b739-40f0-a0b0-1ecfcb9dc48d", "id": "441675ed-b739-40f0-a0b0-1ecfcb9dc48d",
"name": "Mobile", "name": "Mobile",
"cli": '-t mp4 --merge-output-format mp4 --add-chapters --remux-video mp4 \n--embed-metadata --embed-thumbnail \n--postprocessor-args "-movflags +faststart"', "cli": '--socket-timeout 30 --download-archive %(config_path)s/archive.log\n-t mp4 --merge-output-format mp4 --add-chapters --remux-video mp4 \n--embed-metadata --embed-thumbnail \n--postprocessor-args "-movflags +faststart"',
"default": True, "default": True,
"description": "This preset is designed for mobile devices. It will download the best quality video and audio in mp4 format, merge them, and add chapters, metadata, and thumbnail.", "description": "This preset is designed for mobile devices. It will download the best quality video and audio in mp4 format, merge them, and add chapters, metadata, and thumbnail.",
}, },
{ {
"id": "441675ed-b739-40f0-a0b0-1ecfcb9dc48b", "id": "441675ed-b739-40f0-a0b0-1ecfcb9dc48b",
"name": "1080p", "name": "1080p",
"cli": "-S vcodec:h264 --format 'bv[height<=1080][ext=mp4]+ba[ext=m4a]/b[ext=mp4]/b[ext=webm]'", "cli": "--socket-timeout 30 --download-archive %(config_path)s/archive.log\n-S vcodec:h264 --format 'bv[height<=1080][ext=mp4]+ba[ext=m4a]/b[ext=mp4]/b[ext=webm]'",
"default": True, "default": True,
"description": "Download the best quality video and audio in mp4 format for 1080p resolution.", "description": "Download the best quality video and audio in mp4 format for 1080p resolution.",
}, },
{ {
"id": "9719fcc3-4cf2-4d88-b1e4-74dff3dba00e", "id": "9719fcc3-4cf2-4d88-b1e4-74dff3dba00e",
"name": "720p", "name": "720p",
"cli": "-S vcodec:h264 --format 'bv[height<=720][ext=mp4]+ba[ext=m4a]/b[ext=mp4]/b[ext=webm]'", "cli": "--socket-timeout 30 --download-archive %(config_path)s/archive.log\n-S vcodec:h264 --format 'bv[height<=720][ext=mp4]+ba[ext=m4a]/b[ext=mp4]/b[ext=webm]'",
"default": True, "default": True,
"description": "Download the best quality video and audio in mp4 format for 720p resolution.", "description": "Download the best quality video and audio in mp4 format for 720p resolution.",
}, },
{ {
"id": "a6fd4b25-2b3e-458d-bb57-b75e41cc4330", "id": "a6fd4b25-2b3e-458d-bb57-b75e41cc4330",
"name": "Audio Only", "name": "Audio Only",
"cli": "--extract-audio --add-chapters --embed-metadata --embed-thumbnail --format 'bestaudio/best'", "cli": "--socket-timeout 30 --download-archive %(config_path)s/archive.log\n--extract-audio --add-chapters --embed-metadata --embed-thumbnail --format 'bestaudio/best'",
"default": True, "default": True,
"description": "This preset is designed to download only the audio of the video. It will extract the audio, add chapters, metadata, and thumbnail.", "description": "This preset is designed to download only the audio of the video. It will extract the audio, add chapters, metadata, and thumbnail.",
}, },
@ -55,7 +56,7 @@ DEFAULT_PRESETS: list[dict[int, dict[str, str | bool]]] = [
"description": 'This preset generate specific filename format and metadata to work with yt-dlp info reader plugins for jellyfin/emby and plex and to make play state sync work for WatchState.\n\nThere is one more step you need to do via Other > Terminal if you have it enabled or directly from container shell\n\nyt-dlp -I0 --write-info-json --write-thumbnail --convert-thumbnails jpg --paths /downloads/youtube -o "%(channel|Unknown_title)s [%(channel_id|Unknown_id)s]/%(title).180B [%(channel_id|Unknown_id)s].%(ext)s" -- https://www.youtube.com/channel/UCClfFsWcT3N2I7VTXXyt84A\n\nChange the url to the channel you want to download.\n\nFor more information please visit \nhttps://github.com/arabcoders/watchstate/blob/master/FAQ.md#how-to-get-watchstate-working-with-youtube-contentlibrary', "description": 'This preset generate specific filename format and metadata to work with yt-dlp info reader plugins for jellyfin/emby and plex and to make play state sync work for WatchState.\n\nThere is one more step you need to do via Other > Terminal if you have it enabled or directly from container shell\n\nyt-dlp -I0 --write-info-json --write-thumbnail --convert-thumbnails jpg --paths /downloads/youtube -o "%(channel|Unknown_title)s [%(channel_id|Unknown_id)s]/%(title).180B [%(channel_id|Unknown_id)s].%(ext)s" -- https://www.youtube.com/channel/UCClfFsWcT3N2I7VTXXyt84A\n\nChange the url to the channel you want to download.\n\nFor more information please visit \nhttps://github.com/arabcoders/watchstate/blob/master/FAQ.md#how-to-get-watchstate-working-with-youtube-contentlibrary',
"folder": "youtube", "folder": "youtube",
"template": "%(channel)s %(channel_id|Unknown_id)s/Season %(release_date>%Y,upload_date>%Y|Unknown)s/%(release_date>%Y%m%d,upload_date>%Y%m%d)s - %(title).180B [%(extractor)s-%(id)s].%(ext)s", "template": "%(channel)s %(channel_id|Unknown_id)s/Season %(release_date>%Y,upload_date>%Y|Unknown)s/%(release_date>%Y%m%d,upload_date>%Y%m%d)s - %(title).180B [%(extractor)s-%(id)s].%(ext)s",
"cli": "--windows-filenames --write-info-json --embed-info-json \n--convert-thumbnails jpg --write-thumbnail --embed-metadata", "cli": "--socket-timeout 30 --download-archive %(config_path)s/archive.log\n--windows-filenames --write-info-json --embed-info-json \n--convert-thumbnails jpg --write-thumbnail --embed-metadata",
"default": True, "default": True,
}, },
] ]
@ -92,6 +93,7 @@ class Preset:
def json(self) -> str: def json(self) -> str:
from .encoder import Encoder from .encoder import Encoder
return Encoder().encode(self.serialize()) return Encoder().encode(self.serialize())
def get(self, key: str, default: Any = None) -> Any: def get(self, key: str, default: Any = None) -> Any:

View file

@ -22,7 +22,7 @@ class YTDLPOpts:
"""The command options for yt-dlp from preset.""" """The command options for yt-dlp from preset."""
def __init__(self): def __init__(self):
self._config = Config.get_instance() self._config: Config = Config.get_instance()
@staticmethod @staticmethod
def get_instance() -> "YTDLPOpts": def get_instance() -> "YTDLPOpts":
@ -96,7 +96,7 @@ class YTDLPOpts:
""" """
preset: Preset | None = Presets.get_instance().get(name) preset: Preset | None = Presets.get_instance().get(name)
if not preset or "default" == name: if not preset:
return self return self
if preset.cli: if preset.cli:
@ -169,7 +169,11 @@ class YTDLPOpts:
if len(self._item_cli) > 0: if len(self._item_cli) > 0:
try: try:
user_cli: dict = arg_converter(args="\n".join(self._item_cli), level=True) user_cli = "\n".join(self._item_cli)
for k, v in self._config.get_replacers().items():
user_cli = user_cli.replace(f"%({k})s", v if isinstance(v, str) else str(v))
user_cli: dict = arg_converter(args=user_cli, level=True)
except Exception as e: except Exception as e:
msg = f"Invalid command options for yt-dlp were given. '{e!s}'." msg = f"Invalid command options for yt-dlp were given. '{e!s}'."
raise ValueError(msg) from e raise ValueError(msg) from e

View file

@ -402,6 +402,9 @@ class Config:
self._ytdlp_cli_mutable += f"\n--socket-timeout {self.socket_timeout}" self._ytdlp_cli_mutable += f"\n--socket-timeout {self.socket_timeout}"
if self.keep_archive: if self.keep_archive:
LOG.warning(
"The global 'keep_archive' option is deprecated and will be removed in future releases. please use presets instead."
)
archive_file: Path = Path(self.archive_file) archive_file: Path = Path(self.archive_file)
if not archive_file.exists(): if not archive_file.exists():
LOG.info(f"Creating archive file '{archive_file}'.") LOG.info(f"Creating archive file '{archive_file}'.")
@ -537,7 +540,7 @@ class Config:
data["ytdlp_version"] = Config._ytdlp_version() data["ytdlp_version"] = Config._ytdlp_version()
return data return data
def get_replacer(self) -> dict: def get_replacers(self) -> dict:
""" """
Get the variables that can be used in Command options for yt-dlp. Get the variables that can be used in Command options for yt-dlp.

View file

@ -72,25 +72,16 @@
</p> </p>
<ul> <ul>
<li> <li>
The environment variables <code>YTP_KEEP_ARCHIVE</code> and <code>YTP_SOCKET_TIMEOUT</code> will no The following ENVs <strong>YTP_KEEP_ARCHIVE</strong> and <strong>YTP_SOCKET_TIMEOUT</strong> will be
longer be user-configurable. Their behavior will be part of the <strong>default presets</strong>. To keep removed.
your current behavior <strong>and avoid re-downloading</strong>, please add the following <strong>Command Their behavior will be part of the <strong>default presets</strong>. To keep your current behavior
options for yt-dlp</strong> to your presets: <strong>and avoid re-downloading</strong>, please add the following <strong>Command options for
<code>--socket-timeout 30 --download-archive /config/archive.log</code> yt-dlp</strong> to your presets:
<code>--socket-timeout 30 --download-archive %(config_path)s/archive.log</code>
</li> </li>
<li> <li>
The global yt-dlp config file <code>/config/ytdlp.cli</code> is deprecated and will be removed. Please The global yt-dlp config file <strong>/config/ytdlp.cli</strong> will be removed. Please migrate to
migrate any global options into your presets. 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>
<li>
The file browser feature will be enabled by <strong>default</strong>, and the associated environment
variable <code>YTP_BROWSER_ENABLED</code> will be removed, We will keep the
<code>YTP_BROWSER_CONTROL_ENABLED</code> to control whether you want to enable the file management
features or not. it will default to <code>false</code>.
</li> </li>
<li>The <strong>archive.manual.log</strong> feature has been removed.</li> <li>The <strong>archive.manual.log</strong> feature has been removed.</li>
</ul> </ul>
@ -98,6 +89,22 @@
These changes help reduce confusion from multiple sources of truth. Going forward, <strong>presets</strong> 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. and the <strong>Command options for yt-dlp</strong> will be the single source of truth.
</p> </p>
<p>
Notable changes in <strong>v0.10.x</strong>:
</p>
<ul>
<li>
The file browser feature is going to be enabled by default. and the associated ENV
<strong>YTP_BROWSER_ENABLED</strong> will be removed, <strong>YTP_BROWSER_CONTROL_ENABLED</strong> will
remain and
will default to <strong>false</strong>.
</li>
<li>
The <strong>Basic mode</strong> (which limited the interface to just the new download form) along it's
associated ENV <strong>YTP_BASIC_MODE</strong> is being removed. Everything except what is available
behind configurable flag will become part of the standard interface.
</li>
</ul>
</DeprecatedNotice> </DeprecatedNotice>
</div> </div>
</div> </div>

View file

@ -6,7 +6,6 @@ export const useConfigStore = defineStore('config', () => {
showForm: useStorage('showForm', false), showForm: useStorage('showForm', false),
app: { app: {
download_path: '/downloads', download_path: '/downloads',
keep_archive: false,
remove_files: false, remove_files: false,
ui_update_title: true, ui_update_title: true,
output_template: '', output_template: '',

View file

@ -4,8 +4,6 @@ import type { DLField } from "./dl_fields"
type AppConfig = { type AppConfig = {
/** Path where downloaded files will be saved */ /** Path where downloaded files will be saved */
download_path: string download_path: string
/** Indicates if the app should keep an archive of downloaded files */
keep_archive: boolean
/** Indicates if files should be removed after download */ /** Indicates if files should be removed after download */
remove_files: boolean remove_files: boolean
/** Indicates if the UI should update the title with the current download status */ /** Indicates if the UI should update the title with the current download status */