From 9085f91070d072bbaa8e15289abbd15fab2f1980 Mon Sep 17 00:00:00 2001 From: Justin Date: Tue, 8 Aug 2023 17:48:49 +0800 Subject: [PATCH] save market settings --- server.py | 41 +++++++++++++++++++++++++++++++++++++++-- 1 file changed, 39 insertions(+), 2 deletions(-) diff --git a/server.py b/server.py index 0b4b855..f18093a 100755 --- a/server.py +++ b/server.py @@ -696,8 +696,8 @@ def save(): save_jokes_settings(input_settings) elif 'Sports' in feature: save_sports_settings(input_settings) - # elif feature == 'Gainers, Losers, Active': - # save_market_settings(input_settings) + elif feature == 'Gainers, Losers, Active': + save_market_settings(input_settings) elif feature in ['Custom GIFs', 'Custom Images']: images = request.files @@ -1408,6 +1408,43 @@ def save_jokes_settings(input_settings): f.close() +def save_market_settings(input_settings): + filename = 'market_settings.json' + try: + f = open('csv/' + filename, 'r') + current_settings = json.load(f) + f.close() + except: + current_settings = {"feature": "Gainers, Losers, Active", "speed": "medium", "speed2": "medium", "animation": "up", "percent": True, "point": true, "logos": True, "chart": False, "title": True, "lohivol": False, "categories": ["Top Gainers", "Top Losers", "Most Active"], "gainers": {}, "losers": {}, "mostactive": {}} + + 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'] + current_settings['logos'] = input_settings['logos'] + current_settings['percent'] = input_settings['percent'] + current_settings['point'] = input_settings['point'] + current_settings['categories'] = input_settings['categories'] + current_settings['lohivol'] = input_settings['lohivol'] + try: + f = open('csv/' + filename, 'w') + json.dump(current_settings, f) + f.close() + except: + with open('csv/market_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['market']['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']