mirror of
https://github.com/mikf/gallery-dl.git
synced 2024-11-23 11:12:40 +01:00
[paheal] improve metadata extraction (#2641)
- unescape 'tags' - add 'date', 'source', and 'uploader' for single posts
This commit is contained in:
parent
603af48265
commit
61fa9b535a
@ -1,6 +1,6 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Copyright 2018-2020 Mike Fährmann
|
||||
# Copyright 2018-2022 Mike Fährmann
|
||||
#
|
||||
# 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
|
||||
@ -41,6 +41,29 @@ class PahealExtractor(Extractor):
|
||||
def get_posts(self):
|
||||
"""Return an iterable containing data of all relevant posts"""
|
||||
|
||||
def _extract_post(self, post_id):
|
||||
url = "{}/post/view/{}".format(self.root, post_id)
|
||||
extr = text.extract_from(self.request(url).text)
|
||||
|
||||
post = {
|
||||
"id" : post_id,
|
||||
"tags" : extr(": ", "<"),
|
||||
"md5" : extr("/_thumbs/", "/"),
|
||||
"file_url": extr("id='main_image' src='", "'"),
|
||||
"uploader": text.unquote(extr(
|
||||
"class='username' href='/user/", "'")),
|
||||
"date" : text.parse_datetime(
|
||||
extr("datetime='", "'"), "%Y-%m-%dT%H:%M:%S%z"),
|
||||
"source" : text.extract(
|
||||
extr(">Source Link<", "</td>"), "href='", "'")[0],
|
||||
}
|
||||
|
||||
dimensions, size, ext = extr("Info</th><td>", ">").split(" // ")
|
||||
post["width"], _, post["height"] = dimensions.partition("x")
|
||||
post["size"] = text.parse_bytes(size[:-1])
|
||||
|
||||
return (post,)
|
||||
|
||||
|
||||
class PahealTagExtractor(PahealExtractor):
|
||||
"""Extractor for images from rule34.paheal.net by search-tags"""
|
||||
@ -87,8 +110,9 @@ class PahealTagExtractor(PahealExtractor):
|
||||
width, _, height = dimensions.partition("x")
|
||||
|
||||
return {
|
||||
"id": pid, "md5": md5, "tags": tags, "file_url": url,
|
||||
"id": pid, "md5": md5, "file_url": url,
|
||||
"width": width, "height": height,
|
||||
"tags": text.unescape(tags),
|
||||
"size": text.parse_bytes(size[:-1]),
|
||||
}
|
||||
|
||||
@ -98,31 +122,44 @@ class PahealPostExtractor(PahealExtractor):
|
||||
subcategory = "post"
|
||||
pattern = (r"(?:https?://)?(?:rule34|rule63|cosplay)\.paheal\.net"
|
||||
r"/post/view/(\d+)")
|
||||
test = ("https://rule34.paheal.net/post/view/481609", {
|
||||
test = (
|
||||
("https://rule34.paheal.net/post/view/481609", {
|
||||
"pattern": r"https://tulip\.paheal\.net/_images"
|
||||
r"/bbdc1c33410c2cdce7556c7990be26b7/481609%20-%20"
|
||||
r"Azumanga_Daioh%20Osaka%20Vuvuzela%20inanimate\.jpg",
|
||||
"keyword": "abe7c1220ba5601f9639aa79fbb9689674ec8f5c",
|
||||
"content": "7b924bcf150b352ac75c9d281d061e174c851a11",
|
||||
})
|
||||
"keyword": {
|
||||
"date": "dt:2010-06-17 15:40:23",
|
||||
"extension": "jpg",
|
||||
"file_url": "re:https://tulip.paheal.net/_images/bbdc1c33410c",
|
||||
"filename": "481609 - Azumanga_Daioh Osaka Vuvuzela inanimate",
|
||||
"height": 660,
|
||||
"id": 481609,
|
||||
"md5": "bbdc1c33410c2cdce7556c7990be26b7",
|
||||
"size": 157389,
|
||||
"source": None,
|
||||
"tags": "Azumanga_Daioh Osaka Vuvuzela inanimate",
|
||||
"uploader": "CaptainButtface",
|
||||
"width": 614,
|
||||
},
|
||||
}),
|
||||
("https://rule34.paheal.net/post/view/488534", {
|
||||
"keyword": {
|
||||
"date": "dt:2010-06-25 13:51:17",
|
||||
"height": 800,
|
||||
"md5": "b39edfe455a0381110c710d6ed2ef57d",
|
||||
"size": 758989,
|
||||
"source": "http://www.furaffinity.net/view/4057821/",
|
||||
"tags": "Vuvuzela inanimate thelost-dragon",
|
||||
"uploader": "leacheate_soup",
|
||||
"width": 1200,
|
||||
},
|
||||
}),
|
||||
)
|
||||
|
||||
def __init__(self, match):
|
||||
PahealExtractor.__init__(self, match)
|
||||
self.post_id = match.group(1)
|
||||
|
||||
def get_posts(self):
|
||||
url = "{}/post/view/{}".format(self.root, self.post_id)
|
||||
page = self.request(url).text
|
||||
|
||||
tags , pos = text.extract(page, ": ", "<")
|
||||
md5 , pos = text.extract(page, "/_thumbs/", "/", pos)
|
||||
url , pos = text.extract(page, "id='main_image' src='", "'", pos)
|
||||
width , pos = text.extract(page, "data-width=", " ", pos)
|
||||
height, pos = text.extract(page, "data-height=", " ", pos)
|
||||
|
||||
return ({
|
||||
"id": self.post_id, "md5": md5, "tags": tags, "file_url": url,
|
||||
"size" : 0,
|
||||
"width" : width.strip("'\""),
|
||||
"height": height.strip("'\""),
|
||||
},)
|
||||
return self._extract_post(self.post_id)
|
||||
|
Loading…
Reference in New Issue
Block a user