[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():
files = []
if post["file"]:
files.append(post["file"])
if post["attachments"]:
files.extend(post["attachments"])
append = files.append
file = post["file"]
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 ""):
files.append({"path": path, "name": path})
append({"path": path, "name": path, "type": "inline"})
post["date"] = text.parse_datetime(
post["published"], "%a, %d %b %Y %H:%M:%S %Z")