movies and movies api key adding

This commit is contained in:
Justin 2023-01-09 17:11:55 +08:00 committed by GitHub
parent d54e2ed8fc
commit 4c40cbbca6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -119,7 +119,7 @@ app = Flask(__name__)
def index():
global command
all_features = ['Current Weather','Daily Forecast','News', 'Sports (Upcoming Games)','Sports (Past Games)','Sports (Live Games)',
'Sports (Team Stats)','Custom Images', 'Custom GIFs', 'Custom Messages', 'Stocks', 'Crypto', 'Forex', 'Commodities', 'Indices']
'Sports (Team Stats)','Custom Images', 'Custom GIFs', 'Custom Messages', 'Stocks', 'Crypto', 'Forex', 'Commodities', 'Indices', 'Movies']
global professional
@ -146,6 +146,12 @@ def index():
with open('api_keys.txt', 'r') as f:
api_key2 = f.readlines()
try:
with open('movie_api_key.txt', 'r') as f:
movie_api = f.readlines()
except:
movie_api = ''
with open('/etc/wpa_supplicant/wpa_supplicant.conf', 'r') as f:
wifiline = f.readlines()
@ -170,6 +176,10 @@ def index():
crypto_settings = json.load(f)
f.close()
f= open('csv/movie_settings.json', 'r')
movie_settings = json.load(f)
f.close()
f = open('csv/forex_settings.json', 'r')
forex_settings = json.load(f)
f.close()
@ -225,6 +235,11 @@ def index():
except:
api_keys = ''
try:
movie_api_key = movie_api[0]
except:
movie_api_key = ''
try:
wifi_SSID = wifiline[5][6:].replace('"','')
except:
@ -248,6 +263,7 @@ def index():
'forex_settings': forex_settings,
'current_weather': current_weather,
'daily_weather': daily_weather,
'movie_settings': movie_settings,
'news_settings': news_settings,
'upcoming_games': upcoming_games,
'past_games': past_games,
@ -259,6 +275,7 @@ def index():
'professional':professional,
'general_settings':general_settings,
'api_keys':api_keys,
'movie_api_key':movie_api_key,
'wifi_SSID':wifi_SSID,
'wifi_PSK':wifi_PSK
}
@ -273,10 +290,10 @@ def save_displaying(input_settings):
global professional
all_settings = ['Stocks', 'Crypto', 'Forex', 'Commodities', 'Indices', 'Current Weather', 'Daily Forecast', 'News', 'Sports (Upcoming Games)', 'Sports (Past Games)',
'Sports (Live Games)', 'Sports (Team Stats)', 'Custom Images', 'Custom GIFs', 'Custom Messages']
'Sports (Live Games)', 'Sports (Team Stats)', 'Custom Images', 'Custom GIFs', 'Custom Messages', 'Movies']
professional = len(input_settings) == 2
if professional:
all_settings = ['Stocks', 'Crypto', 'Forex', 'Commodities', 'Indices', 'Current Weather', 'News', 'Daily Forecast', 'Sports (Upcoming Games)', 'Sports (Past Games)', 'Sports (Team Stats)', 'Custom Messages', 'Custom Images']
all_settings = ['Stocks', 'Crypto', 'Forex', 'Commodities', 'Indices', 'Current Weather', 'News', 'Daily Forecast', 'Sports (Upcoming Games)', 'Sports (Past Games)', 'Sports (Team Stats)', 'Custom Messages', 'Custom Images', 'Movies']
positions = []
@ -415,6 +432,8 @@ def save():
save_weather_settings(input_settings)
elif feature == 'News':
save_news_settings(input_settings)
elif feature == 'Movies':
save_movie_settings(input_settings)
elif 'Sports' in feature:
save_sports_settings(input_settings)
@ -623,6 +642,22 @@ def saveWeatherAPIKey():
f.write(line)
return index()
@app.route("/saveMovieAPIKey", methods = ['PUT', 'POST'])
def saveMovieAPIKey():
data= request.data.decode('utf-8')
settings = json.loads(data)
key = settings['api_key']
with open('movie_api_key.txt', 'w') as f:
f.write(str(key))
return index()
@app.route("/screensaver", methods = ['PUT', 'POST'])
def screensaver():
global displaying_screensaver
@ -798,6 +833,37 @@ def save_news_settings(input_settings):
json.dump(last_updates, f)
f.close()
def save_movie_settings(input_settings):
filename = 'movie_settings.json'
f = open('csv/' + filename, 'r')
current_settings = json.load(f)
f.close()
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['category'] = input_settings['category']
f = open('csv/' + filename, 'w')
json.dump(current_settings, f)
f.close()
#api_caller.sendline('n')
f = open('csv/last_updates.json', 'r')
last_updates = json.load(f)
f.close()
last_updates['movies']['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']