Skip to content

Bulk asynchronous downloader for multiple file hosts

screw it, we always get head.

Jules-WinnfieldXb86dc5dd6191
diff --git a/cyberdrop_dl/__init__.py b/cyberdrop_dl/__init__.py
index 6e9a24925..71fae1bc8 100644
--- a/cyberdrop_dl/__init__.py
+++ b/cyberdrop_dl/__init__.py
@@ -1 +1 @@
-__version__ = "2.19.2"
+__version__ = "2.19.3"
diff --git a/cyberdrop_dl/utils/downloaders.py b/cyberdrop_dl/utils/downloaders.py
index a0e66277a..0b62ded6d 100644
--- a/cyberdrop_dl/utils/downloaders.py
+++ b/cyberdrop_dl/utils/downloaders.py
@@ -144,13 +144,14 @@ class Downloader:
await asyncio.sleep(gauss(1, 1.5))
await self.File_Lock.add_lock(filename)
+ async with session.head(url, headers=headers, ssl=ssl_context, raise_for_status=True) as resp:
+ total_size = int(resp.headers.get('Content-Length', str(0)))
+
complete_file = (self.folder / self.title / filename)
if await self.SQL_helper.check_filename(filename) or complete_file.exists:
for key, value in self.delay.items():
if key in url.host:
await throttle(self, value, key)
- async with session.head(url, headers=headers, ssl=ssl_context, raise_for_status=True) as resp:
- total_size = int(resp.headers.get('Content-Length', str(0)))
# check for exact file
if complete_file.exists():
@@ -211,11 +212,10 @@ class Downloader:
await self.File_Lock.remove_lock(original_filename)
return
- total_size = int(resp.headers.get('Content-Length', str(0)))
total = int(resp.headers.get('Content-Length', str(0))) + resume_point
(self.folder / self.title).mkdir(parents=True, exist_ok=True)
- await self.SQL_helper.sql_insert_file(original_filename, filename, total, 0)
+ await self.SQL_helper.sql_insert_file(original_filename, filename, total_size, 0)
with tqdm(
total=total, unit_scale=True,