Duplicate song queue adds can be blocked
This commit is contained in:
parent
1e1eac4aa4
commit
bcd6807a34
2 changed files with 22 additions and 8 deletions
|
|
@ -332,7 +332,11 @@ async function submitSong(songid) {
|
||||||
let returncode = await getFromServer({song: songid}, "songadd");
|
let returncode = await getFromServer({song: songid}, "songadd");
|
||||||
if(returncode == ERR_NO_ADMIN) {
|
if(returncode == ERR_NO_ADMIN) {
|
||||||
// right now the error is alerted in getFromServer, maybe will change that
|
// right now the error is alerted in getFromServer, maybe will change that
|
||||||
} else {
|
}
|
||||||
|
else if(returncode["error"]=="song-in-queue") {
|
||||||
|
alertText("That song's about to play! Hang on!")
|
||||||
|
}
|
||||||
|
else {
|
||||||
alertText("Added to Queue");
|
alertText("Added to Queue");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ from flask import Flask
|
||||||
from flask import request
|
from flask import request
|
||||||
from flask_cors import CORS
|
from flask_cors import CORS
|
||||||
import sqlite3 as sql
|
import sqlite3 as sql
|
||||||
import vlc,threading,time,random,argparse,dotenv,os,hashlib
|
import vlc,threading,time,random,argparse,dotenv,os,hashlib,string
|
||||||
# Argparse Stuff
|
# Argparse Stuff
|
||||||
parser=argparse.ArgumentParser(description="Options for the Webby Bits")
|
parser=argparse.ArgumentParser(description="Options for the Webby Bits")
|
||||||
# parser.add_argument('-p','--port',help="Port to host on, not the same as the web (client) port",default='19054')
|
# parser.add_argument('-p','--port',help="Port to host on, not the same as the web (client) port",default='19054')
|
||||||
|
|
@ -14,9 +14,13 @@ portTheUserPicked=os.getenv("SERVER_PORT")
|
||||||
# This is not great design, and the whole "returning string codes" thing is something to add to the todo list
|
# This is not great design, and the whole "returning string codes" thing is something to add to the todo list
|
||||||
# I mean returning 200 when no return is necesary i think is fine but we'll see
|
# I mean returning 200 when no return is necesary i think is fine but we'll see
|
||||||
ERR_NO_ADMIN = "401"
|
ERR_NO_ADMIN = "401"
|
||||||
ADMIN_PASS = hashlib.sha256(bytes(args.admin,'utf-8')).hexdigest()
|
if args.admin:
|
||||||
if not(ADMIN_PASS):
|
ADMIN_PASS = hashlib.sha256(bytes(args.admin,'utf-8')).hexdigest()
|
||||||
ADMIN_PASS = None
|
else:
|
||||||
|
tempPass = ''.join(random.choices(string.ascii_letters + string.digits +"?"+"!",k=20))
|
||||||
|
print("No adminPass was set, the auto generated one is: "+tempPass)
|
||||||
|
ADMIN_PASS = hashlib.sha256(bytes(tempPass,'utf-8')).hexdigest()
|
||||||
|
|
||||||
# True = everyone, False = admin only. Change in client while in use.
|
# True = everyone, False = admin only. Change in client while in use.
|
||||||
# play-pause,skip,addsong,partymode,volume in order
|
# play-pause,skip,addsong,partymode,volume in order
|
||||||
controlPerms = {
|
controlPerms = {
|
||||||
|
|
@ -189,9 +193,15 @@ def searchSongDB():
|
||||||
def songadd():
|
def songadd():
|
||||||
recieveData=request.get_json(force=True)
|
recieveData=request.get_json(force=True)
|
||||||
if (ADMIN_PASS and ADMIN_PASS == recieveData['password']) or controlPerms["AS"]:
|
if (ADMIN_PASS and ADMIN_PASS == recieveData['password']) or controlPerms["AS"]:
|
||||||
# Password exists and is correct, or it's not restricted
|
# Password exists and is correct, or it's not restricted
|
||||||
queueSong(recieveData['song'])
|
# if (recieveData['song'] in playlist):
|
||||||
return "200"
|
# return {"error":"song-in-queue"}
|
||||||
|
# else:
|
||||||
|
# Right now the above is disabled since i want to make it optional first
|
||||||
|
# probably with a checkbox like the other admin controls
|
||||||
|
if True:
|
||||||
|
queueSong(recieveData['song'])
|
||||||
|
return "200"
|
||||||
else:
|
else:
|
||||||
# the password is incorrect (technically a password not existing falls into the above case because controlPerms is never changed)
|
# the password is incorrect (technically a password not existing falls into the above case because controlPerms is never changed)
|
||||||
return ERR_NO_ADMIN
|
return ERR_NO_ADMIN
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue