diff --git a/Client/index.html b/Client/index.html index b56f759..c2f2400 100644 --- a/Client/index.html +++ b/Client/index.html @@ -86,7 +86,6 @@ changes visibility with JS-->

Hit settings icon to refresh the code

-

Version 1.0.0

diff --git a/Client/scripts.js b/Client/scripts.js index e543aa6..fe09161 100644 --- a/Client/scripts.js +++ b/Client/scripts.js @@ -95,6 +95,7 @@ function searchSongsEnter(e) { async function searchSongs(searchTerm){ let optionslist = [] + document.getElementById("songlist").innerHTML = "" searchResults = await getFromServer({search:searchTerm},"search").then() //generate the visual song list @@ -123,7 +124,7 @@ async function searchSongs(searchTerm){ document.getElementById("songlist").appendChild(newItem); } - if (JSON.stringify(searchResults)==JSON.stringify({})) { + if (searchResults.length == 0) { //display error if no results document.getElementById("songlist").innerHTML = "

We might not have that one...

"; } @@ -164,11 +165,16 @@ function ipSetter(){ alertText("Your IP is now set to "+ipBox+" at port 19054 (Default)") } } - qrCodeGenerate() } -function qrCodeGenerate() { +async function checkSettings(skipServer=false) { + //check client stuff first so if the server doesn't exist it can still be changed and seen + if (ip.slice(-5)=="19054") { + document.getElementById("iptextbox").value = ip.slice(0,-6) + } else { + document.getElementById("iptextbox").value = ip; + } let tempURL = "http://" + document.location.href.split("/")[2] + "/?ip=" + ip; document.getElementById("qrcode").innerHTML = "" new QRCode(document.getElementById("qrcode"), { @@ -179,17 +185,6 @@ function qrCodeGenerate() { colorLight : "#eeeeee", correctLevel : QRCode.CorrectLevel.H }); -} - -async function checkSettings(skipServer=false) { - //check client stuff first so if the server doesn't exist it can still be changed and seen - if (ip.slice(-5)=="19054") { - // don't show the port if it is the default - document.getElementById("iptextbox").value = ip.slice(0,-6) - } else { - document.getElementById("iptextbox").value = ip; - } - qrCodeGenerate() document.getElementById("alerttimetextbox").value = alertTime partyButtonState = document.getElementById("partymode-button").innerHTML; x = await getFromServer({setting: "getsettings"}, "settings"); @@ -315,12 +310,8 @@ document.getElementById("playlist-mode").style.display = "none"; document.getElementById("settings-mode").style.display = "none"; //.ontouch for mobile?? document.getElementById("volumerange").onchange = function() { - let returnValue = getFromServer({setting:"volume",level:this.value}, "settings") - if (returnValue !=0) { - alertText("Nothing is playing") - document.getElementById("volumerange").value = -1 - } - else if (this.value == 0) { + getFromServer({setting:"volume",level:this.value}, "settings") + if (this.value == 0) { alertText("The volume is now set to 0 (Pause?)") } else { alertText("The volume is now set to " + this.value.toString()) @@ -366,4 +357,12 @@ if (alertTime == "") { document.cookie = "alertTime="+alertTime+"; path=/;" } // this is the code that makes the qr code at the very start -qrCodeGenerate() \ No newline at end of file +let tempURL = "http://" + document.location.href.split("/")[2] + "/?ip=" + ip; +new QRCode(document.getElementById("qrcode"), { +text: tempURL, +width: 256, +height: 256, +colorDark : "#000000", +colorLight : "#eeeeee", +correctLevel : QRCode.CorrectLevel.H +}); \ No newline at end of file diff --git a/Client/styles.css b/Client/styles.css index a00db3b..8857c11 100644 --- a/Client/styles.css +++ b/Client/styles.css @@ -74,7 +74,7 @@ h4 { /* Songlist stuff */ .songlist { - width: 80%; + width: 60%; min-width: 300px; margin:auto auto 150px; display: flex; @@ -84,9 +84,9 @@ h4 { .songlist > .item{ border: 1px solid #333333; width:30%; - max-width: 150px; + max-width: 200px; margin: 5px auto; - min-width: 75px; + min-width: 100px; background-color: inherit; } @@ -172,13 +172,6 @@ h4 { border-bottom: 0; } -.versionNumber { - font-size: 8px; - font-style: italic; - text-align: left; - width: 80%; -} - #volumerange { background-color: #4477AA; color: #4477ff; diff --git a/Server/databaseGenerator.py b/Server/databaseGenerator.py index 05c3898..5494c3f 100644 --- a/Server/databaseGenerator.py +++ b/Server/databaseGenerator.py @@ -7,8 +7,7 @@ loading = ["-","\\","|","/"] parser=argparse.ArgumentParser(description="Options for the generation of the song database") parser.add_argument('-k','--apikey', help='String: LastFM api key', default="") -# parser.add_argument('-m', '--mode', help='new/update: Remake database or update current', default= "update") -parser.add_argument('-m', '--mode', help='new mode required temporarily', default= "new") +parser.add_argument('-m', '--mode', help='new/update: Remake database or update current', default= "update") parser.add_argument('-a', '--art', help="True/False: Add art to the database using LastFm (takes minimum 0.25s per song)", default="True") parser.add_argument('-d','--directory',help="Directory of the song files", default="./sound/") args = parser.parse_args() @@ -23,25 +22,31 @@ else: # apikeylastfm = "KeyHere" # soundLocation = "directoryHere" songFiles = os.listdir(soundLocation) -if args.mode == "update": +if args.mode.lower() == "update": try: with open('songDatabase.json', 'r') as handle: songDatabaseList = json.load(handle) except: songDatabaseList={"songDirectory":soundLocation,'songData':{}} - + deleteySongs = [] for i in songDatabaseList["songData"]: try: - songFiles.index(i) != -1 + if songFiles.index(i) == -1: + deleteySongs.append(i) except: - print("deleted: " + i + " from database") - songDatabaseList.remove(i) + deleteySongs.append(i) + if deleteySongs: + print("deleted: " + ", ".join(deleteySongs)+ " from database") + for i in deleteySongs: + songDatabaseList["songData"].pop(i) for i in songDatabaseList["songData"]: songFiles.remove(i) - print("new songs: " + str(songFiles)) -elif args.mode=="new": + print("new songs: " + ", ".join(songFiles)) +elif args.mode.lower()=="new": songDatabaseList={"songDirectory":soundLocation,'songData':{}} -if args.art.lower() == "true": +else: + raise ValueError("Must be \"new\" or \"update\"") +if args.art.lower() == "true" and not(args.apikey == ""): x = len(songFiles)*0.25 if x > 60: print("ETA "+ str(x/60) + " minutes") @@ -49,6 +54,9 @@ if args.art.lower() == "true": print("ETA "+ str(x) + " seconds") for i in songFiles: + if i[-4].lower() != ".mp3": + # skip any non-mp3's (like directories or cover art) + continue try: # get the metadata song = EasyID3(soundLocation+i) diff --git a/Server/webbyBits.py b/Server/webbyBits.py index 3251649..d645bb2 100644 --- a/Server/webbyBits.py +++ b/Server/webbyBits.py @@ -97,11 +97,10 @@ def playerControls(): def settingsControl(): # set the volume and partymode global partyMode - global player recieveData = request.get_json(force=True) if recieveData["setting"] == "volume": - volumePassed = player.audio_set_volume(int(recieveData["level"])) - return {"volumePassed":volumePassed} + player.audio_set_volume(int(recieveData["level"])) + return "200" elif recieveData["setting"] == "partymode-toggle": partyMode = not(partyMode) return "200" @@ -118,18 +117,15 @@ def searchSongDB(): # the way i put the data in a list was really dumb looking back, i could and should have used a list of dictioaries like i was before # i might try to change it but this layout is embedded deep in the client tempData = {} - if (recieveData['search'] == ""): - tempData = songDatabaseList["songData"].copy() - else: - for i in songDatabaseList["songData"]: - if ((songDatabaseList["songData"][i]["title"].lower().find(recieveData['search'].lower())) > -1): + for i in songDatabaseList["songData"]: + if ((songDatabaseList["songData"][i]["title"].lower().find(recieveData['search'].lower())) > -1) or (recieveData['search'] == ""): + tempData[i] = songDatabaseList["songData"][i] + + try: + if (songDatabaseList["songData"][i]["artist"].lower().find(recieveData['search'].lower()) > -1): tempData[i] = songDatabaseList["songData"][i] - - try: - if (songDatabaseList["songData"][i]["artist"].lower().find(recieveData['search'].lower()) > -1): - tempData[i] = songDatabaseList["songData"][i] - except: - pass + except: + pass # print(tempData) return tempData