1
0
mirror of https://github.com/mikf/gallery-dl.git synced 2024-11-22 02:32:33 +01:00

[danbooru] provide 'tags' as list (#4942)

keep the old 'tag_string' values around, similar to sankaku

a lot of repeat code ...
would be a lot less bad if "".split(" ") returned an empty list
This commit is contained in:
Mike Fährmann 2023-12-21 14:39:38 +01:00
parent fbebc58189
commit 627ed794a2
No known key found for this signature in database
GPG Key ID: 5680CA389D365A88
2 changed files with 144 additions and 0 deletions

View File

@ -72,6 +72,25 @@ class DanbooruExtractor(BaseExtractor):
post["date"] = text.parse_datetime(
post["created_at"], "%Y-%m-%dT%H:%M:%S.%f%z")
post["tags"] = (
post["tag_string"].split(" ")
if post["tag_string"] else ())
post["tags_artist"] = (
post["tag_string_artist"].split(" ")
if post["tag_string_artist"] else ())
post["tags_character"] = (
post["tag_string_character"].split(" ")
if post["tag_string_character"] else ())
post["tags_copyright"] = (
post["tag_string_copyright"].split(" ")
if post["tag_string_copyright"] else ())
post["tags_general"] = (
post["tag_string_general"].split(" ")
if post["tag_string_general"] else ())
post["tags_meta"] = (
post["tag_string_meta"].split(" ")
if post["tag_string_meta"] else ())
if post["extension"] == "zip":
if self.ugoira:
post["frames"] = self._ugoira_frames(post)

View File

@ -75,7 +75,132 @@ __tests__ = (
"#class" : danbooru.DanbooruPostExtractor,
"#sha1_content": "5e255713cbf0a8e0801dc423563c34d896bb9229",
"approver_id": None,
"bit_flags": 0,
"created_at": "2008-08-12T00:46:05.385-04:00",
"date": "dt:2008-08-12 04:46:05",
"down_score": 0,
"extension": "jpg",
"fav_count": 9,
"file_ext": "jpg",
"file_size": 358232,
"file_url": "https://cdn.donmai.us/original/ac/8e/ac8e3b92ea328ce9cf7211e69c905bf9.jpg",
"filename": "ac8e3b92ea328ce9cf7211e69c905bf9",
"has_active_children": False,
"has_children": False,
"has_large": True,
"has_visible_children": False,
"id": 294929,
"image_height": 687,
"image_width": 895,
"is_banned": False,
"is_deleted": False,
"is_flagged": False,
"is_pending": False,
"large_file_url": "https://cdn.donmai.us/sample/ac/8e/sample-ac8e3b92ea328ce9cf7211e69c905bf9.jpg",
"last_comment_bumped_at": None,
"last_commented_at": None,
"last_noted_at": None,
"md5": "ac8e3b92ea328ce9cf7211e69c905bf9",
"media_asset": dict,
"parent_id": None,
"pixiv_id": 1129835,
"preview_file_url": "https://cdn.donmai.us/180x180/ac/8e/ac8e3b92ea328ce9cf7211e69c905bf9.jpg",
"rating": "s",
"score": 1,
"source": "https://i.pximg.net/img-original/img/2008/07/09/16/10/23/1129835_p0.jpg",
"subcategory": "post",
"tag_count": 32,
"tag_count_artist": 1,
"tag_count_character": 3,
"tag_count_copyright": 3,
"tag_count_general": 23,
"tag_count_meta": 2,
"tag_string": "2boys bat_(animal) batman batman_(series) black_bodysuit bodysuit bonocho brown_eyes closed_mouth collared_shirt commentary_request copyright_name dc_comics expressionless facepaint glasgow_smile heath_ledger joker_(dc) male_focus multiple_boys outline outstretched_arm parted_lips photoshop_(medium) pink_shirt shirt sketch smile the_dark_knight upper_body white_outline wing_collar",
"tag_string_artist": "bonocho",
"tag_string_character": "batman heath_ledger joker_(dc)",
"tag_string_copyright": "batman_(series) dc_comics the_dark_knight",
"tag_string_general": "2boys bat_(animal) black_bodysuit bodysuit brown_eyes closed_mouth collared_shirt copyright_name expressionless facepaint glasgow_smile male_focus multiple_boys outline outstretched_arm parted_lips pink_shirt shirt sketch smile upper_body white_outline wing_collar",
"tag_string_meta": "commentary_request photoshop_(medium)",
"tags": [
"2boys",
"bat_(animal)",
"batman",
"batman_(series)",
"black_bodysuit",
"bodysuit",
"bonocho",
"brown_eyes",
"closed_mouth",
"collared_shirt",
"commentary_request",
"copyright_name",
"dc_comics",
"expressionless",
"facepaint",
"glasgow_smile",
"heath_ledger",
"joker_(dc)",
"male_focus",
"multiple_boys",
"outline",
"outstretched_arm",
"parted_lips",
"photoshop_(medium)",
"pink_shirt",
"shirt",
"sketch",
"smile",
"the_dark_knight",
"upper_body",
"white_outline",
"wing_collar",
],
"tags_artist": [
"bonocho",
],
"tags_character": [
"batman",
"heath_ledger",
"joker_(dc)",
],
"tags_copyright": [
"batman_(series)",
"dc_comics",
"the_dark_knight",
],
"tags_general": [
"2boys",
"bat_(animal)",
"black_bodysuit",
"bodysuit",
"brown_eyes",
"closed_mouth",
"collared_shirt",
"copyright_name",
"expressionless",
"facepaint",
"glasgow_smile",
"male_focus",
"multiple_boys",
"outline",
"outstretched_arm",
"parted_lips",
"pink_shirt",
"shirt",
"sketch",
"smile",
"upper_body",
"white_outline",
"wing_collar",
],
"tags_meta": [
"commentary_request",
"photoshop_(medium)",
],
"up_score": range(1, 5),
"updated_at": "2022-07-11T23:42:31.881-04:00",
"uploader_id": 67005,
},
{