Skip to content

Bulk asynchronous downloader for multiple file hosts

fix: type checking errors

NTFSvolume0a77482ea423
diff --git a/cyberdrop_dl/clients/errors.py b/cyberdrop_dl/clients/errors.py
index 5a88d3dca..f86f8f79d 100644
--- a/cyberdrop_dl/clients/errors.py
+++ b/cyberdrop_dl/clients/errors.py
@@ -1,11 +1,12 @@
+from __future__ import annotations
from typing import TYPE_CHECKING, Optional
from http import HTTPStatus
+from yarl import URL
+from pathlib import Path
if TYPE_CHECKING:
- from cyberdrop_dl.scraper.crawler import ScrapeItem
from yaml.constructor import ConstructorError
- from yarl import URL
- from pathlib import Path
+ from cyberdrop_dl.scraper.crawler import ScrapeItem
class CDLBaseException(Exception):
"""Base exception for cyberdrop-dl errors"""
@@ -14,7 +15,7 @@ class CDLBaseException(Exception):
self.ui_message = ui_message
self.message = message if message else ui_message
self.origin = origin
- if isinstance(origin, ScrapeItem):
+ if not isinstance(origin, (URL, Path)):
self.origin = origin.parents[0] if origin.parents else None
super().__init__(self.message)
if status:
diff --git a/cyberdrop_dl/clients/scraper_client.py b/cyberdrop_dl/clients/scraper_client.py
index 364a31ba7..4f349b8a5 100644
--- a/cyberdrop_dl/clients/scraper_client.py
+++ b/cyberdrop_dl/clients/scraper_client.py
@@ -11,7 +11,7 @@ from bs4 import BeautifulSoup
from multidict import CIMultiDictProxy
from yarl import URL
-from cyberdrop_dl.clients.errors import InvalidContentTypeFailure, DDOSGuardFailure, ScrapeFailure
+from cyberdrop_dl.clients.errors import InvalidContentTypeFailure, DDOSGuardFailure
from cyberdrop_dl.utils.utilities import log
if TYPE_CHECKING:
diff --git a/cyberdrop_dl/downloader/downloader.py b/cyberdrop_dl/downloader/downloader.py
index 55c389d38..495effcf0 100644
--- a/cyberdrop_dl/downloader/downloader.py
+++ b/cyberdrop_dl/downloader/downloader.py
@@ -79,8 +79,11 @@ def retry(f):
e_log_message = "See Log for Details"
e_ui_failure = "Unknown"
+ await log(f"{self.log_prefix} failed: {media_item.url} with error: {e_log_detail}", 40, exc_info = exc_info)
+
+ if not exc_info:
+ await log(f"{self.log_prefix} failed: {media_item.url} with error: {e_log_detail}", 40)
await self.attempt_task_removal(media_item)
- await log(f"{self.log_prefix} failed: {media_item.url} with error: {e_log_detail}", 40, exc_info = exc_info)
await self.manager.log_manager.write_download_error_log(media_item.url, e_log_message, e_origin)
await self.manager.progress_manager.download_stats_progress.add_failure(e_ui_failure)
await self.manager.progress_manager.download_progress.add_failed()
@@ -238,5 +241,5 @@ class Downloader:
raise DownloadFailure(status=getattr(err, "status", type(err).__name__), message=message)
async def is_failed(self, status: int):
- return any((await is_4xx_client_error(status) and status != HTTPStatus.TOO_MANY_REQUESTS),
- status in (HTTPStatus.SERVICE_UNAVAILABLE, HTTPStatus.BAD_GATEWAY, CustomHTTPStatus.WEB_SERVER_IS_DOWN))
\ No newline at end of file
+ return any((await is_4xx_client_error(status) and status != HTTPStatus.TOO_MANY_REQUESTS,
+ status in (HTTPStatus.SERVICE_UNAVAILABLE, HTTPStatus.BAD_GATEWAY, CustomHTTPStatus.WEB_SERVER_IS_DOWN)))
\ No newline at end of file
diff --git a/cyberdrop_dl/utils/utilities.py b/cyberdrop_dl/utils/utilities.py
index 7ae19f5f8..7e9d2f7e0 100644
--- a/cyberdrop_dl/utils/utilities.py
+++ b/cyberdrop_dl/utils/utilities.py
@@ -85,8 +85,10 @@ def error_handling_wrapper(func):
e_log_detail = str(err)
e_log_message = "See Log for Details"
e_ui_failure = "Unknown"
-
- await log(f"Scrape Failed: {link} ({e_log_detail})", 40, exc_info = exc_info)
+ await log(f"Scrape Failed: {link} ({e_log_detail})", 40, exc_info = True)
+
+ if not exc_info:
+ await log(f"Scrape Failed: {link} ({e_log_detail})", 40)
await self.manager.log_manager.write_scrape_error_log(link, e_log_message, e_origin )
await self.manager.progress_manager.scrape_stats_progress.add_failure(e_ui_failure)