Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[nhentai] add 'artist' extractor (#1950) #1955

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/supportedsites.md
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,7 @@ Consider all sites to be NSFW unless otherwise known.
<tr>
<td>nhentai</td>
<td>https://nhentai.net/</td>
<td>Favorites, Galleries, Search Results</td>
<td>Artists, Favorites, Galleries, Search Results</td>
<td></td>
</tr>
<tr>
Expand Down
31 changes: 31 additions & 0 deletions gallery_dl/extractor/nhentai.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,3 +157,34 @@ def _pagination(self, params):
if 'class="next"' not in page:
return
params["page"] += 1

class NhentaiArtistExtractor(NhentaiBase, Extractor):
"""Extractor for nhentai artists"""
subcategory = "artist"
pattern = r"(?:https?://)?nhentai\.net/artist/([^/?#]+)/?(popular(?:-today|-week|-month)?)?(?:\?([^#]+))?"
test = ("https://nhentai.net/artist/ayane/",)

def __init__(self, match):
Extractor.__init__(self, match)
self.artist = match.group(1)
self.sort = match.group(2)
if self.sort is None:
self.sort = ""
self.params = text.parse_query(match.group(3))

def items(self):
data = {"_extractor": NhentaiGalleryExtractor}
for gallery_id in self._pagination(self.params):
url = "{}/g/{}/".format(self.root, gallery_id)
yield Message.Queue, url, data

def _pagination(self, params):
url = "{}/artist/{}/{}".format(self.root, self.artist, self.sort)
params["page"] = text.parse_int(params.get("page"), 1)

while True:
page = self.request(url, params=params).text
yield from text.extract_iter(page, 'href="/g/', '/')
if 'class="next"' not in page:
return
params["page"] += 1