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

[hentaicosplays] Add extractor #1473

Merged
merged 2 commits into from
Apr 18, 2021
Merged
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
18 changes: 18 additions & 0 deletions docs/supportedsites.md
Original file line number Diff line number Diff line change
Expand Up @@ -193,12 +193,24 @@ Consider all sites to be NSFW unless otherwise known.
<td>Chapters, Manga</td>
<td></td>
</tr>
<tr>
<td>Hentai Cosplay</td>
<td>https://hentai-cosplays.com/</td>
<td>Galleries</td>
<td></td>
</tr>
<tr>
<td>Hentai Foundry</td>
<td>https://www.hentai-foundry.com/</td>
<td>Favorites, individual Images, Pictures, Popular Images, Recent Images, Scraps, Stories, User Profiles</td>
<td></td>
</tr>
<tr>
<td>Hentai Image</td>
<td>https://hentai-img.com/</td>
<td>Galleries</td>
<td></td>
</tr>
<tr>
<td>Hentai2Read</td>
<td>https://hentai2read.com/</td>
Expand Down Expand Up @@ -541,6 +553,12 @@ Consider all sites to be NSFW unless otherwise known.
<td>Posts, Timelines</td>
<td></td>
</tr>
<tr>
<td>Porn Image</td>
<td>https://porn-images-xxx.com/</td>
<td>Galleries</td>
<td></td>
</tr>
<tr>
<td>Pornhub</td>
<td>https://www.pornhub.com/</td>
Expand Down
1 change: 1 addition & 0 deletions gallery_dl/extractor/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
"gfycat",
"hbrowse",
"hentai2read",
"hentaicosplays",
"hentaifoundry",
"hentaifox",
"hentaihand",
Expand Down
84 changes: 84 additions & 0 deletions gallery_dl/extractor/hentaicosplays.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
# -*- coding: utf-8 -*-

# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 2 as
# published by the Free Software Foundation.

"""
Extractor for https://hentai-cosplays.com/
(also works for hentai-img.com and porn-images-xxx.com)
"""

from .common import Extractor, Message
from .. import text


class HentaicosplaysGalleryExtractor(Extractor):
"""
Extractor for image galleries from hentai-cosplays.com, hentai-img.com,
and porn-images-xxx.com
"""
category = "hentaicosplays"
subcategory = "gallery"
directory_fmt = ("{site}", "{title}")
filename_fmt = "{filename}.{extension}"
archive_fmt = "{title}_{filename}"
root = "https://hentai-cosplays.com"
pattern = r"(?:https?://)?(?:\w{2}.)?" \
r"(hentai-cosplays|hentai-img|porn-images-xxx)\.com/" \
r"(?:image|story)/([\w-]+)(/\w+/\d+)?"
test = (
("https://hentai-cosplays.com/image/---devilism--tide-kurihara-/", {
"pattern": r"https://static\d?.hentai-cosplays.com/upload/"
r"\d+/\d+/\d+/\d+.jpg$",
"keyword": {
"count": 18,
"site": "hentai-cosplays",
"title": str,
},
}),
("https://fr.porn-images-xxx.com/image/enako-enako-24/", {
"pattern": r"https://static\d?.porn-images-xxx.com/upload/"
r"\d+/\d+/\d+/\d+.jpg$",
"keyword": {
"count": 11,
"site": "porn-images-xxx",
"title": str,
},
}),
("https://ja.hentai-img.com/image/hollow-cora-502/", {
"pattern": r"https://static\d?.hentai-img.com/upload/"
r"\d+/\d+/\d+/\d+.jpg$",
"keyword": {
"count": 2,
"site": "hentai-img",
"title": str,
},
}),
)

def __init__(self, match):
Extractor.__init__(self, match)
self.site = match.group(1)
self.title = match.group(2)

def items(self):
url = "https://{}.com/story/{}/".format(
self.site, self.title)
page = self.request(url).text
data = self.metadata(page)
images = text.extract_iter(page,
'<amp-img class="auto-style" src="', '"')
yield Message.Version, 1
yield Message.Directory, data
for image in images:
yield Message.Url, image, text.nameext_from_url(image, data)

def metadata(self, page):
"""Collect metadata for extractor-job"""
title = text.extract(page, "<title>", "</title>")[0]
title, _, _ = title.rpartition(" Story Viewer - ")
return {
"title": title,
"site": self.site,
}
10 changes: 10 additions & 0 deletions scripts/supportedsites.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,12 @@
"hbrowse" : "HBrowse",
"hentai2read" : "Hentai2Read",
"hentaicafe" : "Hentai Cafe",
"hentaicosplays" : "Hentai Cosplay",
"hentaifoundry" : "Hentai Foundry",
"hentaifox" : "HentaiFox",
"hentaihand" : "HentaiHand",
"hentaihere" : "HentaiHere",
"hentaiimg" : "Hentai Image",
"hitomi" : "Hitomi.la",
"idolcomplex" : "Idol Complex",
"illusioncardsbooru": "Illusion Game Cards",
Expand Down Expand Up @@ -75,6 +77,7 @@
"nyafuu" : "Nyafuu Archive",
"paheal" : "rule #34",
"photovogue" : "PhotoVogue",
"pornimagesxxx" : "Porn Image",
"powermanga" : "PowerManga",
"readcomiconline": "Read Comic Online",
"rbt" : "RebeccaBlackTech",
Expand Down Expand Up @@ -324,6 +327,13 @@ def build_extractor_list():
default["e-hentai"] = default["exhentai"]
domains["e-hentai"] = domains["exhentai"].replace("x", "-")

# add hentai-cosplays sister sites (hentai-img, porn-images-xxx)
default["hentaiimg"] = default["hentaicosplays"]
domains["hentaiimg"] = "https://hentai-img.com/"

default["pornimagesxxx"] = default["hentaicosplays"]
domains["pornimagesxxx"] = "https://porn-images-xxx.com/"

return categories, domains


Expand Down