Skip to content

Bulk asynchronous downloader for multiple file hosts

fix: handle undefined HTTP errors

NTFSvolume0bac6e4fb9ca
diff --git a/cyberdrop_dl/clients/errors.py b/cyberdrop_dl/clients/errors.py
index f86f8f79d..5a55a477b 100644
--- a/cyberdrop_dl/clients/errors.py
+++ b/cyberdrop_dl/clients/errors.py
@@ -15,7 +15,7 @@ class CDLBaseException(Exception):
self.ui_message = ui_message
self.message = message if message else ui_message
self.origin = origin
- if not isinstance(origin, (URL, Path)):
+ if origin and not isinstance(origin, (URL, Path)):
self.origin = origin.parents[0] if origin.parents else None
super().__init__(self.message)
if status:
@@ -52,13 +52,19 @@ class DDOSGuardFailure(CDLBaseException):
class DownloadFailure(CDLBaseException):
def __init__(self, status: int, message: Optional[str] = "Download Failure" , origin: Optional[ScrapeItem | URL] = None):
"""This error will be thrown when a request fails"""
- ui_message = f"{status} {HTTPStatus(status).phrase}" if isinstance (status, int) else status
+ try:
+ ui_message = f"{status} {HTTPStatus(status).phrase}" if isinstance (status, int) else status
+ except ValueError:
+ ui_message = status
super().__init__(ui_message, message = message, status = status, origin=origin)
class ScrapeFailure(CDLBaseException):
def __init__(self, status: int, message: Optional[str] = "Scrape Failure" , origin: Optional[ScrapeItem | URL] = None):
"""This error will be thrown when a scrape fails"""
- ui_message = f"{status} {HTTPStatus(status).phrase}" if isinstance (status, int) else status
+ try:
+ ui_message = f"{status} {HTTPStatus(status).phrase}" if isinstance (status, int) else status
+ except ValueError:
+ ui_message = status
super().__init__(ui_message, message = message, status = status, origin=origin)
class FailedLoginFailure(CDLBaseException):
diff --git a/cyberdrop_dl/ui/progress/statistic_progress.py b/cyberdrop_dl/ui/progress/statistic_progress.py
index cc07e35e3..66a4bf3a7 100644
--- a/cyberdrop_dl/ui/progress/statistic_progress.py
+++ b/cyberdrop_dl/ui/progress/statistic_progress.py
@@ -73,7 +73,10 @@ class DownloadStatsProgress:
"""Adds a failed file to the progress bar"""
self.failed_files += 1
if isinstance(failure_type, int):
- failure_type = f"{failure_type} {HTTPStatus(failure_type).phrase}"
+ try:
+ failure_type = f"{failure_type} {HTTPStatus(failure_type).phrase}"
+ except ValueError:
+ failure_type = f"{failure_type} HTTP Error"
if failure_type in self.failure_types:
self.progress.advance(self.failure_types[failure_type], 1)