safe setting added to jokes

This commit is contained in:
Justin 2023-07-17 14:38:58 +08:00 committed by GitHub
parent 8e5e100859
commit 6e68c350f1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -817,7 +817,7 @@ def updateJokes(api_key, logf):
with open('csv/jokes_settings.json', 'r') as f:
jokes_settings = json.load(f)
except:
jokes_settings = {"feature": "Jokes", "speed": "medium", "speed2": "medium", "animation": "up", "title": true, "categories": ["Any"], "blacklist": [], "amount": "5", "jokes": []}
jokes_settings = {"feature": "Jokes", "speed": "medium", "speed2": "medium", "animation": "up", "title": True, "safe": True, "categories": ["Any"], "blacklist": [], "amount": "5", "jokes": []}
try:
if 'Any' in jokes_settings['categories']:
categories = 'Any'
@ -830,6 +830,8 @@ def updateJokes(api_key, logf):
joke_url = 'https://v2.jokeapi.dev/joke/'+categories+'?amount='+amount
if blacklist != '':
joke_url = 'https://v2.jokeapi.dev/joke/'+categories+ '?blacklistFlags=' + blacklist + '&amount='+amount
if jokes_settings['safe']:
joke_url += '&safe-mode'
get_jokes = requests.get(joke_url)
all_jokes = get_jokes.json()