Skip to content

Bulk asynchronous downloader for multiple file hosts

fix: serialization of flaresolverr and proxy

NTFSvolumed7cb860d6a2b
diff --git a/.zed/debug.json b/.zed/debug.json
index eb3d9c419..618e8e054 100644
--- a/.zed/debug.json
+++ b/.zed/debug.json
@@ -10,7 +10,7 @@
"--download",
"--ignore-history",
"--dump-json",
- "--required-free-space",
+ "--min-free-space",
"512MB",
"--no-ignore-coomer-post-content",
"--max-simultaneous-downloads",
diff --git a/cyberdrop_dl/config/__init__.py b/cyberdrop_dl/config/__init__.py
index 7cd305a91..ae781f77f 100644
--- a/cyberdrop_dl/config/__init__.py
+++ b/cyberdrop_dl/config/__init__.py
@@ -7,7 +7,7 @@ from typing import TYPE_CHECKING, Annotated, Literal, Self
from cyclopts import App, Parameter
from cyclopts.bind import normalize_tokens
-from pydantic import BaseModel, ByteSize, Field, PositiveInt, field_serializer, field_validator
+from pydantic import BaseModel, ByteSize, Field, PositiveInt, field_validator
from cyberdrop_dl import yaml
from cyberdrop_dl.config.merge import merge_models
@@ -148,10 +148,6 @@ class Config(BaseModel):
def _unique_list(cls, value: list[str]) -> list[str]:
return sorted(set(value))
- @field_serializer("flaresolverr", "proxy")
- def _serialize(self, value: object) -> object:
- return falsy_as(value, None)
-
@field_validator("flaresolverr", "proxy", mode="before")
@classmethod
def _to_str(cls, value: str) -> str | None:
diff --git a/cyberdrop_dl/logs.py b/cyberdrop_dl/logs.py
index 4a36a8417..c2717260c 100644
--- a/cyberdrop_dl/logs.py
+++ b/cyberdrop_dl/logs.py
@@ -71,18 +71,23 @@ class JsonLogRecord(logging.LogRecord):
@override
def getMessage(self) -> str:
msg = str(self._proccess_msg(self.msg))
- if self.args:
- args = tuple(map(self._proccess_msg, self.args))
- if "%" in msg:
- try:
- return msg % args
- except TypeError as e:
- if not e.args or "not all arguments converted" in e.args[0]:
- raise
+ args = self.args
+ if not args:
+ return msg
- return msg.format(*args)
+ if type(self.args) is dict:
+ # Override std special case for mappings
+ args = [self.args]
- return msg
+ args = tuple(map(self._proccess_msg, args))
+ if "%" in msg:
+ try:
+ return msg % args
+ except TypeError as e:
+ if not e.args or "not all arguments converted" in e.args[0]:
+ raise
+
+ return msg.format(*args)
@staticmethod
def _proccess_msg(obj: object) -> object:
@@ -163,8 +168,8 @@ class LogHandler(RichHandler):
def emit(self, record: logging.LogRecord) -> None:
try:
return super().emit(record)
- except Exception: # noqa: BLE001
- self.handleError(record)
+ except Exception:
+ logger.critical("Unable to log", exc_info=True)
class BareQueueHandler(QueueHandler):
diff --git a/cyberdrop_dl/manager.py b/cyberdrop_dl/manager.py
index 9ced3a0c1..4ea71d812 100644
--- a/cyberdrop_dl/manager.py
+++ b/cyberdrop_dl/manager.py
@@ -292,10 +292,10 @@ def _log_cli_args(cli_args: CLIargs) -> None:
def _log_config(config: Config) -> None:
- data = config.model_dump(mode="json")
- data["auth"] = {site: all(credentials.values()) for site, credentials in data.pop("auth").items()}
+ auth = {site: all(credentials.values()) for site, credentials in config.auth.model_dump().items()}
logger.debug("Config file: %s", config.source)
- logger.debug(data)
+ logger.debug("Auth: \n%s", auth)
+ logger.debug(config.model_dump_json(exclude={"auth"}, indent=2))
def _log_ffmpeg() -> None: