[gelbooru_v02] unescape categorized tags

This commit is contained in:
Mike Fährmann
2024-10-10 17:30:55 +02:00
parent f9e76ba6eb
commit 2818973981
5 changed files with 7 additions and 5 deletions

View File

@@ -97,6 +97,7 @@ class GelbooruV02Extractor(booru.BooruExtractor):
@staticmethod
def _prepare(post):
post["tags"] = post["tags"].strip()
post["date"] = text.parse_datetime(
post["created_at"], "%a %b %d %H:%M:%S %z %Y")
@@ -114,7 +115,7 @@ class GelbooruV02Extractor(booru.BooruExtractor):
pattern = re.compile(
r"tag-type-([^\"' ]+).*?[?;]tags=([^\"'&]+)", re.S)
for tag_type, tag_name in pattern.findall(tag_container):
tags[tag_type].append(text.unquote(tag_name))
tags[tag_type].append(text.unescape(text.unquote(tag_name)))
for key, value in tags.items():
post["tags_" + key] = " ".join(value)
@@ -178,7 +179,7 @@ class GelbooruV02Extractor(booru.BooruExtractor):
pattern = re.compile(
r'<a class="(?:tag-type-)?([^"]+).*?;tags=([^"&]+)')
for tag_type, tag_name in pattern.findall(tag_container):
tags[tag_type].append(text.unquote(tag_name))
tags[tag_type].append(text.unescape(text.unquote(tag_name)))
for key, value in tags.items():
post["tags_" + key] = " ".join(value)