mirror of
https://github.com/mikf/gallery-dl.git
synced 2024-11-23 11:12:40 +01:00
[hentaicosplays] use GalleryExtractor (#1473)
This commit is contained in:
parent
d88e34f17e
commit
dddda7d0e7
@ -4,29 +4,23 @@
|
||||
# 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)
|
||||
"""
|
||||
"""Extractors for https://hentai-cosplays.com/
|
||||
(also works for hentai-img.com and porn-images-xxx.com)"""
|
||||
|
||||
from .common import Extractor, Message
|
||||
from .common import GalleryExtractor
|
||||
from .. import text
|
||||
|
||||
|
||||
class HentaicosplaysGalleryExtractor(Extractor):
|
||||
"""
|
||||
Extractor for image galleries from hentai-cosplays.com, hentai-img.com,
|
||||
and porn-images-xxx.com
|
||||
"""
|
||||
class HentaicosplaysGalleryExtractor(GalleryExtractor):
|
||||
"""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+)?"
|
||||
pattern = r"((?:https?://)?(?:\w{2}\.)?" \
|
||||
r"(hentai-cosplays|hentai-img|porn-images-xxx)\.com)/" \
|
||||
r"(?:image|story)/([\w-]+)"
|
||||
test = (
|
||||
("https://hentai-cosplays.com/image/---devilism--tide-kurihara-/", {
|
||||
"pattern": r"https://static\d?.hentai-cosplays.com/upload/"
|
||||
@ -58,27 +52,21 @@ class HentaicosplaysGalleryExtractor(Extractor):
|
||||
)
|
||||
|
||||
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)
|
||||
root, self.site, path = match.groups()
|
||||
self.root = text.ensure_http_scheme(root)
|
||||
url = "{}/story/{}/".format(self.root, path)
|
||||
GalleryExtractor.__init__(self, match, url)
|
||||
|
||||
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,
|
||||
"title": text.unescape(title.rpartition(" Story Viewer - ")[0]),
|
||||
"site" : self.site,
|
||||
}
|
||||
|
||||
def images(self, page):
|
||||
return [
|
||||
(url, None)
|
||||
for url in text.extract_iter(
|
||||
page, '<amp-img class="auto-style" src="', '"')
|
||||
]
|
||||
|
Loading…
Reference in New Issue
Block a user