Skip to content

Bulk asynchronous downloader for multiple file hosts

refactor: use inplace logic

NTFSvolumebba1996dc98f
diff --git a/cyberdrop_dl/clients/download_client.py b/cyberdrop_dl/clients/download_client.py
index df54c935d..97a039c7d 100644
--- a/cyberdrop_dl/clients/download_client.py
+++ b/cyberdrop_dl/clients/download_client.py
@@ -216,8 +216,11 @@ class DownloadClient:
if resp.status != HTTPStatus.PARTIAL_CONTENT and media_item.partial_file.is_file():
media_item.partial_file.unlink()
- if not media_item.datetime:
- add_last_modified(media_item, resp.headers)
+ if not media_item.datetime and (last_modified := get_last_modified(resp.headers)):
+ msg = f"Unable to parse upload date for {media_item.url}, using `Last-Modified` value from server as file datetime"
+ log(msg, 30)
+ media_item.datetime = last_modified
+
media_item.task_id = self.manager.progress_manager.file_progress.add_task(
domain=domain,
filename=media_item.filename,
@@ -513,12 +516,5 @@ def get_last_modified(headers: CIMultiDictProxy) -> int | None:
return calendar.timegm(parsed_date.timetuple())
-def add_last_modified(media_item: MediaItem, headers: CIMultiDictProxy) -> None:
- if date := get_last_modified(headers):
- msg = f"Unable to parse upload date for {media_item.url}, using `Last-Modified` value from server as file datetime"
- log(msg, 30)
- media_item.datetime = date
-
-
def is_html_or_text(content_type: str) -> bool:
return any(s in content_type for s in ("html", "text"))