Skip to content

Bulk asynchronous downloader for multiple file hosts

refactor: handle GoFile token errors

NTFSvolumed7a7142a0524
diff --git a/cyberdrop_dl/crawlers/crawler.py b/cyberdrop_dl/crawlers/crawler.py
index 480a51f06..e5f5d2f37 100644
--- a/cyberdrop_dl/crawlers/crawler.py
+++ b/cyberdrop_dl/crawlers/crawler.py
@@ -294,8 +294,7 @@ class Crawler(HTTPMixin, HLSMixin, ABC):
):
yield resp
- @classmethod
- def __json_resp_check__(cls, json_resp: Any, resp: AbstractResponse[Any], /) -> None:
+ def __json_resp_check__(self, json_resp: Any, resp: AbstractResponse[Any], /) -> None:
"""Custom check for JSON responses.
This method is called automatically by the `HttpClient` when a JSON response is received from `cls.DOMAIN`
diff --git a/cyberdrop_dl/crawlers/gofile.py b/cyberdrop_dl/crawlers/gofile.py
index 77bcfc391..b4d05cf1f 100644
--- a/cyberdrop_dl/crawlers/gofile.py
+++ b/cyberdrop_dl/crawlers/gofile.py
@@ -100,10 +100,14 @@ class GoFileCrawler(Crawler):
return headers
- @classmethod
- def __json_resp_check__(cls, json_resp: dict[str, Any], _=None) -> None:
- if "notFound" in json_resp["status"]:
+ def __json_resp_check__(self, json_resp: dict[str, Any], _=None) -> None:
+ status = json_resp.get("status", "")
+ if "notFound" in status:
raise ScrapeError(404)
+ if "wrongToken" in status:
+ self._create_temp_account.clear()
+ msg = "Invalid API key" if self.config.auth.gofile.api_key else "token expired, please retry"
+ raise ScrapeError(401, msg)
async def __async_post_init__(self) -> None:
await self._get_credentials(_API_ENTRYPOINT)