fix e621 api compliance bugs

mistress
Luna 5 months ago
parent ee4ba47831
commit 019c5ad1b5

@ -84,6 +84,7 @@ class Post:
}
post.pop("up_score")
post.pop("down_score")
post["file"] = {"md5": post.pop("md5")}
post["flags"] = {
"pending": post.pop("is_pending"),
"flagged": post.pop("is_flagged"),
@ -109,7 +110,7 @@ class TagCategory(enum.IntEnum):
self.ARTIST: "artist",
self.COPYRIGHT: "copyright",
self.CHARACTER: "character",
self.METADATA: "metadata",
self.METADATA: "meta",
self.DEPRECATED: "deprecated",
self.SPECIES: "species",
self.LORE: "lore",
@ -164,15 +165,13 @@ async def posts_json():
post = Post(**rows[0])
post_json = post.to_json()
post_json["tags"] = {}
post_json["tags"] = {category.to_string(): [] for category in TagCategory}
for tag in post.tag_string.split(" "):
tag_rows = await app.db.execute_fetchall(
"select category from tags where name = ?", (tag,)
)
category = TagCategory(tag_rows[0][0])
category_str = category.to_string()
if category_str not in post_json["tags"]:
post_json["tags"][category_str] = []
post_json["tags"][category_str].append(tag)
return {"posts": [post_json]}

Loading…
Cancel
Save