[hentaifoundry] support direct links to images
This commit is contained in:
@@ -109,8 +109,9 @@ class HentaifoundryImageExtractor(Extractor):
|
|||||||
subcategory = "image"
|
subcategory = "image"
|
||||||
directory_fmt = ["{category}", "{artist}"]
|
directory_fmt = ["{category}", "{artist}"]
|
||||||
filename_fmt = "{category}_{index}_{title}.{extension}"
|
filename_fmt = "{category}_{index}_{title}.{extension}"
|
||||||
pattern = [(r"(?:https?://)?(?:www\.)?hentai-foundry\.com/pictures/user/"
|
pattern = [(r"(?:https?://)?(?:www\.|pictures\.)?hentai-foundry\.com/"
|
||||||
r"([^/]+)/(\d+)/[^/]+")]
|
r"(?:pictures/user/([^/]+)/(\d+)"
|
||||||
|
r"|[^/]/([^/]+)/(\d+))")]
|
||||||
test = [("http://www.hentai-foundry.com/pictures/user/Tenpura/340854/notitle", {
|
test = [("http://www.hentai-foundry.com/pictures/user/Tenpura/340854/notitle", {
|
||||||
"url": "f3c0739bf86543697deabbed4bf99eb95a04582b",
|
"url": "f3c0739bf86543697deabbed4bf99eb95a04582b",
|
||||||
"keyword": "96217c5becc1369c36dafa201c3c208518de8f1f",
|
"keyword": "96217c5becc1369c36dafa201c3c208518de8f1f",
|
||||||
@@ -119,9 +120,8 @@ class HentaifoundryImageExtractor(Extractor):
|
|||||||
|
|
||||||
def __init__(self, match):
|
def __init__(self, match):
|
||||||
Extractor.__init__(self)
|
Extractor.__init__(self)
|
||||||
self.url = match.group(0)
|
self.artist = match.group(1) or match.group(3)
|
||||||
self.artist = match.group(1)
|
self.index = match.group(2) or match.group(4)
|
||||||
self.index = match.group(2)
|
|
||||||
|
|
||||||
def items(self):
|
def items(self):
|
||||||
url, data = self.get_image_metadata()
|
url, data = self.get_image_metadata()
|
||||||
@@ -131,7 +131,9 @@ class HentaifoundryImageExtractor(Extractor):
|
|||||||
|
|
||||||
def get_image_metadata(self):
|
def get_image_metadata(self):
|
||||||
"""Collect metadata for an image"""
|
"""Collect metadata for an image"""
|
||||||
response = self.session.get(self.url + "?enterAgree=1")
|
url = "http://www.hentai-foundry.com/pictures/user/{}/{}".format(
|
||||||
|
self.artist, self.index)
|
||||||
|
response = self.session.get(url + "?enterAgree=1")
|
||||||
if response.status_code == 404:
|
if response.status_code == 404:
|
||||||
raise exception.NotFoundError("image")
|
raise exception.NotFoundError("image")
|
||||||
page = response.text
|
page = response.text
|
||||||
|
|||||||
Reference in New Issue
Block a user