Image number selection design fix.
This commit is contained in:
parent
952c47f2ea
commit
dc3a45297b
|
@ -55,8 +55,7 @@ class BotInstance:
|
||||||
def get_random_image(self, max_page_number = 100):
|
def get_random_image(self, max_page_number = 100):
|
||||||
# Get a random page number
|
# Get a random page number
|
||||||
page_number = random.randint(0, max_page_number)
|
page_number = random.randint(0, max_page_number)
|
||||||
# Get a random image from the page
|
|
||||||
image_number = random.randint(0, 100)
|
|
||||||
# Get the JSON data from the API
|
# Get the JSON data from the API
|
||||||
if self.gelbooru_tags_exclude != "":
|
if self.gelbooru_tags_exclude != "":
|
||||||
gelbooru_tags_exclude = " " + self.gelbooru_tags_exclude
|
gelbooru_tags_exclude = " " + self.gelbooru_tags_exclude
|
||||||
|
@ -70,9 +69,9 @@ class BotInstance:
|
||||||
# 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:
|
||||||
return None, None, None, max_pages
|
return None, None, None, max_pages
|
||||||
# Make sure the image number is valid
|
|
||||||
if image_number > len(gelbooru_json['post']):
|
# Choose a random image from the page
|
||||||
image_number = random.randint(0, len(gelbooru_json['post']))
|
image_number = random.randint(0, len(gelbooru_json['post']))
|
||||||
|
|
||||||
# Save json to file for debugging
|
# Save json to file for debugging
|
||||||
#with open("gelbooru.json", "w") as gelbooru_json_file:
|
#with open("gelbooru.json", "w") as gelbooru_json_file:
|
||||||
|
|
Loading…
Reference in New Issue