Refactor terminology from "CLI arguments" to "command options for yt-dlp" across multiple files for consistency and clarity.
This commit is contained in:
parent
1a48a3eea9
commit
4ad9ee533b
10 changed files with 37 additions and 35 deletions
8
API.md
8
API.md
|
|
@ -108,7 +108,7 @@ If you fail to provide valid credentials, a `401 Unauthorized` response is retur
|
||||||
---
|
---
|
||||||
|
|
||||||
### POST /api/yt-dlp/convert
|
### 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**:
|
**Body**:
|
||||||
```json
|
```json
|
||||||
|
|
@ -134,7 +134,7 @@ If you fail to provide valid credentials, a `401 Unauthorized` response is retur
|
||||||
or an error:
|
or an error:
|
||||||
```json
|
```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`.
|
"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.
|
"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.
|
"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)
|
// 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
|
"folder": "my_channel/foo", // optional, relative to download_path
|
||||||
"template": "%(title)s.%(ext)s", // optional, filename template
|
"template": "%(title)s.%(ext)s", // optional, filename template
|
||||||
"cookies": "...", // optional, Netscape HTTP Cookie format
|
"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
|
||||||
},
|
},
|
||||||
...
|
...
|
||||||
]
|
]
|
||||||
|
|
|
||||||
|
|
@ -388,8 +388,8 @@ class DownloadQueue(metaclass=Singleton):
|
||||||
try:
|
try:
|
||||||
arg_converter(args=item.cli, level=True)
|
arg_converter(args=item.cli, level=True)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
LOG.error(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 cli options '{item.cli}'. {e!s}"}
|
return {"status": "error", "msg": f"Invalid command options for yt-dlp '{item.cli}'. {e!s}"}
|
||||||
|
|
||||||
if _preset:
|
if _preset:
|
||||||
if _preset.folder and not item.folder:
|
if _preset.folder and not item.folder:
|
||||||
|
|
|
||||||
|
|
@ -491,7 +491,7 @@ class HttpAPI(Common):
|
||||||
err = err.split("\n")[-1] if "\n" in err else err
|
err = err.split("\n")[-1] if "\n" in err else err
|
||||||
err = err.replace("main.py: error: ", "").strip().capitalize()
|
err = err.replace("main.py: error: ", "").strip().capitalize()
|
||||||
return web.json_response(
|
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,
|
status=web.HTTPBadRequest.status_code,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -844,7 +844,8 @@ class HttpAPI(Common):
|
||||||
|
|
||||||
if not item.get("cli"):
|
if not item.get("cli"):
|
||||||
return web.json_response(
|
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):
|
if not item.get("id", None) or not validate_uuid(item.get("id"), version=4):
|
||||||
|
|
|
||||||
|
|
@ -19,19 +19,19 @@ class Item:
|
||||||
"""The URL of the item to be downloaded."""
|
"""The URL of the item to be downloaded."""
|
||||||
|
|
||||||
preset: str = field(default_factory=lambda: Item._default_preset())
|
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 = ""
|
folder: str = ""
|
||||||
"""The folder to save the download to."""
|
"""The folder to save the download to."""
|
||||||
|
|
||||||
cookies: str = ""
|
cookies: str = ""
|
||||||
"""The cookies to be used for the download."""
|
"""The cookies to be used for this download."""
|
||||||
|
|
||||||
template: str = ""
|
template: str = ""
|
||||||
"""The template to be used for the download."""
|
"""The template to be used for this download."""
|
||||||
|
|
||||||
cli: str = ""
|
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)
|
extras: dict = field(default_factory=dict)
|
||||||
"""Extra data to be added to the download."""
|
"""Extra data to be added to the download."""
|
||||||
|
|
@ -60,10 +60,10 @@ class Item:
|
||||||
|
|
||||||
def has_cli(self) -> bool:
|
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:
|
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
|
return self.cli and len(self.cli) > 2
|
||||||
|
|
@ -120,7 +120,7 @@ class Item:
|
||||||
|
|
||||||
Raises:
|
Raises:
|
||||||
ValueError: If the url is not provided.
|
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:
|
Returns:
|
||||||
Item: The formatted item.
|
Item: The formatted item.
|
||||||
|
|
@ -174,7 +174,7 @@ class Item:
|
||||||
|
|
||||||
data["cli"] = cli
|
data["cli"] = cli
|
||||||
except Exception as e:
|
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
|
raise ValueError(msg) from e
|
||||||
|
|
||||||
return Item(**data)
|
return Item(**data)
|
||||||
|
|
|
||||||
|
|
@ -37,7 +37,7 @@ class Preset:
|
||||||
"""The default cookies to use if non is given."""
|
"""The default cookies to use if non is given."""
|
||||||
|
|
||||||
cli: str = ""
|
cli: str = ""
|
||||||
"""yt-dlp cli command line arguments."""
|
"""command options for yt-dlp."""
|
||||||
|
|
||||||
default: bool = False
|
default: bool = False
|
||||||
"""If True, the preset is a default preset."""
|
"""If True, the preset is a default preset."""
|
||||||
|
|
@ -236,7 +236,7 @@ class Presets(metaclass=Singleton):
|
||||||
try:
|
try:
|
||||||
arg_converter(args=item.get("cli"))
|
arg_converter(args=item.get("cli"))
|
||||||
except Exception as e:
|
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
|
raise ValueError(msg) from e
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
|
||||||
|
|
@ -245,7 +245,7 @@ class Tasks(metaclass=Singleton):
|
||||||
|
|
||||||
arg_converter(args=task.get("cli"))
|
arg_converter(args=task.get("cli"))
|
||||||
except Exception as e:
|
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
|
raise ValueError(msg) from e
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
|
||||||
|
|
@ -17,10 +17,10 @@ class YTDLPOpts(metaclass=Singleton):
|
||||||
"""The preset options."""
|
"""The preset options."""
|
||||||
|
|
||||||
_item_cli: list = []
|
_item_cli: list = []
|
||||||
"""The item cli options."""
|
"""The command options for yt-dlp from item."""
|
||||||
|
|
||||||
_preset_cli: str = ""
|
_preset_cli: str = ""
|
||||||
"""The preset cli options."""
|
"""The command options for yt-dlp from preset."""
|
||||||
|
|
||||||
_instance = None
|
_instance = None
|
||||||
"""The instance of the class."""
|
"""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":
|
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:
|
||||||
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
|
from_user (bool): If the options are from the user
|
||||||
|
|
||||||
Returns:
|
Returns:
|
||||||
|
|
@ -60,7 +60,7 @@ class YTDLPOpts(metaclass=Singleton):
|
||||||
try:
|
try:
|
||||||
arg_converter(args=args, level=from_user)
|
arg_converter(args=args, level=from_user)
|
||||||
except Exception as e:
|
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
|
raise ValueError(msg) from e
|
||||||
|
|
||||||
self._item_cli.append(args)
|
self._item_cli.append(args)
|
||||||
|
|
@ -119,7 +119,7 @@ class YTDLPOpts(metaclass=Singleton):
|
||||||
self._preset_opts = {}
|
self._preset_opts = {}
|
||||||
self._preset_cli = preset.cli
|
self._preset_cli = preset.cli
|
||||||
except Exception as e:
|
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
|
raise ValueError(msg) from e
|
||||||
|
|
||||||
if preset.cookies and with_cookies:
|
if preset.cookies and with_cookies:
|
||||||
|
|
@ -175,7 +175,7 @@ class YTDLPOpts(metaclass=Singleton):
|
||||||
merge.append(self._preset_cli)
|
merge.append(self._preset_cli)
|
||||||
|
|
||||||
if len(merge) > 0:
|
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
|
self._item_cli = merge + self._item_cli
|
||||||
|
|
||||||
user_cli = {}
|
user_cli = {}
|
||||||
|
|
@ -188,7 +188,7 @@ class YTDLPOpts(metaclass=Singleton):
|
||||||
if len(removed_options) > 0:
|
if len(removed_options) > 0:
|
||||||
LOG.warning("Removed the following options: '%s'.", ", ".join(removed_options))
|
LOG.warning("Removed the following options: '%s'.", ", ".join(removed_options))
|
||||||
except Exception as e:
|
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
|
raise ValueError(msg) from e
|
||||||
|
|
||||||
data = merge_dict(user_cli, merge_dict(self._item_opts, merge_dict(self._preset_opts, default_opts)))
|
data = merge_dict(user_cli, merge_dict(self._item_opts, merge_dict(self._preset_opts, default_opts)))
|
||||||
|
|
|
||||||
|
|
@ -204,13 +204,13 @@ class Conditions(metaclass=Singleton):
|
||||||
raise ValueError(msg) from e
|
raise ValueError(msg) from e
|
||||||
|
|
||||||
if not item.get("cli"):
|
if not item.get("cli"):
|
||||||
msg = "No CLI arguments were found."
|
msg = "No command options for yt-dlp were found."
|
||||||
raise ValueError(msg)
|
raise ValueError(msg)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
arg_converter(args=item.get("cli"))
|
arg_converter(args=item.get("cli"))
|
||||||
except Exception as e:
|
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
|
raise ValueError(msg) from e
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
|
||||||
|
|
@ -80,7 +80,8 @@
|
||||||
<span class="icon"><i class="fa-solid fa-info" /></span>
|
<span class="icon"><i class="fa-solid fa-info" /></span>
|
||||||
<span>
|
<span>
|
||||||
The yt-dlp <code>[--match-filters]</code> filter logic.
|
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
|
Test filter logic
|
||||||
</NuxtLink>
|
</NuxtLink>
|
||||||
</span>
|
</span>
|
||||||
|
|
@ -92,7 +93,7 @@
|
||||||
<div class="field">
|
<div class="field">
|
||||||
<label class="label is-inline" for="cli_options">
|
<label class="label is-inline" for="cli_options">
|
||||||
<span class="icon"><i class="fa-solid fa-terminal" /></span>
|
<span class="icon"><i class="fa-solid fa-terminal" /></span>
|
||||||
Command arguments for yt-dlp
|
Command options for yt-dlp
|
||||||
</label>
|
</label>
|
||||||
<div class="control">
|
<div class="control">
|
||||||
<textarea class="textarea is-pre" v-model="form.cli" id="cli_options" :disabled="addInProgress"
|
<textarea class="textarea is-pre" v-model="form.cli" id="cli_options" :disabled="addInProgress"
|
||||||
|
|
@ -101,8 +102,8 @@
|
||||||
<span class="help">
|
<span class="help">
|
||||||
<span class="icon"><i class="fa-solid fa-info" /></span>
|
<span class="icon"><i class="fa-solid fa-info" /></span>
|
||||||
<span>If the filter is matched, these options will be used.
|
<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
|
<span class="has-text-danger">This will override the command options for yt-dlp given with the
|
||||||
recommended to use presets and keep the cli with url empty if you plan to use this
|
URL. it's recommended to use presets and keep that field with url empty if you plan to use this
|
||||||
feature.</span>
|
feature.</span>
|
||||||
</span>
|
</span>
|
||||||
</span>
|
</span>
|
||||||
|
|
|
||||||
|
|
@ -94,7 +94,7 @@
|
||||||
<div class="select is-fullwidth">
|
<div class="select is-fullwidth">
|
||||||
<select id="preset" class="is-fullwidth" v-model="form.preset"
|
<select id="preset" class="is-fullwidth" v-model="form.preset"
|
||||||
:disabled="addInProgress || hasFormatInConfig"
|
: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">
|
<optgroup label="Default presets">
|
||||||
<option v-for="item in filter_presets(true)" :key="item.name" :value="item.name">
|
<option v-for="item in filter_presets(true)" :key="item.name" :value="item.name">
|
||||||
{{ item.name }}
|
{{ item.name }}
|
||||||
|
|
@ -179,7 +179,7 @@
|
||||||
<div class="field">
|
<div class="field">
|
||||||
<label class="label is-inline" for="cli_options">
|
<label class="label is-inline" for="cli_options">
|
||||||
<span class="icon"><i class="fa-solid fa-terminal" /></span>
|
<span class="icon"><i class="fa-solid fa-terminal" /></span>
|
||||||
Command arguments for yt-dlp
|
Command options for yt-dlp
|
||||||
</label>
|
</label>
|
||||||
<div class="control">
|
<div class="control">
|
||||||
<textarea type="text" class="textarea is-pre" v-model="form.cli" id="cli_options"
|
<textarea type="text" class="textarea is-pre" v-model="form.cli" id="cli_options"
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue