From 4ad9ee533b28d5b0460aa78ddaa718f584841f96 Mon Sep 17 00:00:00 2001 From: arabcoders Date: Wed, 4 Jun 2025 21:54:53 +0300 Subject: [PATCH] Refactor terminology from "CLI arguments" to "command options for yt-dlp" across multiple files for consistency and clarity. --- API.md | 8 ++++---- app/library/DownloadQueue.py | 4 ++-- app/library/HttpAPI.py | 5 +++-- app/library/ItemDTO.py | 16 ++++++++-------- app/library/Presets.py | 4 ++-- app/library/Tasks.py | 2 +- app/library/YTDLPOpts.py | 16 ++++++++-------- app/library/conditions.py | 4 ++-- ui/components/ConditionForm.vue | 9 +++++---- ui/components/TaskForm.vue | 4 ++-- 10 files changed, 37 insertions(+), 35 deletions(-) diff --git a/API.md b/API.md index faa4305e..37b5dc0d 100644 --- a/API.md +++ b/API.md @@ -108,7 +108,7 @@ If you fail to provide valid credentials, a `401 Unauthorized` response is retur --- ### POST /api/yt-dlp/convert -**Purpose**: Convert a string of yt-dlp or youtube-dl CLI arguments into a JSON-friendly structure. +**Purpose**: Convert a string of yt-dlp options into a JSON-friendly structure. **Body**: ```json @@ -134,7 +134,7 @@ If you fail to provide valid credentials, a `401 Unauthorized` response is retur or an error: ```json { - "error": "Failed to parse command arguments for yt-dlp. ''." + "error": "Failed to parse command options for yt-dlp. ''." } ``` @@ -212,7 +212,7 @@ or an error: "folder": "my_channel/foo", // -- optional. The folder to save the item in, relative to the `download_path`. "cookies": "...", // -- optional. If provided, it MUST BE in Netscape HTTP Cookie format. "template": "%(title)s.%(ext)s", // -- optional. The filename template to use for this item. - "cli": "--write-subs --embed-subs", // -- optional. Additional yt-dlp CLI arguments to apply to this item. + "cli": "--write-subs --embed-subs", // -- optional. Additional command options for yt-dlp to apply to this item. } // Or multiple items (array of objects) @@ -697,7 +697,7 @@ Binary image data with appropriate `Content-Type` header. "folder": "my_channel/foo", // optional, relative to download_path "template": "%(title)s.%(ext)s", // optional, filename template "cookies": "...", // optional, Netscape HTTP Cookie format - "cli": "--write-subs --embed-subs", // optional, additional yt-dlp CLI arguments + "cli": "--write-subs --embed-subs", // optional, additional command options for yt-dlp }, ... ] diff --git a/app/library/DownloadQueue.py b/app/library/DownloadQueue.py index fc15b78f..d9fc6b1e 100644 --- a/app/library/DownloadQueue.py +++ b/app/library/DownloadQueue.py @@ -388,8 +388,8 @@ class DownloadQueue(metaclass=Singleton): try: arg_converter(args=item.cli, level=True) except Exception as e: - LOG.error(f"Invalid cli options '{item.cli}'. {e!s}") - return {"status": "error", "msg": f"Invalid cli options '{item.cli}'. {e!s}"} + LOG.error(f"Invalid command options for yt-dlp '{item.cli}'. {e!s}") + return {"status": "error", "msg": f"Invalid command options for yt-dlp '{item.cli}'. {e!s}"} if _preset: if _preset.folder and not item.folder: diff --git a/app/library/HttpAPI.py b/app/library/HttpAPI.py index b323f713..4add6254 100644 --- a/app/library/HttpAPI.py +++ b/app/library/HttpAPI.py @@ -491,7 +491,7 @@ class HttpAPI(Common): err = err.split("\n")[-1] if "\n" in err else err err = err.replace("main.py: error: ", "").strip().capitalize() return web.json_response( - data={"error": f"Failed to parse command arguments for yt-dlp. '{err}'."}, + data={"error": f"Failed to parse command options for yt-dlp. '{err}'."}, status=web.HTTPBadRequest.status_code, ) @@ -844,7 +844,8 @@ class HttpAPI(Common): if not item.get("cli"): return web.json_response( - {"error": "CLI arguments is required.", "data": item}, status=web.HTTPBadRequest.status_code + {"error": "command options for yt-dlp is required.", "data": item}, + status=web.HTTPBadRequest.status_code, ) if not item.get("id", None) or not validate_uuid(item.get("id"), version=4): diff --git a/app/library/ItemDTO.py b/app/library/ItemDTO.py index cd90223f..19436886 100644 --- a/app/library/ItemDTO.py +++ b/app/library/ItemDTO.py @@ -19,19 +19,19 @@ class Item: """The URL of the item to be downloaded.""" preset: str = field(default_factory=lambda: Item._default_preset()) - """The preset to be used for the download.""" + """The preset to be used for this download.""" folder: str = "" """The folder to save the download to.""" cookies: str = "" - """The cookies to be used for the download.""" + """The cookies to be used for this download.""" template: str = "" - """The template to be used for the download.""" + """The template to be used for this download.""" cli: str = "" - """The yt-dlp cli options to be used for the download.""" + """The command options for yt-dlp to be used for this download.""" extras: dict = field(default_factory=dict) """Extra data to be added to the download.""" @@ -60,10 +60,10 @@ class Item: def has_cli(self) -> bool: """ - Check if the item has any yt-dlp cli options associated with it. + Check if the item has any command options for yt-dlp associated with it. Returns: - bool: True if the item has yt-dlp cli options, False otherwise. + bool: True if the item has command options for yt, False otherwise. """ return self.cli and len(self.cli) > 2 @@ -120,7 +120,7 @@ class Item: Raises: ValueError: If the url is not provided. - ValueError: If the yt-cli command line arguments are not valid. + ValueError: If the command options for yt-cli are invalid. Returns: Item: The formatted item. @@ -174,7 +174,7 @@ class Item: data["cli"] = cli except Exception as e: - msg = f"Failed to parse yt-dlp cli options. {e!s}" + msg = f"Failed to parse command options for yt-dlp. {e!s}" raise ValueError(msg) from e return Item(**data) diff --git a/app/library/Presets.py b/app/library/Presets.py index d5437046..ee695ea4 100644 --- a/app/library/Presets.py +++ b/app/library/Presets.py @@ -37,7 +37,7 @@ class Preset: """The default cookies to use if non is given.""" cli: str = "" - """yt-dlp cli command line arguments.""" + """command options for yt-dlp.""" default: bool = False """If True, the preset is a default preset.""" @@ -236,7 +236,7 @@ class Presets(metaclass=Singleton): try: arg_converter(args=item.get("cli")) except Exception as e: - msg = f"Invalid cli options. '{e!s}'." + msg = f"Invalid command options for yt-dlp. '{e!s}'." raise ValueError(msg) from e return True diff --git a/app/library/Tasks.py b/app/library/Tasks.py index e529a54f..4bf22320 100644 --- a/app/library/Tasks.py +++ b/app/library/Tasks.py @@ -245,7 +245,7 @@ class Tasks(metaclass=Singleton): arg_converter(args=task.get("cli")) except Exception as e: - msg = f"Invalid cli options. '{e!s}'." + msg = f"Invalid command options for yt-dlp. '{e!s}'." raise ValueError(msg) from e return True diff --git a/app/library/YTDLPOpts.py b/app/library/YTDLPOpts.py index da61ea70..77458cfd 100644 --- a/app/library/YTDLPOpts.py +++ b/app/library/YTDLPOpts.py @@ -17,10 +17,10 @@ class YTDLPOpts(metaclass=Singleton): """The preset options.""" _item_cli: list = [] - """The item cli options.""" + """The command options for yt-dlp from item.""" _preset_cli: str = "" - """The preset cli options.""" + """The command options for yt-dlp from preset.""" _instance = None """The instance of the class.""" @@ -44,10 +44,10 @@ class YTDLPOpts(metaclass=Singleton): def add_cli(self, args: str, from_user: int | bool = False) -> "YTDLPOpts": """ - Parse and add yt-dlp cli options to the item options. + Parse and add command options for yt-dlp to the item options. Args: - args (str): The cli options to add + args (str): The command options for yt-dlp to add from_user (bool): If the options are from the user Returns: @@ -60,7 +60,7 @@ class YTDLPOpts(metaclass=Singleton): try: arg_converter(args=args, level=from_user) except Exception as e: - msg = f"Invalid cli options for were given. '{e!s}'." + msg = f"Invalid command options for yt-dlp were given. '{e!s}'." raise ValueError(msg) from e self._item_cli.append(args) @@ -119,7 +119,7 @@ class YTDLPOpts(metaclass=Singleton): self._preset_opts = {} self._preset_cli = preset.cli except Exception as e: - msg = f"Invalid cli options for preset '{preset.name}'. '{e!s}'." + msg = f"Invalid preset '{preset.name}' command options for yt-dlp. '{e!s}'." raise ValueError(msg) from e if preset.cookies and with_cookies: @@ -175,7 +175,7 @@ class YTDLPOpts(metaclass=Singleton): merge.append(self._preset_cli) if len(merge) > 0: - # prepend the cli options to the list + # prepend the yt-dlp command options to the list self._item_cli = merge + self._item_cli user_cli = {} @@ -188,7 +188,7 @@ class YTDLPOpts(metaclass=Singleton): if len(removed_options) > 0: LOG.warning("Removed the following options: '%s'.", ", ".join(removed_options)) except Exception as e: - msg = f"Invalid cli options were given. '{e!s}'." + msg = f"Invalid command options for yt-dlp were given. '{e!s}'." raise ValueError(msg) from e data = merge_dict(user_cli, merge_dict(self._item_opts, merge_dict(self._preset_opts, default_opts))) diff --git a/app/library/conditions.py b/app/library/conditions.py index cb764052..eff44d6f 100644 --- a/app/library/conditions.py +++ b/app/library/conditions.py @@ -204,13 +204,13 @@ class Conditions(metaclass=Singleton): raise ValueError(msg) from e if not item.get("cli"): - msg = "No CLI arguments were found." + msg = "No command options for yt-dlp were found." raise ValueError(msg) try: arg_converter(args=item.get("cli")) except Exception as e: - msg = f"Invalid cli options. '{e!s}'." + msg = f"Invalid command options for yt-dlp. '{e!s}'." raise ValueError(msg) from e return True diff --git a/ui/components/ConditionForm.vue b/ui/components/ConditionForm.vue index 4e7b4f7c..49afd01e 100644 --- a/ui/components/ConditionForm.vue +++ b/ui/components/ConditionForm.vue @@ -80,7 +80,8 @@ The yt-dlp [--match-filters] filter logic. - + Test filter logic @@ -92,7 +93,7 @@