Skip to content

Commit

Permalink
Add error messages in lofter extractor
Browse files Browse the repository at this point in the history
  • Loading branch information
jakaline-dev committed Jan 21, 2025
1 parent 6ce310d commit b05fa66
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions gallery_dl/extractor/lofter.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ def _init(self):

def items(self):
for post in self.posts():
if post is None:
continue
if "post" in post:
post = post["post"]

Expand Down Expand Up @@ -129,6 +131,9 @@ def _call(self, endpoint, data):
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")
Expand All @@ -142,6 +147,9 @@ def _pagination(self, endpoint, params):

yield from posts

if data["offset"] < 0:
break

if params["offset"] + len(posts) < data["offset"]:
break
params["offset"] = data["offset"]

0 comments on commit b05fa66

Please sign in to comment.