From 8b2024a1a552ad0d97b135c28fb616eec80ac0a9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20F=C3=A4hrmann?= Date: Tue, 27 Dec 2016 15:24:42 +0100 Subject: [PATCH] [hentaifoundry] support direct links to images --- gallery_dl/extractor/hentaifoundry.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/gallery_dl/extractor/hentaifoundry.py b/gallery_dl/extractor/hentaifoundry.py index 9c64b913..b6719108 100644 --- a/gallery_dl/extractor/hentaifoundry.py +++ b/gallery_dl/extractor/hentaifoundry.py @@ -109,8 +109,9 @@ class HentaifoundryImageExtractor(Extractor): subcategory = "image" directory_fmt = ["{category}", "{artist}"] filename_fmt = "{category}_{index}_{title}.{extension}" - pattern = [(r"(?:https?://)?(?:www\.)?hentai-foundry\.com/pictures/user/" - r"([^/]+)/(\d+)/[^/]+")] + pattern = [(r"(?:https?://)?(?:www\.|pictures\.)?hentai-foundry\.com/" + r"(?:pictures/user/([^/]+)/(\d+)" + r"|[^/]/([^/]+)/(\d+))")] test = [("http://www.hentai-foundry.com/pictures/user/Tenpura/340854/notitle", { "url": "f3c0739bf86543697deabbed4bf99eb95a04582b", "keyword": "96217c5becc1369c36dafa201c3c208518de8f1f", @@ -119,9 +120,8 @@ class HentaifoundryImageExtractor(Extractor): def __init__(self, match): Extractor.__init__(self) - self.url = match.group(0) - self.artist = match.group(1) - self.index = match.group(2) + self.artist = match.group(1) or match.group(3) + self.index = match.group(2) or match.group(4) def items(self): url, data = self.get_image_metadata() @@ -131,7 +131,9 @@ class HentaifoundryImageExtractor(Extractor): def get_image_metadata(self): """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: raise exception.NotFoundError("image") page = response.text