Merge pull request #3 from z4m1/main

URL parameters are now automatically removed and tag formatting has been enhanced.
main
EnsignMK 2024-03-26 16:02:06 +01:00 committed by GitHub
commit a341a7706b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 13 additions and 3 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={
@ -22,9 +25,9 @@ def fetchTags(ch, art_box, char_box):
format_tags = ""
if art_box:
if art_box and artist:
format_tags += artist
if char_box:
if char_box and char:
if not art_box:
format_tags += char
else:
@ -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