Skip to content

Commit

Permalink
[fanbox] support pixiv redirects (closes #2122)
Browse files Browse the repository at this point in the history
  • Loading branch information
mikf committed Dec 25, 2021
1 parent 281828b commit 22b0433
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
21 changes: 21 additions & 0 deletions gallery_dl/extractor/fanbox.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,3 +280,24 @@ def __init__(self, match):

def posts(self):
return (self._get_post_data_from_id(self.post_id),)


class FanboxRedirectExtractor(Extractor):
"""Extractor for pixiv redirects to fanbox.cc"""
category = "fanbox"
subcategory = "redirect"
pattern = r"(?:https?://)?(?:www\.)?pixiv\.net/fanbox/creator/(\d+)"
test = ("https://www.pixiv.net/fanbox/creator/52336352", {
"pattern": FanboxCreatorExtractor.pattern,
})

def __init__(self, match):
Extractor.__init__(self, match)
self.user_id = match.group(1)

def items(self):
url = "https://www.pixiv.net/fanbox/creator/" + self.user_id
data = {"_extractor": FanboxCreatorExtractor}
response = self.request(
url, method="HEAD", allow_redirects=False, notfound="user")
yield Message.Queue, response.headers["Location"], data
3 changes: 3 additions & 0 deletions scripts/supportedsites.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,9 @@
"stash": "Sta.sh",
"watch-posts": "",
},
"fanbox": {
"redirect": "",
},
"hentaifoundry": {
"story": "",
},
Expand Down

0 comments on commit 22b0433

Please sign in to comment.