[paheal] cleanup

This commit is contained in:
Mike Fährmann
2024-02-27 02:27:20 +01:00
parent ba062712ad
commit c8b591303f

View File

@@ -26,13 +26,13 @@ class PahealExtractor(Extractor):
data = self.get_metadata() data = self.get_metadata()
for post in self.get_posts(): for post in self.get_posts():
url = post["file_url"] post["id"] = text.parse_int(post["id"])
for key in ("id", "width", "height"):
post[key] = text.parse_int(post[key])
post["tags"] = text.unquote(post["tags"]) post["tags"] = text.unquote(post["tags"])
post["width"] = text.parse_int(post["width"])
post["height"] = text.parse_int(post["height"])
post.update(data) post.update(data)
yield Message.Directory, post yield Message.Directory, post
yield Message.Url, url, post yield Message.Url, post["file_url"], post
def get_metadata(self): def get_metadata(self):
"""Return general metadata""" """Return general metadata"""
@@ -114,17 +114,19 @@ class PahealTagExtractor(PahealExtractor):
tags, data, date = data.split("\n") tags, data, date = data.split("\n")
dimensions, size, ext = data.split(" // ") dimensions, size, ext = data.split(" // ")
tags = text.unescape(tags)
width, _, height = dimensions.partition("x") width, _, height = dimensions.partition("x")
height, _, duration = height.partition(", ") height, _, duration = height.partition(", ")
return { return {
"id": pid, "md5": md5, "file_url": url, "id" : pid,
"width": width, "height": height, "md5" : md5,
"duration": text.parse_float(duration[:-1]), "file_url" : url,
"tags": tags, "width" : width,
"size": text.parse_bytes(size[:-1]), "height" : height,
"date": text.parse_datetime(date, "%B %d, %Y; %H:%M"), "duration" : text.parse_float(duration[:-1]),
"tags" : text.unescape(tags),
"size" : text.parse_bytes(size[:-1]),
"date" : text.parse_datetime(date, "%B %d, %Y; %H:%M"),
"filename" : "{} - {}".format(pid, tags), "filename" : "{} - {}".format(pid, tags),
"extension": ext, "extension": ext,
} }