Add error messages in lofter extractor

This commit is contained in:
Jakaline
2025-01-21 21:38:20 +09:00
parent 6ce310d865
commit b05fa669bc

View File

@@ -23,6 +23,8 @@ class LofterExtractor(Extractor):
def items(self):
for post in self.posts():
if post is None:
continue
if "post" in post:
post = post["post"]
@@ -129,6 +131,9 @@ class LofterAPI():
url, method="POST", params=params, data=data)
info = response.json()
if info["meta"]["status"] == 4200:
raise exception.NotFoundError("blog")
if info["meta"]["status"] != 200:
self.extractor.log.debug("Server response: %s", info)
raise exception.StopExtraction("API request failed")
@@ -142,6 +147,9 @@ class LofterAPI():
yield from posts
if data["offset"] < 0:
break
if params["offset"] + len(posts) < data["offset"]:
break
params["offset"] = data["offset"]