Bulk asynchronous downloader for multiple file hosts
Python asynciobunkrcyberdropdownloaderdropboxfilestergofilegoogle-drivemediafiremegamega-nzonedrivepatreonpawchivepinterestpixeldraintransfer-ittwitchtwittervk
HTTP Status doesn't include IM_A_TEAPOT for all supported HTTP versions.
Jules-WinnfieldXa129b532e6ad
diff --git a/cyberdrop_dl/__init__.py b/cyberdrop_dl/__init__.pyindex d66d74451..4f750e6cd 100644--- a/cyberdrop_dl/__init__.py+++ b/cyberdrop_dl/__init__.py@@ -1 +1 @@-__version__ = "4.0.84"+__version__ = "4.0.85"diff --git a/cyberdrop_dl/client/client.py b/cyberdrop_dl/client/client.pyindex ef83aaa43..f31701ac4 100644--- a/cyberdrop_dl/client/client.py+++ b/cyberdrop_dl/client/client.py@@ -21,6 +21,7 @@ from .rate_limiting import AsyncRateLimiter, throttlefrom ..base_functions.base_functions import loggerfrom ..base_functions.data_classes import MediaItemfrom ..base_functions.error_classes import DownloadFailure, InvalidContentTypeFailure+from ..downloader.downloader_utils import CustomHTTPStatusclass Client:@@ -132,12 +133,12 @@ class DownloadSession:raise_for_status=True, proxy=proxy) as resp:content_type = resp.headers.get('Content-Type')if not content_type:- raise DownloadFailure(code=HTTPStatus.IM_A_TEAPOT, message="No content-type in response header")+ raise DownloadFailure(code=CustomHTTPStatus.IM_A_TEAPOT, message="No content-type in response header")if resp.url in self.bunkr_maintenance:raise DownloadFailure(code=HTTPStatus.SERVICE_UNAVAILABLE, message="Bunkr under maintenance")if 'text' in content_type.lower() or 'html' in content_type.lower():logger.debug("Server for %s is experiencing issues, you are being ratelimited, or cookies have expired", str(media.url))- raise DownloadFailure(code=HTTPStatus.IM_A_TEAPOT, message="Unexpectedly got text as response")+ raise DownloadFailure(code=CustomHTTPStatus.IM_A_TEAPOT, message="Unexpectedly got text as response")total = int(resp.headers.get('Content-Length', str(0))) + resume_pointfile.parent.mkdir(parents=True, exist_ok=True)@@ -160,12 +161,12 @@ class DownloadSession:raise_for_status=True, proxy=proxy) as resp:content_type = resp.headers.get('Content-Type')if not content_type:- raise DownloadFailure(code=HTTPStatus.IM_A_TEAPOT, message="No content-type in response header")+ raise DownloadFailure(code=CustomHTTPStatus.IM_A_TEAPOT, message="No content-type in response header")if resp.url in self.bunkr_maintenance:raise DownloadFailure(code=HTTPStatus.SERVICE_UNAVAILABLE, message="Bunkr under maintenance")if 'text' in content_type.lower() or 'html' in content_type.lower():logger.debug("Server for %s is experiencing issues, you are being ratelimited, or cookies have expired", str(media.url))- raise DownloadFailure(code=HTTPStatus.IM_A_TEAPOT, message="Unexpectedly got text as response")+ raise DownloadFailure(code=CustomHTTPStatus.IM_A_TEAPOT, message="Unexpectedly got text as response")total = int(resp.headers.get('Content-Length', str(0))) + resume_pointfile.parent.mkdir(parents=True, exist_ok=True)diff --git a/cyberdrop_dl/downloader/downloader_utils.py b/cyberdrop_dl/downloader/downloader_utils.pyindex e30074f94..5f6da0795 100644--- a/cyberdrop_dl/downloader/downloader_utils.py+++ b/cyberdrop_dl/downloader/downloader_utils.py@@ -8,8 +8,10 @@ from cyberdrop_dl.base_functions.base_functions import FILE_FORMATSfrom cyberdrop_dl.base_functions.data_classes import MediaItem-class CloudflareHTTPStatus:+class CustomHTTPStatus(IntEnum):WEB_SERVER_IS_DOWN = 521+ IM_A_TEAPOT = 418+async def allowed_filetype(media: MediaItem, block_images: bool, block_video: bool, block_audio: bool, block_other: bool):diff --git a/cyberdrop_dl/downloader/downloaders.py b/cyberdrop_dl/downloader/downloaders.pyindex f437e2571..195f1457a 100644--- a/cyberdrop_dl/downloader/downloaders.py+++ b/cyberdrop_dl/downloader/downloaders.py@@ -26,7 +26,7 @@ from cyberdrop_dl.client.client import Client, DownloadSessionfrom cyberdrop_dl.scraper.Scraper import ScrapeMapperfrom .downloader_utils import (- CloudflareHTTPStatus,+ CustomHTTPStatus,allowed_filetype,basic_auth,check_free_space,@@ -295,7 +295,7 @@ class Downloader:self.current_attempt.pop(url_path)await self.output_failed(media, e)return- if e.code == HTTPStatus.SERVICE_UNAVAILABLE or e.code == CloudflareHTTPStatus.WEB_SERVER_IS_DOWN:+ if e.code == HTTPStatus.SERVICE_UNAVAILABLE or e.code == CustomHTTPStatus.WEB_SERVER_IS_DOWN:if hasattr(e, "message"):if not e.message:e.message = "Web server is down"diff --git a/cyberdrop_dl/downloader/old_downloaders.py b/cyberdrop_dl/downloader/old_downloaders.pyindex 2bd5a7ca6..7d0089741 100644--- a/cyberdrop_dl/downloader/old_downloaders.py+++ b/cyberdrop_dl/downloader/old_downloaders.py@@ -25,7 +25,7 @@ from cyberdrop_dl.client.client import Client, DownloadSessionfrom cyberdrop_dl.scraper.Scraper import ScrapeMapperfrom .downloader_utils import (- CloudflareHTTPStatus,+ CustomHTTPStatus,allowed_filetype,basic_auth,check_free_space,@@ -244,7 +244,7 @@ class Old_Downloader:self.current_attempt.pop(url_path)await self.output_failed(media, e)return- if e.code == HTTPStatus.SERVICE_UNAVAILABLE or e.code == CloudflareHTTPStatus.WEB_SERVER_IS_DOWN:+ if e.code == HTTPStatus.SERVICE_UNAVAILABLE or e.code == CustomHTTPStatus.WEB_SERVER_IS_DOWN:if hasattr(e, "message"):if not e.message:e.message = "Web server is down"