[luscious] use new 'html' attribute in API responses

pull/13/head
Mike Fährmann 8 years ago
parent a8d716c043
commit 79ea457e24
No known key found for this signature in database
GPG Key ID: 5680CA389D365A88

@ -23,7 +23,7 @@ class LusciousAlbumExtractor(Extractor):
r"(?:pictures/album|albums)/([^/]+_(\d+))")]
test = [("https://luscious.net/c/hentai_manga/albums/okinami-no-koigokoro_277031/view/", {
"url": "7e4984a271a1072ac6483e4228a045895aff86f3",
"keyword": "026f4dc2e17aa59f97c9b9d8e68fc52b7c900603",
"keyword": "f3087f8e5c84e3f52fcd7d672cf0e6beae821837",
"content": "b3a747a6464509440bd0ff6d1267e6959f8d6ff3",
})]
@ -51,33 +51,35 @@ class LusciousAlbumExtractor(Extractor):
(None , '<p>Section:', ''),
("section" , '>', '<'),
(None , '<p>Language:', ''),
("language", '\n ', ' '),
("artist" , 'rtist: ', '\n'),
("language", '', ' '),
("artist" , 'rtist:</strong>\n', '\n'),
), values={"gallery-id": self.gid})
data["lang"] = iso639_1.language_to_code(data["language"])
_, pos = text.extract(page, 'ic_container', '')
self.imageurl = text.extract(page, '<a href="', '"', pos)[0]
data["artist"] = (data["artist"] or "").strip()
return data
def get_images(self):
"""Collect image-urls and -metadata"""
url = self.imageurl
num = 1
pnum = 1
inum = 1
apiurl = ("https://luscious.net/c/{}/pictures/album/{}/page/{{}}/.json"
"/?style=default").format(self.section, self.gpart)
while True:
page = self.request(urljoin("https://luscious.net", url)).text
url, pos = text.extract(page, '<link rel="next" href="', '"')
data = text.extract_all(page, (
(None , '<img id="single_picture"', ''),
("width" , 'width="', '"'),
("height", 'height="', '"'),
("name" , 'title="', '"'),
(None , 'image_option_icons', ''),
(None , '<a href="', '"'),
("image" , '<a href="', '"'),
), pos, values={"num": num})[0]
image = data["image"]
data["extension"] = image[image.rfind(".")+1:]
yield urljoin("https:", image), data
if url.startswith("/c/-/"):
data = self.request(apiurl.format(pnum)).json()
page = data["html"]
pos = 0
while True:
imgid, pos = text.extract(page, 'container" id="', '"', pos)
if not imgid:
break
url , pos = text.extract(page, 'data-src="', '"', pos)
title, pos = text.extract(page, 'alt="', '"', pos)
yield re.sub(r"\.\d+x\d+(\.[a-z]+)$", r"\1", url), {
"num": inum,
"name": title,
"extension": url[url.rfind(".")+1:],
"image-id": imgid[8:]
}
inum += 1
if data["paginator_complete"]:
return
num += 1
pnum += 1

Loading…
Cancel
Save