better random question fetching

This commit is contained in:
Gordon Shumway 2019-03-06 17:30:40 -05:00 committed by GitHub
parent 2cdf7b5a38
commit 5a40529eed
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 2 additions and 2 deletions

View File

@ -131,7 +131,7 @@ class Jeopardy(callbacks.Plugin):
n = 0
while n < self.num:
if self.category == 'random':
data = requests.get("http://jservice.io/api/random?&count=100").json()
data = requests.get("http://jservice.io/api/random").json()
else:
data = requests.get("http://jservice.io/api/clues?&category={0}".format(self.category)).json()
cluecount = data[0]['category']['clues_count']
@ -145,7 +145,7 @@ class Jeopardy(callbacks.Plugin):
data.extend(requests.get("http://jservice.io/api/clues?&category={0}&offset=400".format(self.category)).json())
if cluecount > 500:
data.extend(requests.get("http://jservice.io/api/clues?&category={0}&offset=500".format(self.category)).json())
random.shuffle(data)
random.shuffle(data)
for item in data:
id = item['id']
question = re.sub('<[^<]+?>', '', unidecode(item['question'])).replace('\\', '').strip()