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

Loading…
Cancel
Save