Bulk asynchronous downloader for multiple file hosts
Python asynciobunkrcyberdropdownloaderdropboxfilestergofilegoogle-drivemediafiremegamega-nzonedrivepatreonpawchivepinterestpixeldraintransfer-ittwitchtwittervk
refactor: move soup check up compare to original
datawhoresd5baabdb7cf6
diff --git a/cyberdrop_dl/managers/client_manager.py b/cyberdrop_dl/managers/client_manager.pyindex 70b5f47cc..dfa90ef4e 100644--- a/cyberdrop_dl/managers/client_manager.py+++ b/cyberdrop_dl/managers/client_manager.py@@ -131,15 +131,7 @@ class ClientManager:if download and headers.get("ETag") in DOWNLOAD_ERROR_ETAGS:message = DOWNLOAD_ERROR_ETAGS.get(headers.get("ETag"))raise DownloadError(HTTPStatus.NOT_FOUND, message=message, origin=origin)-- if any(domain in response.url.host for domain in ("gofile", "imgur")):- with contextlib.suppress(ContentTypeError):- JSON_Resp: dict = await response.json()- if "status" in JSON_Resp and "notFound" in JSON_Resp["status"]:- raise ScrapeError(HTTPStatus.NOT_FOUND, origin=origin)- if "data" in JSON_Resp and "error" in JSON_Resp["data"]:- raise ScrapeError(JSON_Resp["status"], JSON_Resp["data"]["error"], origin=origin)-+response_text = Nonewith contextlib.suppress(UnicodeDecodeError):response_text = await response.text()@@ -148,9 +140,20 @@ class ClientManager:soup = BeautifulSoup(response_text, "html.parser")if cls.check_ddos_guard(soup) or cls.check_cloudflare(soup):raise DDOSGuardError(origin=origin)+if HTTPStatus.OK <= status < HTTPStatus.BAD_REQUEST:return+ if any(domain in response.url.host for domain in ("gofile", "imgur")):+ with contextlib.suppress(ContentTypeError):+ JSON_Resp: dict = await response.json()+ if "status" in JSON_Resp and "notFound" in JSON_Resp["status"]:+ raise ScrapeError(HTTPStatus.NOT_FOUND, origin=origin)+ if "data" in JSON_Resp and "error" in JSON_Resp["data"]:+ raise ScrapeError(JSON_Resp["status"], JSON_Resp["data"]["error"], origin=origin)+++status = status if headers.get("Content-Type") else CustomHTTPStatus.IM_A_TEAPOTmessage = "No content-type in response header" if headers.get("Content-Type") else None