Skip to content

Commit

Permalink
[fanbox] fix pagination (#5949, #5951, #5956)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikf committed Aug 7, 2024
1 parent 605f6fb commit b4733b7
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
16 changes: 14 additions & 2 deletions gallery_dl/extractor/fanbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -309,8 +309,20 @@ def __init__(self, match):
self.creator_id = match.group(1) or match.group(2)

def posts(self):
url = "https://api.fanbox.cc/post.listCreator?creatorId={}&limit=10"
return self._pagination(url.format(self.creator_id))
url = "https://api.fanbox.cc/post.paginateCreator?creatorId="
return self._pagination_creator(url + self.creator_id)

def _pagination_creator(self, url):
urls = self.request(url, headers=self.headers).json()["body"]
for url in urls:
url = text.ensure_http_scheme(url)
body = self.request(url, headers=self.headers).json()["body"]
for item in body:
try:
yield self._get_post_data(item["id"])
except Exception as exc:
self.log.warning("Skipping post %s (%s: %s)",
item["id"], exc.__class__.__name__, exc)


class FanboxPostExtractor(FanboxExtractor):
Expand Down
6 changes: 3 additions & 3 deletions test/results/fanbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,9 @@
"feeRequired": 300,
"plan" : {
"creatorId": "saki9184",
"fee" : 350,
"id" : "414274",
"title" : "涼宮ハルヒの憂鬱",
"fee" : 300,
"id" : "430208",
"title" : "ユーフォ、氷菓同人イラストR18",
},
},

Expand Down

0 comments on commit b4733b7

Please sign in to comment.