| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
"""Extractors for https://hentai-cosplay-xxx.com/ |
| 8 |
(also works for hentai-img-xxx.com and porn-image.com)""" |
| 9 |
|
| 10 |
from .common import BaseExtractor, GalleryExtractor |
| 11 |
from .. import text |
| 12 |
|
| 13 |
|
| 14 |
class HentaicosplaysExtractor(BaseExtractor): |
| 15 |
basecategory = "hentaicosplays" |
| 16 |
|
| 17 |
|
| 18 |
BASE_PATTERN = HentaicosplaysExtractor.update({ |
| 19 |
"hentaicosplay": { |
| 20 |
"root": "https://hentai-cosplay-xxx.com", |
| 21 |
"pattern": r"(?:\w\w\.)?hentai-cosplays?(?:-xxx)?\.com", |
| 22 |
}, |
| 23 |
"hentaiimg": { |
| 24 |
"root": "https://hentai-img-xxx.com", |
| 25 |
"pattern": r"(?:\w\w\.)?hentai-img(?:-xxx)?\.com", |
| 26 |
}, |
| 27 |
"pornimage": { |
| 28 |
"root": "https://porn-image.com", |
| 29 |
"pattern": r"(?:\w\w\.)?porn-images?(?:-xxx)?\.com", |
| 30 |
}, |
| 31 |
}) |
| 32 |
|
| 33 |
|
| 34 |
class HentaicosplaysGalleryExtractor( |
| 35 |
HentaicosplaysExtractor, GalleryExtractor): |
| 36 |
"""Extractor for image galleries from |
| 37 |
hentai-cosplay-xxx.com, hentai-img-xxx.com, and porn-image.com""" |
| 38 |
directory_fmt = ("{site}", "{title}") |
| 39 |
filename_fmt = "{filename}.{extension}" |
| 40 |
archive_fmt = "{title}_{filename}" |
| 41 |
pattern = BASE_PATTERN + r"/(?:image|story)/([\w-]+)" |
| 42 |
example = "https://hentai-cosplay-xxx.com/image/TITLE/" |
| 43 |
|
| 44 |
def __init__(self, match): |
| 45 |
BaseExtractor.__init__(self, match) |
| 46 |
self.slug = self.groups[-1] |
| 47 |
self.page_url = f"{self.root}/story/{self.slug}/" |
| 48 |
|
| 49 |
def _init(self): |
| 50 |
self.session.headers["Referer"] = self.page_url |
| 51 |
|
| 52 |
def metadata(self, page): |
| 53 |
title = text.extr(page, "<title>", "</title>") |
| 54 |
return { |
| 55 |
"title": text.unescape(title.rpartition(" Story Viewer - ")[0]), |
| 56 |
"slug" : self.slug, |
| 57 |
"site" : self.root.partition("://")[2].rpartition(".")[0], |
| 58 |
} |
| 59 |
|
| 60 |
def images(self, page): |
| 61 |
return [ |
| 62 |
(url.replace("http:", "https:", 1), None) |
| 63 |
for url in text.extract_iter( |
| 64 |
page, '<amp-img class="auto-style" src="', '"') |
| 65 |
] |