Skip to content

Commit

Permalink
refactor: add serializer
Browse files Browse the repository at this point in the history
  • Loading branch information
NTFSvolume committed Jan 21, 2025
1 parent 7053585 commit b1e950b
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
2 changes: 1 addition & 1 deletion cyberdrop_dl/clients/download_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def __init__(self, manager: Manager, client_manager: ClientManager) -> None:
self.trace_configs = []
self._file_path = None
self.slow_download_period = timedelta(seconds=10).total_seconds()
self.download_speed_threshold = self.manager.config_manager.settings_data.runtime_options.slow_downloads_speed
self.download_speed_threshold = self.manager.config_manager.settings_data.runtime_options.slow_download_speed
if DEBUG_VAR:
self.add_request_log_hooks()

Expand Down
8 changes: 7 additions & 1 deletion cyberdrop_dl/config_definitions/config_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ class RuntimeOptions(BaseModel):
jdownloader_autostart: bool = False
jdownloader_whitelist: list[NonEmptyStr] = []
deep_scrape: bool = False
slow_downloads_speed: ByteSize = ByteSize(0)
slow_download_speed: ByteSize = ByteSize(0)

@field_validator("jdownloader_download_dir", mode="before")
@classmethod
Expand All @@ -148,6 +148,12 @@ def handle_list(cls, value: list) -> list:
return []
return value

@field_serializer("slow_download_speed")
def human_readable(self, value: ByteSize | int) -> str:
if not isinstance(value, ByteSize):
value = ByteSize(value)
return value.human_readable(decimal=True)


# TODO: allow None values in sorting format to skip that type of file
class Sorting(BaseModel):
Expand Down

0 comments on commit b1e950b

Please sign in to comment.