forked from rDrama/rDrama
fix mp3 songs getting cached
parent
a26f2656aa
commit
fecaed8223
|
@ -761,7 +761,9 @@ def settings_song_change_mp3(v):
|
||||||
if file.content_type != 'audio/mpeg':
|
if file.content_type != 'audio/mpeg':
|
||||||
return render_template("settings_profile.html", v=v, error="Not a valid MP3 file")
|
return render_template("settings_profile.html", v=v, error="Not a valid MP3 file")
|
||||||
|
|
||||||
name = f'/songs/{v.id}.mp3'
|
song = str(time.time()).replace('.','')
|
||||||
|
|
||||||
|
name = f'/songs/{song}.mp3'
|
||||||
file.save(name)
|
file.save(name)
|
||||||
|
|
||||||
size = os.stat(name).st_size
|
size = os.stat(name).st_size
|
||||||
|
@ -769,7 +771,10 @@ def settings_song_change_mp3(v):
|
||||||
os.remove(name)
|
os.remove(name)
|
||||||
return render_template("settings_profile.html", v=v, error="MP3 file must be smaller than 8MB")
|
return render_template("settings_profile.html", v=v, error="MP3 file must be smaller than 8MB")
|
||||||
|
|
||||||
v.song = v.id
|
if path.isfile(f"/songs/{v.song}.mp3") and g.db.query(User).filter_by(song=v.song).count() == 1:
|
||||||
|
os.remove(f"/songs/{v.song}.mp3")
|
||||||
|
|
||||||
|
v.song = song
|
||||||
g.db.add(v)
|
g.db.add(v)
|
||||||
|
|
||||||
return redirect("/settings/profile")
|
return redirect("/settings/profile")
|
||||||
|
|
|
@ -400,8 +400,8 @@
|
||||||
<input type="hidden" name="formkey" value="{{v.formkey}}">
|
<input type="hidden" name="formkey" value="{{v.formkey}}">
|
||||||
<label class="btn btn-secondary format d-inline-block m-0 mb-3">
|
<label class="btn btn-secondary format d-inline-block m-0 mb-3">
|
||||||
<div id="filename-show2"><i class="fas fa-file"></i>
|
<div id="filename-show2"><i class="fas fa-file"></i>
|
||||||
{% if v.song and v.song == v.id|string %}
|
{% if v.song and v.song|length == 17 %}
|
||||||
{{v.id}}.mp3
|
{{v.song}}.mp3
|
||||||
{% else %}
|
{% else %}
|
||||||
Use an MP3 file (Max size is 8MB)
|
Use an MP3 file (Max size is 8MB)
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
@ -413,7 +413,7 @@
|
||||||
<form action="/settings/song_change" method="post">
|
<form action="/settings/song_change" method="post">
|
||||||
<input type="hidden" name="formkey" value="{{v.formkey}}">
|
<input type="hidden" name="formkey" value="{{v.formkey}}">
|
||||||
|
|
||||||
<input class="form-control" style="display:inline;max-width:75%;font-size: min(3.5vw,16px)!important" autocomplete="off" type="text" name="song" class="form-control" value="{% if v.song and v.song != v.id|string %}https://youtu.be/{{v.song}}{% endif %}" placeholder='Enter a YouTube video link here'>
|
<input class="form-control" style="display:inline;max-width:75%;font-size: min(3.5vw,16px)!important" autocomplete="off" type="text" name="song" class="form-control" value="{% if v.song and v.song|length != 17 %}https://youtu.be/{{v.song}}{% endif %}" placeholder='Enter a YouTube video link here'>
|
||||||
|
|
||||||
<input class="btn btn-primary" style="font-size: min(3.5vw,16px)!important" autocomplete="off" class="btn btn-primary ml-auto" type="submit" onclick="disable(this)" value="Submit">
|
<input class="btn btn-primary" style="font-size: min(3.5vw,16px)!important" autocomplete="off" class="btn btn-primary ml-auto" type="submit" onclick="disable(this)" value="Submit">
|
||||||
</form>
|
</form>
|
||||||
|
|
Loading…
Reference in New Issue