Merge pull request #3 from z4m1/main
URL parameters are now automatically removed and tag formatting has been enhanced.main
commit
a341a7706b
|
|
@ -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
|
||||
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue