Преглед на файлове

improved danbooru loop to go the full length of the posts till a good post can be found.

tags/v2.1.0
Roxie Gibson преди 5 години
родител
ревизия
f7e20197f7
променени са 1 файла, в които са добавени 5 реда и са изтрити 4 реда
  1. +5
    -4
      roxbot/utils.py

+ 5
- 4
roxbot/utils.py Целия файл

@@ -227,9 +227,9 @@ async def danbooru_clone_api_req(channel, base_url, endpoint_url, cache=None, ta
return None

post = None
counter = 0
while counter < 50:
post = random.choice(posts)
while posts:
index = random.randint(0, len(posts)-1)
post = posts.pop(index)
if sfw:
if post["rating"] == "e" or post["rating"] == "q":
continue
@@ -239,7 +239,8 @@ async def danbooru_clone_api_req(channel, base_url, endpoint_url, cache=None, ta
if len(cache[cache_id]) > 10:
cache[cache_id].pop(0)
break
counter += 1
if not posts:
return None

url = post.get("file_url")
if not url:

Loading…
Отказ
Запис