URL parameters are now automatically removed and tag formatting has been enhanced.

pull/3/head
z4m1 2024-03-19 03:15:14 +09:00
parent 45a271ce3f
commit ae61babb31
1 changed files with 11 additions and 1 deletions

View File

@ -11,6 +11,9 @@ def fetchTags(ch, art_box, char_box):
try:
if "danbooru.donmai.us/posts" not in ch:
return "unsupported url"
if "?" in ch:
pos = ch.find("?")
ch = ch[:pos]
url = ch + ".json"
with requests.get(url, headers={
@ -32,7 +35,14 @@ def fetchTags(ch, art_box, char_box):
format_tags += " " + general_tags
return format_tags.replace(" ", ", ")
format_tags = format_tags.replace(" ", ", ")
format_tags = format_tags.replace("_", " ")
format_tags = format_tags.replace("(", "\(")
format_tags = format_tags.replace(")", "\)")
format_tags = format_tags.replace("[", "\[")
format_tags = format_tags.replace("]", "\]")
return format_tags