Changing the settings on mobile actually  works as intended
also other rearranging of the backend or whatever
This commit is contained in:
Kristy Fournier 2025-01-19 11:16:54 -05:00
parent 1802ec3b79
commit b1f1a38748
3 changed files with 31 additions and 20 deletions

View file

@ -19,7 +19,7 @@
changes visibility with JS-->
<div class="songlist-mode" id="songlist-mode">
<div class="searchbox-holder">
<input type="text" autocomplete="off" placeholder="Search" id="songsearch" class="searchbox"><button class="go-search" id="go-search">Go!</button>
<input type="text" autocomplete="off" placeholder="Search" id="songsearch" enterkeyhint="Search" class="searchbox"><button class="go-search" id="go-search">Go!</button>
</div>
<div class="songlist" id="songlist">
<h1>Search to find songs!</h1>
@ -63,12 +63,12 @@ changes visibility with JS-->
<div class="item">
<h2 for="iptextbox">Server IP:</h2>
<p class="italic">IP of the device running the song server</p>
<input title="iptextbox" style="width:200px" type="text" id="iptextbox">
<input title="iptextbox" style="width:200px" type="text" id="iptextbox" enterkeyhint="Done">
</div>
<div class="item">
<h2 for="alerttimetextbox">Alert Time:</h2>
<p class="italic">How long alerts stay on screen for (seconds)</p>
<input title="alerttimetextbox" style="width:50px" type="text" id="alerttimetextbox" value="2">
<input title="alerttimetextbox" style="width:50px" type="text" id="alerttimetextbox" value="2" enterkeyhint="Done">
</div>
<h1>Server Settings (Saved to server)</h1>
<div class="item">
@ -84,7 +84,7 @@ changes visibility with JS-->
<div class="item">
<h2>Share the remote:</h2>
<p class="italic">Hit settings icon to refresh the code</p>
<div id="qrcode"></div>
<div id="qrcode" alt="QR code to the remote URL"></div>
</div>
</div>
</div>

View file

@ -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
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"]
if image == "":
# 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"][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:

View file

@ -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"])