diff --git a/Client/index.html b/Client/index.html index f7be55c..97ab4aa 100644 --- a/Client/index.html +++ b/Client/index.html @@ -19,7 +19,7 @@ changes visibility with JS-->
- +

Search to find songs!

@@ -52,7 +52,7 @@ changes visibility with JS-->
-

Client Settings (Saved to device)

+

Client Settings (Saved to device)

Server IP:

IP of the device running the song server

- +

Alert Time:

How long alerts stay on screen for (seconds)

- +

Server Settings (Saved to server)

@@ -84,7 +84,7 @@ changes visibility with JS-->

Share the remote:

Hit settings icon to refresh the code

-
+
diff --git a/Server/databaseGenerator.py b/Server/databaseGenerator.py index 7885322..a504848 100644 --- a/Server/databaseGenerator.py +++ b/Server/databaseGenerator.py @@ -9,10 +9,15 @@ parser=argparse.ArgumentParser(description="Options for the generation of the so 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('-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 (USING FORWARD SLASHES)", default="./sound") +parser.add_argument('-d','--directory',help="Directory of the song files", default="./sound/") args = parser.parse_args() apikeylastfm = args.apikey -soundLocation = args.directory +if args.directory[-1] == "/" or args.directory[-1] == "\\": + soundLocation = args.directory +elif "/" in args.directory: + soundLocation = args.directory + "/" +else: + soundLocation = args.directory + "\\" # if you want to set the api key/sound directory permenantly for your setup just uncomment the next line # apikeylastfm = "KeyHere" # soundLocation = "directoryHere" @@ -29,8 +34,7 @@ if args.mode == "update": songFiles.index(i["file"]) != -1 except: print("deleted: " + i["file"] + " from database") - songDatabaseList.pop(songDatabaseList.index(i)) - + songDatabaseList.remove(i) for i in songDatabaseList: songFiles.pop(songFiles.index(i["file"])) print("new songs: " + str(songFiles)) @@ -47,7 +51,7 @@ if args.art.lower() == "true": for i in songFiles: try: # get the metadata - song = EasyID3(soundLocation+"/"+i) + song = EasyID3(soundLocation+i) title = song['title'][0] artist = song['artist'][0] except: @@ -62,10 +66,10 @@ for i in songFiles: artist = None if args.art.lower() == "true" and not(args.apikey == ""): try: - # get the smallest possible image from lastFM - image = ast.literal_eval(requests.post(url="http://ws.audioscrobbler.com/2.0/?method=track.getInfo&api_key="+apikeylastfm+"&artist="+artist+"&track="+title+"&format=json").text)["track"]["album"]["image"][1]["#text"] + # get the images from last fm, try 2 different sizes + image = ast.literal_eval(requests.post(url="http://ws.audioscrobbler.com/2.0/?method=track.getInfo&api_key="+apikeylastfm+"&artist="+artist+"&track="+title+"&format=json").text)["track"]["album"]["image"][2]["#text"] if image == "": - image = ast.literal_eval(requests.post(url="http://ws.audioscrobbler.com/2.0/?method=track.getInfo&api_key="+apikeylastfm+"&artist="+artist+"&track="+title+"&format=json").text)["track"]["album"]["image"][2]["#text"] + image = ast.literal_eval(requests.post(url="http://ws.audioscrobbler.com/2.0/?method=track.getInfo&api_key="+apikeylastfm+"&artist="+artist+"&track="+title+"&format=json").text)["track"]["album"]["image"][1]["#text"] if image == "": image = None time.sleep(0.25) @@ -74,7 +78,7 @@ for i in songFiles: else: image=None try: - length = math.ceil(MP3(soundLocation+"/"+i).info.length) + length = math.ceil(MP3(soundLocation+i).info.length) except: length = 0 if len(songFiles) != 1: diff --git a/Server/webbyBits.py b/Server/webbyBits.py index 045fff1..4351984 100644 --- a/Server/webbyBits.py +++ b/Server/webbyBits.py @@ -4,8 +4,18 @@ from flask_cors import CORS import json,vlc,threading,time,random, argparse # Argparse Stuff parser=argparse.ArgumentParser(description="Options for the Webby Bits") -parser.add_argument('-p','--port',help="Pick a port to host on, not the same as the web (client) port",default='19054') +parser.add_argument('-d','--directory',help="Directory of the song files", default="./sound/") +parser.add_argument('-p','--port',help="Port to host on, not the same as the web (client) port",default='19054') portTheUserPicked=parser.parse_args().port +soundLocation = parser.parse_args().directory +# To set the directory permenantly just uncomment the next line +# soundLocation = "/example/directory/here/" +if soundLocation[-1] == "/" or soundLocation[-1] == "\\": + pass +elif "/" in soundLocation: + soundLocation += "/" +else: + soundLocation += "\\" #Initializing all the global stuff random.seed() global partyMode @@ -47,15 +57,12 @@ def playQueuedSongs(): media = fakeplayer.media_new("sound/"+songNext) player.set_media(media) player.play() - elif (len(playlist) == 0) and skipNow==True: + elif (skipNow==True or (z == "State.Ended" or z == "State.NothingSpecial" or z=="State.Stopped")): # skip was pressed and there are no new songs skipNow=False songNext = None player.stop() - elif (len(playlist) == 0) and (z == "State.Ended" or z == "State.NothingSpecial" or z=="State.Stopped"): - # i feel like this could actually be combined with the above, but imma not do that rn - songNext = None - elif (len(playlist)<1) and (partyMode == True): + elif len(playlist)<1 and (partyMode == True): # adds the random songs for party mode # the above 2 means this only applies if (a song is playing (or paused)) and the queue is empty playlist.append(random.choice(songDatabaseList)["file"])