Refactor arg_converter usage to remove logging of removed options in Item and YTDLPOpts classes
This commit is contained in:
parent
28e3062bef
commit
c9af30edda
2 changed files with 2 additions and 20 deletions
|
|
@ -151,11 +151,7 @@ class Item:
|
|||
from .Utils import arg_converter
|
||||
|
||||
try:
|
||||
removed_options: list = []
|
||||
arg_converter(args=cli, level=True, removed_options=removed_options)
|
||||
if len(removed_options) > 0:
|
||||
LOG.warning("Removed the following options '%s' for '%s'.", ", ".join(removed_options), url)
|
||||
|
||||
arg_converter(args=cli, level=True)
|
||||
data["cli"] = cli
|
||||
except Exception as e:
|
||||
msg = f"Failed to parse command options for yt-dlp. {e!s}"
|
||||
|
|
|
|||
|
|
@ -76,18 +76,12 @@ class YTDLPOpts:
|
|||
if from_user:
|
||||
bad_options: dict[str, str] = {k: v for d in REMOVE_KEYS for k, v in d.items()}
|
||||
|
||||
removed_options: list = []
|
||||
|
||||
for key, value in config.items():
|
||||
if from_user and key in bad_options:
|
||||
removed_options.append(bad_options[key])
|
||||
continue
|
||||
|
||||
self._item_opts[key] = value
|
||||
|
||||
if len(removed_options) > 0:
|
||||
LOG.warning("Removed the following options: '%s'.", ", ".join(removed_options))
|
||||
|
||||
return self
|
||||
|
||||
def preset(self, name: str) -> "YTDLPOpts":
|
||||
|
|
@ -175,15 +169,7 @@ class YTDLPOpts:
|
|||
|
||||
if len(self._item_cli) > 0:
|
||||
try:
|
||||
removed_options: list = []
|
||||
user_cli: dict = arg_converter(
|
||||
args="\n".join(self._item_cli),
|
||||
level=True,
|
||||
removed_options=removed_options,
|
||||
)
|
||||
|
||||
if len(removed_options) > 0:
|
||||
LOG.warning("Removed the following options: '%s'.", ", ".join(removed_options))
|
||||
user_cli: dict = arg_converter(args="\n".join(self._item_cli), level=True)
|
||||
except Exception as e:
|
||||
msg = f"Invalid command options for yt-dlp were given. '{e!s}'."
|
||||
raise ValueError(msg) from e
|
||||
|
|
|
|||
Loading…
Reference in a new issue