From 11cb3ab18f86ddf95a05ed888315e2eba1b924d8 Mon Sep 17 00:00:00 2001 From: Aevann Date: Sat, 26 Aug 2023 00:11:32 +0300 Subject: [PATCH] handle 500 error --- files/routes/settings.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/files/routes/settings.py b/files/routes/settings.py index 707178189..828397897 100644 --- a/files/routes/settings.py +++ b/files/routes/settings.py @@ -865,7 +865,12 @@ def settings_song_change(v): if YOUTUBE_KEY != DEFAULT_CONFIG_VALUE: req = requests.get(f"https://www.googleapis.com/youtube/v3/videos?id={id}&key={YOUTUBE_KEY}&part=contentDetails", timeout=5).json() - duration = req['items'][0]['contentDetails']['duration'] + + try: + duration = req['items'][0]['contentDetails']['duration'] + except: + return redirect("/settings/personal?error=Anthem change failed, please try another video!") + if duration == 'P0D': return redirect("/settings/personal?error=Can't use a live youtube video!")