2015-11-14 03:19:44 +01:00
|
|
|
# -*- coding: utf-8 -*-
|
|
|
|
|
2020-01-11 23:15:05 +01:00
|
|
|
# Copyright 2015-2020 Mike Fährmann
|
2015-11-14 03:19:44 +01:00
|
|
|
#
|
|
|
|
# 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.
|
|
|
|
|
2020-01-11 23:15:05 +01:00
|
|
|
"""Extractors for https://www.hentai-foundry.com/"""
|
2015-11-14 03:19:44 +01:00
|
|
|
|
|
|
|
from .common import Extractor, Message
|
2020-10-12 21:15:07 +02:00
|
|
|
from .. import text, util
|
|
|
|
|
2020-11-07 22:40:02 +01:00
|
|
|
BASE_PATTERN = r"(https?://)?(?:www\.)?hentai-foundry\.com"
|
2015-11-14 03:19:44 +01:00
|
|
|
|
2017-02-01 00:53:19 +01:00
|
|
|
|
2018-04-20 18:22:57 +02:00
|
|
|
class HentaifoundryExtractor(Extractor):
|
2018-09-20 16:24:49 +02:00
|
|
|
"""Base class for hentaifoundry extractors"""
|
2015-11-21 04:26:30 +01:00
|
|
|
category = "hentaifoundry"
|
2019-02-08 13:45:40 +01:00
|
|
|
directory_fmt = ("{category}", "{user}")
|
2015-11-21 04:26:30 +01:00
|
|
|
filename_fmt = "{category}_{index}_{title}.{extension}"
|
2018-01-30 22:49:16 +01:00
|
|
|
archive_fmt = "{index}"
|
2020-10-28 21:49:03 +01:00
|
|
|
cookiedomain = "www.hentai-foundry.com"
|
2018-04-20 18:22:57 +02:00
|
|
|
root = "https://www.hentai-foundry.com"
|
|
|
|
per_page = 25
|
2015-11-14 03:19:44 +01:00
|
|
|
|
2020-10-12 21:15:07 +02:00
|
|
|
def __init__(self, match):
|
2020-11-07 22:40:02 +01:00
|
|
|
self.root = (match.group(1) or "https://") + "www.hentai-foundry.com"
|
|
|
|
self.user = match.group(2)
|
2019-02-11 13:31:10 +01:00
|
|
|
Extractor.__init__(self, match)
|
2019-02-12 10:20:21 +01:00
|
|
|
self.page_url = ""
|
2018-04-20 18:22:57 +02:00
|
|
|
self.start_post = 0
|
2020-10-12 21:15:07 +02:00
|
|
|
self.start_page = 1
|
2015-11-14 03:19:44 +01:00
|
|
|
|
|
|
|
def items(self):
|
2020-10-12 21:15:07 +02:00
|
|
|
self._init_site_filters()
|
|
|
|
data = self.metadata()
|
2018-04-20 18:22:57 +02:00
|
|
|
|
2020-10-12 21:15:07 +02:00
|
|
|
for post_url in util.advance(self.posts(), self.start_post):
|
|
|
|
image = self._parse_post(post_url)
|
2015-11-14 03:19:44 +01:00
|
|
|
image.update(data)
|
2020-10-12 21:15:07 +02:00
|
|
|
yield Message.Directory, image
|
2020-01-11 23:15:05 +01:00
|
|
|
yield Message.Url, image["src"], image
|
2015-11-14 03:19:44 +01:00
|
|
|
|
2018-04-20 18:22:57 +02:00
|
|
|
def skip(self, num):
|
|
|
|
pages, posts = divmod(num, self.per_page)
|
|
|
|
self.start_page += pages
|
|
|
|
self.start_post += posts
|
|
|
|
return num
|
|
|
|
|
2020-10-12 21:15:07 +02:00
|
|
|
def metadata(self):
|
2018-09-22 17:38:09 +02:00
|
|
|
return {"user": self.user}
|
2018-04-20 18:22:57 +02:00
|
|
|
|
2020-10-12 21:15:07 +02:00
|
|
|
def posts(self):
|
|
|
|
return self._pagination(self.page_url)
|
|
|
|
|
|
|
|
def _pagination(self, url, begin='thumbTitle"><a href="', end='"'):
|
2018-09-22 17:38:09 +02:00
|
|
|
num = self.start_page
|
|
|
|
|
|
|
|
while True:
|
2020-10-12 21:15:07 +02:00
|
|
|
page = self.request("{}/page/{}".format(url, num)).text
|
2020-09-27 02:22:23 +02:00
|
|
|
yield from text.extract_iter(page, begin, end)
|
2018-04-20 18:22:57 +02:00
|
|
|
|
2018-09-22 17:38:09 +02:00
|
|
|
if 'class="pager"' not in page or 'class="last hidden"' in page:
|
|
|
|
return
|
|
|
|
num += 1
|
|
|
|
|
2020-10-12 21:15:07 +02:00
|
|
|
def _parse_post(self, path):
|
|
|
|
"""Collect url and metadata from an image post"""
|
2020-01-11 23:15:05 +01:00
|
|
|
url = text.urljoin(self.root, path)
|
|
|
|
page = self.request(url).text
|
|
|
|
extr = text.extract_from(page, page.index('id="picBox"'))
|
|
|
|
|
|
|
|
data = {
|
|
|
|
"title" : text.unescape(extr('class="imageTitle">', '<')),
|
|
|
|
"artist" : text.unescape(extr('/profile">', '<')),
|
|
|
|
"width" : text.parse_int(extr('width="', '"')),
|
|
|
|
"height" : text.parse_int(extr('height="', '"')),
|
|
|
|
"index" : text.parse_int(path.rsplit("/", 2)[1]),
|
2020-11-07 22:40:02 +01:00
|
|
|
"src" : text.urljoin(self.root, text.unescape(extr(
|
|
|
|
'src="', '"'))),
|
2020-01-11 23:15:05 +01:00
|
|
|
"description": text.unescape(text.remove_html(extr(
|
|
|
|
'>Description</div>', '</section>')
|
|
|
|
.replace("\r\n", "\n"), "", "")),
|
|
|
|
"ratings" : [text.unescape(r) for r in text.extract_iter(extr(
|
|
|
|
"class='ratings_box'", "</div>"), "title='", "'")],
|
|
|
|
"media" : text.unescape(extr("Media</b></td>\t\t<td>", "<")),
|
|
|
|
"date" : text.parse_datetime(extr("datetime='", "'")),
|
|
|
|
"views" : text.parse_int(extr("Views</b></td>\t\t<td>", "<")),
|
|
|
|
"tags" : text.split_html(extr(
|
|
|
|
"<td><b>Keywords</b></td>", "</tr>"))[::2],
|
|
|
|
"score" : text.parse_int(extr('Score</b></td>\t\t<td>', '<')),
|
|
|
|
}
|
|
|
|
|
|
|
|
return text.nameext_from_url(data["src"], data)
|
2018-04-20 18:22:57 +02:00
|
|
|
|
2020-10-12 21:15:07 +02:00
|
|
|
def _parse_story(self, html):
|
2020-09-27 02:22:23 +02:00
|
|
|
"""Collect url and metadata for a story"""
|
|
|
|
extr = text.extract_from(html)
|
|
|
|
data = {
|
|
|
|
"user" : self.user,
|
|
|
|
"title" : text.unescape(extr(
|
|
|
|
"<div class='titlebar'>", "</a>").rpartition(">")[2]),
|
|
|
|
"author" : text.unescape(extr('alt="', '"')),
|
|
|
|
"date" : text.parse_datetime(extr(
|
|
|
|
">Updated<", "</span>").rpartition(">")[2], "%B %d, %Y"),
|
|
|
|
"status" : extr("class='indent'>", "<"),
|
|
|
|
}
|
|
|
|
|
|
|
|
for c in ("Chapters", "Words", "Comments", "Views", "Rating"):
|
|
|
|
data[c.lower()] = text.parse_int(extr(
|
|
|
|
">" + c + ":</span>", "<").replace(",", ""))
|
|
|
|
|
|
|
|
data["description"] = text.unescape(extr(
|
|
|
|
"class='storyDescript'>", "<div"))
|
|
|
|
path = extr('href="', '"')
|
|
|
|
data["src"] = self.root + path
|
|
|
|
data["index"] = text.parse_int(path.rsplit("/", 2)[1])
|
|
|
|
data["ratings"] = [text.unescape(r) for r in text.extract_iter(extr(
|
|
|
|
"class='ratings_box'", "</div>"), "title='", "'")]
|
|
|
|
|
|
|
|
return text.nameext_from_url(data["src"], data)
|
|
|
|
|
2020-10-12 21:15:07 +02:00
|
|
|
def _init_site_filters(self):
|
2015-11-14 14:13:02 +01:00
|
|
|
"""Set site-internal filters to show all images"""
|
2020-10-12 21:15:07 +02:00
|
|
|
url = self.root + "/?enterAgree=1"
|
2020-10-28 21:49:03 +01:00
|
|
|
self.request(url, method="HEAD")
|
|
|
|
|
|
|
|
csrf_token = self.session.cookies.get(
|
|
|
|
"YII_CSRF_TOKEN", domain=self.cookiedomain)
|
|
|
|
if not csrf_token:
|
|
|
|
self.log.warning("Unable to update site content filters")
|
|
|
|
return
|
2020-10-12 21:15:07 +02:00
|
|
|
|
|
|
|
url = self.root + "/site/filters"
|
2018-09-20 16:24:49 +02:00
|
|
|
data = {
|
2020-10-12 21:15:07 +02:00
|
|
|
"rating_nudity" : "3",
|
|
|
|
"rating_violence" : "3",
|
|
|
|
"rating_profanity": "3",
|
|
|
|
"rating_racism" : "3",
|
|
|
|
"rating_sex" : "3",
|
|
|
|
"rating_spoilers" : "3",
|
|
|
|
"rating_yaoi" : "1",
|
|
|
|
"rating_yuri" : "1",
|
|
|
|
"rating_teen" : "1",
|
|
|
|
"rating_guro" : "1",
|
|
|
|
"rating_furry" : "1",
|
|
|
|
"rating_beast" : "1",
|
|
|
|
"rating_male" : "1",
|
|
|
|
"rating_female" : "1",
|
|
|
|
"rating_futa" : "1",
|
|
|
|
"rating_other" : "1",
|
|
|
|
"rating_scat" : "1",
|
|
|
|
"rating_incest" : "1",
|
|
|
|
"rating_rape" : "1",
|
|
|
|
"filter_media" : "A",
|
|
|
|
"filter_order" : "date_new",
|
|
|
|
"filter_type" : "0",
|
|
|
|
"YII_CSRF_TOKEN" : text.unquote(text.extract(
|
2020-10-28 21:49:03 +01:00
|
|
|
csrf_token, "%22", "%22")[0]),
|
2015-11-14 03:19:44 +01:00
|
|
|
}
|
2018-09-20 16:24:49 +02:00
|
|
|
self.request(url, method="POST", data=data)
|
2015-11-29 00:01:49 +01:00
|
|
|
|
2018-09-20 16:24:49 +02:00
|
|
|
|
|
|
|
class HentaifoundryUserExtractor(HentaifoundryExtractor):
|
2020-10-12 21:15:07 +02:00
|
|
|
"""Extractor for a hentaifoundry user profile"""
|
2018-09-20 16:24:49 +02:00
|
|
|
subcategory = "user"
|
2020-10-22 23:12:59 +02:00
|
|
|
pattern = BASE_PATTERN + r"/user/([^/?#]+)/profile"
|
2020-09-24 00:48:08 +02:00
|
|
|
test = ("https://www.hentai-foundry.com/user/Tenpura/profile",)
|
|
|
|
|
|
|
|
def items(self):
|
2020-10-12 21:15:07 +02:00
|
|
|
root = self.root
|
2020-09-27 02:22:23 +02:00
|
|
|
user = "/user/" + self.user
|
2020-09-24 00:48:08 +02:00
|
|
|
return self._dispatch_extractors((
|
2020-10-04 22:53:23 +02:00
|
|
|
(HentaifoundryPicturesExtractor ,
|
2020-10-12 21:15:07 +02:00
|
|
|
root + "/pictures" + user),
|
2020-09-27 02:22:23 +02:00
|
|
|
(HentaifoundryScrapsExtractor,
|
2020-10-12 21:15:07 +02:00
|
|
|
root + "/pictures" + user + "/scraps"),
|
2020-09-27 02:22:23 +02:00
|
|
|
(HentaifoundryStoriesExtractor,
|
2020-10-12 21:15:07 +02:00
|
|
|
root + "/stories" + user),
|
2020-09-24 00:48:08 +02:00
|
|
|
(HentaifoundryFavoriteExtractor,
|
2020-10-12 21:15:07 +02:00
|
|
|
root + user + "/faves/pictures"),
|
2020-10-04 22:53:23 +02:00
|
|
|
), ("pictures",))
|
2020-09-24 00:48:08 +02:00
|
|
|
|
|
|
|
|
2020-10-04 22:53:23 +02:00
|
|
|
class HentaifoundryPicturesExtractor(HentaifoundryExtractor):
|
|
|
|
"""Extractor for all pictures of a hentaifoundry user"""
|
|
|
|
subcategory = "pictures"
|
2020-10-22 23:12:59 +02:00
|
|
|
pattern = BASE_PATTERN + r"/pictures/user/([^/?#]+)(?:/page/(\d+))?/?$"
|
2019-02-08 13:45:40 +01:00
|
|
|
test = (
|
2018-09-20 16:24:49 +02:00
|
|
|
("https://www.hentai-foundry.com/pictures/user/Tenpura", {
|
|
|
|
"url": "ebbc981a85073745e3ca64a0f2ab31fab967fc28",
|
|
|
|
}),
|
2019-02-08 13:45:40 +01:00
|
|
|
("https://www.hentai-foundry.com/pictures/user/Tenpura/page/3"),
|
|
|
|
)
|
2018-09-19 21:04:50 +02:00
|
|
|
|
|
|
|
def __init__(self, match):
|
2020-10-12 21:15:07 +02:00
|
|
|
HentaifoundryExtractor.__init__(self, match)
|
2019-02-12 10:20:21 +01:00
|
|
|
self.page_url = "{}/pictures/user/{}".format(self.root, self.user)
|
2018-09-19 21:04:50 +02:00
|
|
|
|
|
|
|
|
2018-09-20 16:24:49 +02:00
|
|
|
class HentaifoundryScrapsExtractor(HentaifoundryExtractor):
|
2020-10-12 21:15:07 +02:00
|
|
|
"""Extractor for scraps of a hentaifoundry user"""
|
2018-09-20 16:24:49 +02:00
|
|
|
subcategory = "scraps"
|
2019-02-08 13:45:40 +01:00
|
|
|
directory_fmt = ("{category}", "{user}", "Scraps")
|
2020-10-22 23:12:59 +02:00
|
|
|
pattern = BASE_PATTERN + r"/pictures/user/([^/?#]+)/scraps"
|
2019-02-08 13:45:40 +01:00
|
|
|
test = (
|
2018-09-20 16:24:49 +02:00
|
|
|
("https://www.hentai-foundry.com/pictures/user/Evulchibi/scraps", {
|
2019-09-08 11:33:35 +02:00
|
|
|
"url": "7cd9c6ec6258c4ab8c44991f7731be82337492a7",
|
2018-09-20 16:24:49 +02:00
|
|
|
}),
|
2019-02-08 13:45:40 +01:00
|
|
|
("https://www.hentai-foundry.com"
|
|
|
|
"/pictures/user/Evulchibi/scraps/page/3"),
|
|
|
|
)
|
2018-09-20 16:24:49 +02:00
|
|
|
|
|
|
|
def __init__(self, match):
|
2020-10-12 21:15:07 +02:00
|
|
|
HentaifoundryExtractor.__init__(self, match)
|
2019-02-12 10:20:21 +01:00
|
|
|
self.page_url = "{}/pictures/user/{}/scraps".format(
|
|
|
|
self.root, self.user)
|
2018-09-20 16:24:49 +02:00
|
|
|
|
2018-09-19 21:04:50 +02:00
|
|
|
|
2018-09-22 21:22:53 +02:00
|
|
|
class HentaifoundryFavoriteExtractor(HentaifoundryExtractor):
|
2020-10-12 21:15:07 +02:00
|
|
|
"""Extractor for favorite images of a hentaifoundry user"""
|
2018-09-22 21:22:53 +02:00
|
|
|
subcategory = "favorite"
|
2019-02-08 13:45:40 +01:00
|
|
|
directory_fmt = ("{category}", "{user}", "Favorites")
|
2018-09-22 21:22:53 +02:00
|
|
|
archive_fmt = "f_{user}_{index}"
|
2020-10-22 23:12:59 +02:00
|
|
|
pattern = BASE_PATTERN + r"/user/([^/?#]+)/faves/pictures"
|
2019-02-08 13:45:40 +01:00
|
|
|
test = (
|
2018-09-22 21:22:53 +02:00
|
|
|
("https://www.hentai-foundry.com/user/Tenpura/faves/pictures", {
|
|
|
|
"url": "56f9ae2e89fe855e9fe1da9b81e5ec6212b0320b",
|
|
|
|
}),
|
|
|
|
("https://www.hentai-foundry.com"
|
2019-02-08 13:45:40 +01:00
|
|
|
"/user/Tenpura/faves/pictures/page/3"),
|
|
|
|
)
|
2018-09-22 21:22:53 +02:00
|
|
|
|
|
|
|
def __init__(self, match):
|
2020-10-12 21:15:07 +02:00
|
|
|
HentaifoundryExtractor.__init__(self, match)
|
2019-02-12 10:20:21 +01:00
|
|
|
self.page_url = "{}/user/{}/faves/pictures".format(
|
|
|
|
self.root, self.user)
|
2018-09-22 21:22:53 +02:00
|
|
|
|
|
|
|
|
2018-09-22 21:28:16 +02:00
|
|
|
class HentaifoundryRecentExtractor(HentaifoundryExtractor):
|
|
|
|
"""Extractor for 'Recent Pictures' on hentaifoundry.com"""
|
|
|
|
subcategory = "recent"
|
2019-02-08 13:45:40 +01:00
|
|
|
directory_fmt = ("{category}", "Recent Pictures", "{date}")
|
2018-09-22 21:28:16 +02:00
|
|
|
archive_fmt = "r_{index}"
|
2020-10-12 21:15:07 +02:00
|
|
|
pattern = BASE_PATTERN + r"/pictures/recent/(\d\d\d\d-\d\d-\d\d)"
|
2020-11-07 22:40:02 +01:00
|
|
|
test = ("https://www.hentai-foundry.com/pictures/recent/2018-09-20", {
|
2020-10-22 23:12:59 +02:00
|
|
|
"pattern": r"https://pictures.hentai-foundry.com/[^/]/[^/?#]+/\d+/",
|
2020-01-11 23:15:05 +01:00
|
|
|
"range": "20-30",
|
|
|
|
})
|
2018-09-22 21:28:16 +02:00
|
|
|
|
|
|
|
def __init__(self, match):
|
2020-10-12 21:15:07 +02:00
|
|
|
HentaifoundryExtractor.__init__(self, match)
|
|
|
|
self.page_url = "{}/pictures/recent/{}".format(self.root, self.user)
|
2018-09-22 21:28:16 +02:00
|
|
|
|
2020-10-12 21:15:07 +02:00
|
|
|
def metadata(self):
|
|
|
|
return {"date": self.user}
|
2018-09-22 21:28:16 +02:00
|
|
|
|
|
|
|
|
|
|
|
class HentaifoundryPopularExtractor(HentaifoundryExtractor):
|
|
|
|
"""Extractor for popular images on hentaifoundry.com"""
|
|
|
|
subcategory = "popular"
|
2019-02-08 13:45:40 +01:00
|
|
|
directory_fmt = ("{category}", "Popular Pictures")
|
2018-09-22 21:28:16 +02:00
|
|
|
archive_fmt = "p_{index}"
|
2020-10-12 21:15:07 +02:00
|
|
|
pattern = BASE_PATTERN + r"/pictures/popular()"
|
2020-11-07 22:40:02 +01:00
|
|
|
test = ("https://www.hentai-foundry.com/pictures/popular", {
|
2020-10-22 23:12:59 +02:00
|
|
|
"pattern": r"https://pictures.hentai-foundry.com/[^/]/[^/?#]+/\d+/",
|
2020-01-11 23:15:05 +01:00
|
|
|
"range": "20-30",
|
|
|
|
})
|
2018-09-22 21:28:16 +02:00
|
|
|
|
|
|
|
def __init__(self, match):
|
2020-10-12 21:15:07 +02:00
|
|
|
HentaifoundryExtractor.__init__(self, match)
|
2019-02-12 10:20:21 +01:00
|
|
|
self.page_url = self.root + "/pictures/popular"
|
2018-09-22 21:28:16 +02:00
|
|
|
|
|
|
|
|
2018-04-20 18:22:57 +02:00
|
|
|
class HentaifoundryImageExtractor(HentaifoundryExtractor):
|
2016-09-12 10:20:57 +02:00
|
|
|
"""Extractor for a single image from hentaifoundry.com"""
|
2015-11-30 01:11:13 +01:00
|
|
|
subcategory = "image"
|
2020-11-07 22:40:02 +01:00
|
|
|
pattern = (r"(https?://)?(?:www\.|pictures\.)?hentai-foundry\.com"
|
2020-10-22 23:12:59 +02:00
|
|
|
r"/(?:pictures/user|[^/?#])/([^/?#]+)/(\d+)")
|
2019-02-08 13:45:40 +01:00
|
|
|
test = (
|
2018-09-20 16:24:49 +02:00
|
|
|
(("https://www.hentai-foundry.com"
|
2018-04-20 18:22:57 +02:00
|
|
|
"/pictures/user/Tenpura/407501/shimakaze"), {
|
2017-04-20 13:20:41 +02:00
|
|
|
"url": "fbf2fd74906738094e2575d2728e8dc3de18a8a3",
|
2017-04-10 10:50:34 +02:00
|
|
|
"content": "91bf01497c39254b6dfb234a18e8f01629c77fd1",
|
2020-01-11 23:15:05 +01:00
|
|
|
"keyword": {
|
|
|
|
"artist" : "Tenpura",
|
2020-02-23 16:48:30 +01:00
|
|
|
"date" : "dt:2016-02-22 14:41:19",
|
2020-01-11 23:15:05 +01:00
|
|
|
"description": "Thank you!",
|
|
|
|
"height" : 700,
|
|
|
|
"index" : 407501,
|
|
|
|
"media" : "Other digital art",
|
|
|
|
"ratings": ["Sexual content", "Contains female nudity"],
|
|
|
|
"score" : int,
|
|
|
|
"tags" : ["kancolle", "kantai", "collection", "shimakaze"],
|
|
|
|
"title" : "shimakaze",
|
|
|
|
"user" : "Tenpura",
|
|
|
|
"views" : int,
|
|
|
|
"width" : 495,
|
|
|
|
},
|
2016-12-31 00:51:06 +01:00
|
|
|
}),
|
2020-11-07 22:40:02 +01:00
|
|
|
("http://www.hentai-foundry.com/pictures/user/Tenpura/407501/", {
|
|
|
|
"pattern": "http://pictures.hentai-foundry.com/t/Tenpura/407501/",
|
|
|
|
}),
|
|
|
|
("https://www.hentai-foundry.com/pictures/user/Tenpura/407501/"),
|
2019-02-08 13:45:40 +01:00
|
|
|
("https://pictures.hentai-foundry.com"
|
|
|
|
"/t/Tenpura/407501/Tenpura-407501-shimakaze.png"),
|
|
|
|
)
|
2020-10-12 21:15:07 +02:00
|
|
|
skip = Extractor.skip
|
2015-11-29 00:01:49 +01:00
|
|
|
|
|
|
|
def __init__(self, match):
|
2020-10-12 21:15:07 +02:00
|
|
|
HentaifoundryExtractor.__init__(self, match)
|
2020-11-07 22:40:02 +01:00
|
|
|
self.index = match.group(3)
|
2015-11-29 00:01:49 +01:00
|
|
|
|
2018-09-20 16:24:49 +02:00
|
|
|
def items(self):
|
2018-09-22 17:38:09 +02:00
|
|
|
post_url = "{}/pictures/user/{}/{}/?enterAgree=1".format(
|
|
|
|
self.root, self.user, self.index)
|
2020-10-12 21:15:07 +02:00
|
|
|
image = self._parse_post(post_url)
|
|
|
|
image["user"] = self.user
|
|
|
|
yield Message.Directory, image
|
|
|
|
yield Message.Url, image["src"], image
|
2020-09-27 02:22:23 +02:00
|
|
|
|
|
|
|
|
|
|
|
class HentaifoundryStoriesExtractor(HentaifoundryExtractor):
|
2020-10-12 21:15:07 +02:00
|
|
|
"""Extractor for stories of a hentaifoundry user"""
|
2020-09-27 02:22:23 +02:00
|
|
|
subcategory = "stories"
|
2020-10-12 21:15:07 +02:00
|
|
|
archive_fmt = "s_{index}"
|
2020-10-22 23:12:59 +02:00
|
|
|
pattern = BASE_PATTERN + r"/stories/user/([^/?#]+)(?:/page/(\d+))?/?$"
|
2020-09-27 02:22:23 +02:00
|
|
|
test = ("https://www.hentai-foundry.com/stories/user/SnowWolf35", {
|
|
|
|
"count": ">= 35",
|
|
|
|
"keyword": {
|
|
|
|
"author" : "SnowWolf35",
|
|
|
|
"chapters" : int,
|
|
|
|
"comments" : int,
|
|
|
|
"date" : "type:datetime",
|
|
|
|
"description": str,
|
|
|
|
"index" : int,
|
|
|
|
"rating" : int,
|
|
|
|
"ratings" : list,
|
|
|
|
"status" : "re:(Inc|C)omplete",
|
|
|
|
"title" : str,
|
|
|
|
"user" : "SnowWolf35",
|
|
|
|
"views" : int,
|
|
|
|
"words" : int,
|
|
|
|
},
|
|
|
|
})
|
|
|
|
|
|
|
|
def items(self):
|
2020-10-12 21:15:07 +02:00
|
|
|
self._init_site_filters()
|
|
|
|
for story_html in util.advance(self.stories(), self.start_post):
|
|
|
|
story = self._parse_story(story_html)
|
2020-09-27 02:22:23 +02:00
|
|
|
yield Message.Directory, story
|
|
|
|
yield Message.Url, story["src"], story
|
|
|
|
|
2020-10-12 21:15:07 +02:00
|
|
|
def stories(self):
|
|
|
|
url = "{}/stories/user/{}".format(self.root, self.user)
|
|
|
|
return self._pagination(url, '<div class="storyRow">', '</tr></table>')
|
|
|
|
|
2020-09-27 02:22:23 +02:00
|
|
|
|
|
|
|
class HentaifoundryStoryExtractor(HentaifoundryExtractor):
|
|
|
|
"""Extractor for a hentaifoundry story"""
|
|
|
|
subcategory = "story"
|
2020-10-12 21:15:07 +02:00
|
|
|
archive_fmt = "s_{index}"
|
2020-10-22 23:12:59 +02:00
|
|
|
pattern = BASE_PATTERN + r"/stories/user/([^/?#]+)/(\d+)"
|
2020-09-27 02:22:23 +02:00
|
|
|
test = (("https://www.hentai-foundry.com/stories/user/SnowWolf35"
|
|
|
|
"/26416/Overwatch-High-Chapter-Voting-Location"), {
|
|
|
|
"url": "5a67cfa8c3bf7634c8af8485dd07c1ea74ee0ae8",
|
|
|
|
"keyword": {"title": "Overwatch High Chapter Voting Location"},
|
|
|
|
})
|
2020-10-12 21:15:07 +02:00
|
|
|
skip = Extractor.skip
|
2020-09-27 02:22:23 +02:00
|
|
|
|
|
|
|
def __init__(self, match):
|
2020-10-12 21:15:07 +02:00
|
|
|
HentaifoundryExtractor.__init__(self, match)
|
2020-11-07 22:40:02 +01:00
|
|
|
self.index = match.group(3)
|
2020-09-27 02:22:23 +02:00
|
|
|
|
|
|
|
def items(self):
|
|
|
|
story_url = "{}/stories/user/{}/{}/x?enterAgree=1".format(
|
|
|
|
self.root, self.user, self.index)
|
2020-10-12 21:15:07 +02:00
|
|
|
story = self._parse_story(self.request(story_url).text)
|
2020-09-27 02:22:23 +02:00
|
|
|
yield Message.Directory, story
|
|
|
|
yield Message.Url, story["src"], story
|