flac and wav support

This commit is contained in:
Kristy Fournier 2025-10-10 18:39:56 -04:00
parent 86e3e9cce8
commit faac93b1f6
3 changed files with 24 additions and 9 deletions

View file

@ -3,7 +3,7 @@ let ip;
let alertTime = 2;
let adminPass = "";
const ERR_NO_ADMIN = "401"; // gonna use this later to refactor
const VALID_FILE_EXT = ["mp3","flac","wav"]
async function alertText(text="Song Added!") {
alertbox = document.getElementById("alert");
alertbox.innerHTML = text;
@ -41,7 +41,7 @@ async function getFromServer(bodyInfo, source="",password=adminPass) {
} else if(e == "") {
} else {
alertText("Error: " + e)
alertText("Error: " + e);
}
const response=null;
return response;
@ -320,7 +320,9 @@ function checkWhatSongWasClicked(e) {
//i feel like later kristy won't apreciate this
//one of my files was "file.MP3" so it didn't work
//windows be like
if (itemId.slice(-4).toLowerCase() == ".mp3") {
let filenameSep = itemId.split('.')
if (VALID_FILE_EXT.includes(filenameSep[filenameSep.length-1].toLowerCase())) {
submitSong(itemId);
}
}
@ -388,6 +390,8 @@ document.getElementById("volumerange").onchange = async function() {
}
}
//bit of a cheat code for clearing the alerts when they don't clear normally
document.getElementById("title").addEventListener('click',function(){document.getElementById("alert").innerHTML = ""})
document.getElementById("settings-button").addEventListener('click',function(){controlButton("st")});
document.getElementById("play-pause-button").addEventListener('click', function(){controlButton("pp")});
document.getElementById("playlist-button").addEventListener('click', function(){controlButton("pl")});
@ -402,6 +406,7 @@ document.getElementById("admincheckholder").addEventListener('click',function(e)
document.getElementById("partymode-button").addEventListener('click',function(){controlButton("pm")})
//sets the fact that clicking a song needs to return its id to the function to find it
document.getElementById("songlist").addEventListener('click', function(e){checkWhatSongWasClicked(e)});
//makes the controls look mostly normal on all screens, best solution i could find, idk man
let tempWidth = document.getElementById('controls').clientWidth;
document.getElementById("controls").style.marginLeft = "-"+String(parseInt(tempWidth/2))+"px";

View file

@ -1,6 +1,8 @@
import os
from mutagen.easyid3 import EasyID3
from mutagen.mp3 import MP3
import mutagen.flac
import mutagen.wave
import sqlite3 as sql
import requests, ast, time, math, argparse
@ -60,15 +62,23 @@ if args.art.lower() == "true" and not(args.apikey == ""):
print("ETA "+ str(x) + " seconds")
# will be used soon
validFormats = [".mp3",".flac",".wav"]
validFormats = ["mp3","flac","wav"]
for i in songFiles:
if i[-4:].lower() != ".mp3":
global song
extension = i.split(".")
extension = extension[len(extension)-1]
if not(extension.lower() in validFormats):
# skip any non music files (like directories or cover art)
continue
try:
# get the metadata
song = EasyID3(soundLocation+i)
if(extension.lower() == "mp3"):
# get the metadata
song = EasyID3(soundLocation+i)
elif(extension.lower() == "flac"):
song = mutagen.flac.FLAC(soundLocation+i)
elif(extension.lower() in ["wav","wave"]):
song = mutagen.wave.WAVE(soundLocation+i)
title = song['title'][0]
artist = song['artist'][0]
except:
@ -102,7 +112,7 @@ for i in songFiles:
else:
image=None
try:
length = math.ceil(MP3(soundLocation+i).info.length)
length = math.ceil(song.info.length)
except:
length = 0
if len(songFiles) != 1:

View file

@ -5,7 +5,7 @@
- [ ] Refactoring existing code
- [ ] Update the SQL -> Server -> Client pipeline when searching and building playlist
- [ ] Verify all if-else sequences are correct and not redundant
- [ ] Remove old comments
- [x] Remove old comments
- [ ] Secure Password
* Actually use SSL for stuff that should be using it
- [ ] GUI update for client