2021-04-18 20:28:00 +02:00
|
|
|
# -*- 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.
|
|
|
|
|
2021-04-18 20:30:39 +02:00
|
|
|
"""Extractors for https://hentai-cosplays.com/
|
|
|
|
(also works for hentai-img.com and porn-images-xxx.com)"""
|
2021-04-18 20:28:00 +02:00
|
|
|
|
2021-04-18 20:30:39 +02:00
|
|
|
from .common import GalleryExtractor
|
2021-04-18 20:28:00 +02:00
|
|
|
from .. import text
|
|
|
|
|
|
|
|
|
2021-04-18 20:30:39 +02:00
|
|
|
class HentaicosplaysGalleryExtractor(GalleryExtractor):
|
|
|
|
"""Extractor for image galleries from
|
|
|
|
hentai-cosplays.com, hentai-img.com, and porn-images-xxx.com"""
|
2021-04-18 20:28:00 +02:00
|
|
|
category = "hentaicosplays"
|
|
|
|
directory_fmt = ("{site}", "{title}")
|
|
|
|
filename_fmt = "{filename}.{extension}"
|
|
|
|
archive_fmt = "{title}_{filename}"
|
2021-04-18 20:30:39 +02:00
|
|
|
pattern = r"((?:https?://)?(?:\w{2}\.)?" \
|
|
|
|
r"(hentai-cosplays|hentai-img|porn-images-xxx)\.com)/" \
|
|
|
|
r"(?:image|story)/([\w-]+)"
|
2023-09-11 16:30:55 +02:00
|
|
|
example = "https://hentai-cosplays.com/image/TITLE/"
|
2021-04-18 20:28:00 +02:00
|
|
|
|
|
|
|
def __init__(self, match):
|
2021-04-19 16:28:01 +02:00
|
|
|
root, self.site, self.slug = match.groups()
|
2021-04-18 20:30:39 +02:00
|
|
|
self.root = text.ensure_http_scheme(root)
|
2021-04-19 16:28:01 +02:00
|
|
|
url = "{}/story/{}/".format(self.root, self.slug)
|
2021-04-18 20:30:39 +02:00
|
|
|
GalleryExtractor.__init__(self, match, url)
|
2023-07-25 20:09:44 +02:00
|
|
|
|
|
|
|
def _init(self):
|
|
|
|
self.session.headers["Referer"] = self.gallery_url
|
2021-04-18 20:28:00 +02:00
|
|
|
|
|
|
|
def metadata(self, page):
|
2022-11-04 23:39:38 +01:00
|
|
|
title = text.extr(page, "<title>", "</title>")
|
2021-04-18 20:28:00 +02:00
|
|
|
return {
|
2021-04-18 20:30:39 +02:00
|
|
|
"title": text.unescape(title.rpartition(" Story Viewer - ")[0]),
|
2021-04-19 16:28:01 +02:00
|
|
|
"slug" : self.slug,
|
2021-04-18 20:30:39 +02:00
|
|
|
"site" : self.site,
|
2021-04-18 20:28:00 +02:00
|
|
|
}
|
2021-04-18 20:30:39 +02:00
|
|
|
|
|
|
|
def images(self, page):
|
|
|
|
return [
|
2023-11-26 02:08:12 +01:00
|
|
|
(url.replace("http:", "https:", 1), None)
|
2021-04-18 20:30:39 +02:00
|
|
|
for url in text.extract_iter(
|
|
|
|
page, '<amp-img class="auto-style" src="', '"')
|
|
|
|
]
|