From c5aaa1de77265259f740c9b250de5bdd0bd171cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mike=20F=C3=A4hrmann?= Date: Sun, 26 Jul 2020 23:43:50 +0200 Subject: [PATCH] [inkbunny] simplify metadata structure (#283) Just put everything at the top level, instead of having a separate 'post' object. --- gallery_dl/extractor/inkbunny.py | 85 +++++++++++++++----------------- 1 file changed, 40 insertions(+), 45 deletions(-) diff --git a/gallery_dl/extractor/inkbunny.py b/gallery_dl/extractor/inkbunny.py index b74e33ea..bc39608f 100644 --- a/gallery_dl/extractor/inkbunny.py +++ b/gallery_dl/extractor/inkbunny.py @@ -19,8 +19,8 @@ BASE_PATTERN = r"(?:https?://)?(?:www\.)?inkbunny\.net" class InkbunnyExtractor(Extractor): """Base class for inkbunny extractors""" category = "inkbunny" - directory_fmt = ("{category}", "{post[username]!l}") - filename_fmt = "{post[submission_id]} {file_id} {post[title]}.{extension}" + directory_fmt = ("{category}", "{username!l}") + filename_fmt = "{submission_id} {file_id} {title}.{extension}" archive_fmt = "{file_id}" root = "https://inkbunny.net" @@ -38,6 +38,7 @@ class InkbunnyExtractor(Extractor): post["date"] = text.parse_datetime( post["create_datetime"] + "00", "%Y-%m-%d %H:%M:%S.%f%z") post["tags"] = [kw["keyword_name"] for kw in post["keywords"]] + post["ratings"] = [r["name"] for r in post["ratings"]] files = post["files"] for key in to_bool: @@ -46,14 +47,14 @@ class InkbunnyExtractor(Extractor): del post["keywords"] del post["files"] - yield Message.Directory, {"post": post} + yield Message.Directory, post for file in files: - file["post"] = post - file["deleted"] = (file["deleted"] == "t") - file["date"] = text.parse_datetime( + post.update(file) + post["deleted"] = (file["deleted"] == "t") + post["date"] = text.parse_datetime( file["create_datetime"] + "00", "%Y-%m-%d %H:%M:%S.%f%z") - text.nameext_from_url(file["file_name"], file) - yield Message.Url, file["file_url_full"], file + text.nameext_from_url(file["file_name"], post) + yield Message.Url, file["file_url_full"], post class InkbunnyUserExtractor(InkbunnyExtractor): @@ -66,52 +67,46 @@ class InkbunnyUserExtractor(InkbunnyExtractor): r"/\d+/\d+_soina_.+", "range": "20-50", "keyword": { - "date": "type:datetime", - "deleted": bool, - "file_id": "re:[0-9]+", - "filename": r"re:[0-9]+_soina_\w+", + "date" : "type:datetime", + "deleted" : bool, + "file_id" : "re:[0-9]+", + "filename" : r"re:[0-9]+_soina_\w+", "full_file_md5": "re:[0-9a-f]{32}", - "mimetype": str, - "submission_file_order": "re:[0-9]+", + "mimetype" : str, "submission_id": "re:[0-9]+", - "user_id": "20969", - "post": { - "comments_count" : "re:[0-9]+", - "date" : "type:datetime", - "deleted" : bool, - "digitalsales" : bool, - "favorite" : bool, - "favorites_count": "re:[0-9]+", - "forsale" : bool, - "friends_only" : bool, - "guest_block" : bool, - "hidden" : bool, - "pagecount" : "re:[0-9]+", - "pools" : list, - "pools_count" : int, - "printsales" : bool, - "public" : bool, - "rating_id" : "re:[0-9]+", - "rating_name" : str, - "ratings" : list, - "scraps" : bool, - "submission_id" : "re:[0-9]+", - "tags" : list, - "title" : str, - "type_name" : str, - "user_id" : "20969", - "username" : "soina", - "views" : str, - }, + "user_id" : "20969", + "comments_count" : "re:[0-9]+", + "deleted" : bool, + "digitalsales" : bool, + "favorite" : bool, + "favorites_count": "re:[0-9]+", + "forsale" : bool, + "friends_only" : bool, + "guest_block" : bool, + "hidden" : bool, + "pagecount" : "re:[0-9]+", + "pools" : list, + "pools_count" : int, + "printsales" : bool, + "public" : bool, + "rating_id" : "re:[0-9]+", + "rating_name" : str, + "ratings" : list, + "scraps" : bool, + "tags" : list, + "title" : str, + "type_name" : str, + "username" : "soina", + "views" : str, }, }), ("https://inkbunny.net/gallery/soina", { "range": "1-25", - "keyword": {"post": {"scraps": False}}, + "keyword": {"scraps": False}, }), ("https://inkbunny.net/scraps/soina", { "range": "1-25", - "keyword": {"post": {"scraps": True}}, + "keyword": {"scraps": True}, }), )