forked from rDrama/rDrama
1
0
Fork 0

fix profile songs in localhost

master
Aevann 2023-02-17 17:20:51 +02:00
parent 44e9085d8d
commit 92b77735ae
1 changed files with 11 additions and 10 deletions

View File

@ -800,19 +800,20 @@ def settings_song_change(v):
return redirect("/settings/personal?msg=Profile Anthem successfully updated!") return redirect("/settings/personal?msg=Profile Anthem successfully updated!")
req = requests.get(f"https://www.googleapis.com/youtube/v3/videos?id={id}&key={YOUTUBE_KEY}&part=contentDetails", timeout=5).json() if YOUTUBE_KEY != DEFAULT_CONFIG_VALUE:
duration = req['items'][0]['contentDetails']['duration'] req = requests.get(f"https://www.googleapis.com/youtube/v3/videos?id={id}&key={YOUTUBE_KEY}&part=contentDetails", timeout=5).json()
if duration == 'P0D': duration = req['items'][0]['contentDetails']['duration']
return redirect("/settings/personal?error=Can't use a live youtube video!"), 400 if duration == 'P0D':
return redirect("/settings/personal?error=Can't use a live youtube video!"), 400
if "H" in duration: if "H" in duration:
return redirect("/settings/personal?error=Duration of the video must not exceed 15 minutes!"), 400
if "M" in duration:
duration = int(duration.split("PT")[1].split("M")[0])
if duration > 15:
return redirect("/settings/personal?error=Duration of the video must not exceed 15 minutes!"), 400 return redirect("/settings/personal?error=Duration of the video must not exceed 15 minutes!"), 400
if "M" in duration:
duration = int(duration.split("PT")[1].split("M")[0])
if duration > 15:
return redirect("/settings/personal?error=Duration of the video must not exceed 15 minutes!"), 400
gevent.spawn(_change_song_youtube, v.id, id) gevent.spawn(_change_song_youtube, v.id, id)
return redirect("/settings/personal?msg=Profile Anthem successfully updated. Wait 5 minutes for the change to take effect.") return redirect("/settings/personal?msg=Profile Anthem successfully updated. Wait 5 minutes for the change to take effect.")