Properly convert tags to url format.
This commit is contained in:
parent
ee7f0bb527
commit
007a8f6570
|
@ -10,6 +10,7 @@ import time
|
||||||
import traceback
|
import traceback
|
||||||
from PIL import Image
|
from PIL import Image
|
||||||
from io import BytesIO
|
from io import BytesIO
|
||||||
|
import urllib.parse
|
||||||
|
|
||||||
class BotInstance:
|
class BotInstance:
|
||||||
# Gelbooru API URL
|
# Gelbooru API URL
|
||||||
|
@ -46,7 +47,7 @@ class BotInstance:
|
||||||
gelbooru_tags_exclude = "+" + self.gelbooru_tags_exclude
|
gelbooru_tags_exclude = "+" + self.gelbooru_tags_exclude
|
||||||
else:
|
else:
|
||||||
gelbooru_tags_exclude = ""
|
gelbooru_tags_exclude = ""
|
||||||
gelbooru_json = requests.get(self.gelbooru_url + self.gelbooru_tags + '+' + gelbooru_tags_exclude + "&pid=" + str(page_number)).json()
|
gelbooru_json = requests.get(self.gelbooru_url + urllib.parse.quote_plus(self.gelbooru_tags) + '+' + urllib.parse.quote_plus(gelbooru_tags_exclude) + "&pid=" + str(page_number)).json()
|
||||||
max_pages = gelbooru_json['@attributes']['count'] // 100 + (1 if gelbooru_json['@attributes']['count'] % 100 != 0 else 0)
|
max_pages = gelbooru_json['@attributes']['count'] // 100 + (1 if gelbooru_json['@attributes']['count'] % 100 != 0 else 0)
|
||||||
# Make sure there are images on the page
|
# Make sure there are images on the page
|
||||||
if 'post' not in gelbooru_json:
|
if 'post' not in gelbooru_json:
|
||||||
|
|
Loading…
Reference in New Issue