save jokes added
This commit is contained in:
parent
739017c1e1
commit
8947d1f634
39
server.py
39
server.py
@ -661,6 +661,8 @@ def save():
|
||||
save_ipo_settings(input_settings)
|
||||
elif feature == 'Economic Calendar':
|
||||
save_economic_settings(input_settings)
|
||||
elif feature == 'Jokes':
|
||||
save_jokes_settings(input_settings)
|
||||
elif 'Sports' in feature:
|
||||
save_sports_settings(input_settings)
|
||||
|
||||
@ -1335,6 +1337,43 @@ def save_economic_settings(input_settings):
|
||||
f.close()
|
||||
|
||||
|
||||
def save_jokes_settings(input_settings):
|
||||
filename = 'jokes_settings.json'
|
||||
try:
|
||||
f = open('csv/' + filename, 'r')
|
||||
current_settings = json.load(f)
|
||||
f.close()
|
||||
except:
|
||||
current_settings = {"feature": "Jokes", "speed": "medium", "speed2": "medium", "animation": "up", "title": True, "categories": ["Any"], "blacklist": [], "amount": "5", "jokes": []}
|
||||
|
||||
current_settings['speed'] = input_settings['speed'].lower()
|
||||
current_settings['speed2'] = input_settings['speed2'].lower()
|
||||
current_settings['animation'] = input_settings['animation'].lower()
|
||||
current_settings['title'] = input_settings['title']
|
||||
if input_settings['categories'] == '':
|
||||
current_settings['categories'] = 'Any'
|
||||
else:
|
||||
current_settings['categories'] = input_settings['categories']
|
||||
current_settings['blacklist'] = input_settings['blacklist']
|
||||
current_settings['amount'] = input_settings['amount']
|
||||
|
||||
try:
|
||||
f = open('csv/' + filename, 'w')
|
||||
json.dump(current_settings, f)
|
||||
f.close()
|
||||
except:
|
||||
with open('csv/jokes_settings.json', 'w') as f:
|
||||
json.dump(current_settings, f)
|
||||
|
||||
f = open('csv/last_updates.json', 'r')
|
||||
last_updates = json.load(f)
|
||||
f.close()
|
||||
last_updates['jokes']['force'] = True
|
||||
f = open('csv/last_updates.json', 'w')
|
||||
json.dump(last_updates, f)
|
||||
f.close()
|
||||
|
||||
|
||||
def save_sports_settings(input_settings):
|
||||
|
||||
feature = input_settings['feature']
|
||||
|
Loading…
Reference in New Issue
Block a user