Skip to content

Bulk asynchronous downloader for multiple file hosts

Add more error handling, and add updating of referer to DB so check_by_referer can function more properly.

Jules-WinnfieldXb5eb5b62b26e
diff --git a/cyberdrop_dl/__init__.py b/cyberdrop_dl/__init__.py
index 6ce813856..f061738db 100644
--- a/cyberdrop_dl/__init__.py
+++ b/cyberdrop_dl/__init__.py
@@ -1 +1 @@
-__version__ = "5.1.15"
+__version__ = "5.1.16"
diff --git a/cyberdrop_dl/scraper/crawler.py b/cyberdrop_dl/scraper/crawler.py
index 607d4b3ef..308c3be66 100644
--- a/cyberdrop_dl/scraper/crawler.py
+++ b/cyberdrop_dl/scraper/crawler.py
@@ -69,7 +69,7 @@ class Crawler(ABC):
else:
original_filename = filename
- check_complete = await self.manager.db_manager.history_table.check_complete(self.domain, url)
+ check_complete = await self.manager.db_manager.history_table.check_complete(self.domain, url, scrape_item.url)
if check_complete:
await log(f"Skipping {url} as it has already been downloaded", 10)
await self.manager.progress_manager.download_progress.add_previously_completed()
@@ -165,6 +165,9 @@ class Crawler(ABC):
async def create_title(self, title: str, album_id: Optional[str], thread_id: Optional[str]) -> str:
"""Creates the title for the scrape item"""
+ if not title:
+ title = "Untitled"
+
title = title.strip()
if self.manager.config_manager.settings_data['Download_Options']['include_album_id_in_folder_name']:
if album_id:
diff --git a/cyberdrop_dl/utils/database/tables/history_table.py b/cyberdrop_dl/utils/database/tables/history_table.py
index 7669fc491..cc9d94712 100644
--- a/cyberdrop_dl/utils/database/tables/history_table.py
+++ b/cyberdrop_dl/utils/database/tables/history_table.py
@@ -9,7 +9,7 @@ from yarl import URL
from cyberdrop_dl.utils.database.table_definitions import create_history, create_fixed_history
if TYPE_CHECKING:
- from cyberdrop_dl.utils.dataclasses.url_objects import MediaItem
+ from cyberdrop_dl.utils.dataclasses.url_objects import MediaItem, ScrapeItem
async def get_db_path(url: URL, referer: str = "") -> str:
@@ -45,7 +45,7 @@ class HistoryTable:
await self.fix_bunkr_v4_entries()
await self.fix_primary_keys()
- async def check_complete(self, domain: str, url: URL) -> bool:
+ async def check_complete(self, domain: str, url: URL, referer: URL) -> bool:
"""Checks whether an individual file has completed given its domain and url path"""
if self.ignore_history:
return False
@@ -56,7 +56,12 @@ class HistoryTable:
cursor = await self.db_conn.cursor()
result = await cursor.execute("""SELECT completed FROM media WHERE domain = ? and url_path = ?""", (domain, url_path))
sql_file_check = await result.fetchone()
- return sql_file_check and sql_file_check[0] != 0
+ if sql_file_check and sql_file_check[0] != 0:
+ # Update the referer if it has changed so that check_complete_by_referer can work
+ await cursor.execute("""UPDATE media SET referer = ? WHERE domain = ? and url_path = ?""", (str(referer), domain, url_path))
+ await self.db_conn.commit()
+ return True
+ return False
async def check_complete_by_referer(self, domain: str, referer: URL) -> bool:
"""Checks whether an individual file has completed given its domain and url path"""
diff --git a/cyberdrop_dl/utils/utilities.py b/cyberdrop_dl/utils/utilities.py
index fddb0ee33..7a49b5f38 100644
--- a/cyberdrop_dl/utils/utilities.py
+++ b/cyberdrop_dl/utils/utilities.py
@@ -1,5 +1,6 @@
from __future__ import annotations
+import asyncio
import logging
import os
import re
@@ -71,6 +72,10 @@ def error_handling_wrapper(func):
await log(f"Scrape Failed: {link} (Invalid Content Type Received)", 40)
await self.manager.log_manager.write_scrape_error_log(link, " Invalid Content Type Received")
await self.manager.progress_manager.scrape_stats_progress.add_failure("Invalid Content Type")
+ except asyncio.TimeoutError:
+ await log(f"Scrape Failed: {link} (Timeout)", 40)
+ await self.manager.log_manager.write_scrape_error_log(link, " Timeout")
+ await self.manager.progress_manager.scrape_stats_progress.add_failure("Timeout")
except Exception as e:
if hasattr(e, 'status'):
if hasattr(e, 'message'):
diff --git a/pyproject.toml b/pyproject.toml
index a1e7cfeb4..00a60cec0 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -1,6 +1,6 @@
[tool.poetry]
name = "cyberdrop-dl"
-version = "5.1.15"
+version = "5.1.16"
description = "Bulk downloader for multiple file hosts"
authors = ["Jules Winnfield <[email protected]>"]
readme = "README.md"