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
|
from .Utils import arg_converter
|
||||||
|
|
||||||
try:
|
try:
|
||||||
removed_options: list = []
|
arg_converter(args=cli, level=True)
|
||||||
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)
|
|
||||||
|
|
||||||
data["cli"] = cli
|
data["cli"] = cli
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
msg = f"Failed to parse command options for yt-dlp. {e!s}"
|
msg = f"Failed to parse command options for yt-dlp. {e!s}"
|
||||||
|
|
|
||||||
|
|
@ -76,18 +76,12 @@ class YTDLPOpts:
|
||||||
if from_user:
|
if from_user:
|
||||||
bad_options: dict[str, str] = {k: v for d in REMOVE_KEYS for k, v in d.items()}
|
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():
|
for key, value in config.items():
|
||||||
if from_user and key in bad_options:
|
if from_user and key in bad_options:
|
||||||
removed_options.append(bad_options[key])
|
|
||||||
continue
|
continue
|
||||||
|
|
||||||
self._item_opts[key] = value
|
self._item_opts[key] = value
|
||||||
|
|
||||||
if len(removed_options) > 0:
|
|
||||||
LOG.warning("Removed the following options: '%s'.", ", ".join(removed_options))
|
|
||||||
|
|
||||||
return self
|
return self
|
||||||
|
|
||||||
def preset(self, name: str) -> "YTDLPOpts":
|
def preset(self, name: str) -> "YTDLPOpts":
|
||||||
|
|
@ -175,15 +169,7 @@ class YTDLPOpts:
|
||||||
|
|
||||||
if len(self._item_cli) > 0:
|
if len(self._item_cli) > 0:
|
||||||
try:
|
try:
|
||||||
removed_options: list = []
|
user_cli: dict = arg_converter(args="\n".join(self._item_cli), level=True)
|
||||||
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))
|
|
||||||
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
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue