Refactor terminology from "CLI arguments" to "command options for yt-dlp" across multiple files for consistency and clarity.

This commit is contained in:
arabcoders 2025-06-04 21:54:53 +03:00
parent 1a48a3eea9
commit 4ad9ee533b
10 changed files with 37 additions and 35 deletions

8
API.md
View file

@ -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. '<reason>'."
"error": "Failed to parse command options for yt-dlp. '<reason>'."
}
```
@ -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
},
...
]

View file

@ -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:

View file

@ -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):

View file

@ -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)

View file

@ -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

View file

@ -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

View file

@ -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)))

View file

@ -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

View file

@ -80,7 +80,8 @@
<span class="icon"><i class="fa-solid fa-info" /></span>
<span>
The yt-dlp <code>[--match-filters]</code> filter logic.
<NuxtLink @click="test_data.show = true" :disabled="addInProgress || !form.filter" class="is-bold">
<NuxtLink @click="test_data.show = true" :disabled="addInProgress || !form.filter"
class="is-bold">
Test filter logic
</NuxtLink>
</span>
@ -92,7 +93,7 @@
<div class="field">
<label class="label is-inline" for="cli_options">
<span class="icon"><i class="fa-solid fa-terminal" /></span>
Command arguments for yt-dlp
Command options for yt-dlp
</label>
<div class="control">
<textarea class="textarea is-pre" v-model="form.cli" id="cli_options" :disabled="addInProgress"
@ -101,8 +102,8 @@
<span class="help">
<span class="icon"><i class="fa-solid fa-info" /></span>
<span>If the filter is matched, these options will be used.
<span class="has-text-danger">This will override the cli arguments given with the URL. it's
recommended to use presets and keep the cli with url empty if you plan to use this
<span class="has-text-danger">This will override the command options for yt-dlp given with the
URL. it's recommended to use presets and keep that field with url empty if you plan to use this
feature.</span>
</span>
</span>

View file

@ -94,7 +94,7 @@
<div class="select is-fullwidth">
<select id="preset" class="is-fullwidth" v-model="form.preset"
:disabled="addInProgress || hasFormatInConfig"
v-tooltip.bottom="hasFormatInConfig ? 'Presets are disabled. Format key is present in the command arguments for yt-dlp.' : ''">
v-tooltip.bottom="hasFormatInConfig ? 'Presets are disabled. Format key is present in the command options for yt-dlp.' : ''">
<optgroup label="Default presets">
<option v-for="item in filter_presets(true)" :key="item.name" :value="item.name">
{{ item.name }}
@ -179,7 +179,7 @@
<div class="field">
<label class="label is-inline" for="cli_options">
<span class="icon"><i class="fa-solid fa-terminal" /></span>
Command arguments for yt-dlp
Command options for yt-dlp
</label>
<div class="control">
<textarea type="text" class="textarea is-pre" v-model="form.cli" id="cli_options"