handle 500 error

master
Aevann 2023-08-26 00:11:32 +03:00
parent ba9f802bbb
commit 11cb3ab18f
1 changed files with 6 additions and 1 deletions

View File

@ -865,7 +865,12 @@ def settings_song_change(v):
if YOUTUBE_KEY != DEFAULT_CONFIG_VALUE: 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() 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': if duration == 'P0D':
return redirect("/settings/personal?error=Can't use a live youtube video!") return redirect("/settings/personal?error=Can't use a live youtube video!")