[kemonoparty] add 'type' metadata field (#1556)

'file', 'attachment', or 'inline'
This commit is contained in:
Mike Fährmann
2021-05-15 01:12:07 +02:00
parent 17b0ccb071
commit 2b5d80862e

View File

@@ -35,12 +35,17 @@ class KemonopartyExtractor(Extractor):
for post in self.posts(): for post in self.posts():
files = [] files = []
if post["file"]: append = files.append
files.append(post["file"]) file = post["file"]
if post["attachments"]:
files.extend(post["attachments"]) if file:
file["type"] = "file"
append(file)
for attachment in post["attachments"]:
attachment["type"] = "attachment"
append(attachment)
for path in find_inline(post["content"] or ""): for path in find_inline(post["content"] or ""):
files.append({"path": path, "name": path}) append({"path": path, "name": path, "type": "inline"})
post["date"] = text.parse_datetime( post["date"] = text.parse_datetime(
post["published"], "%a, %d %b %Y %H:%M:%S %Z") post["published"], "%a, %d %b %Y %H:%M:%S %Z")