flac and wav support
This commit is contained in:
parent
86e3e9cce8
commit
faac93b1f6
3 changed files with 24 additions and 9 deletions
|
|
@ -3,7 +3,7 @@ let ip;
|
||||||
let alertTime = 2;
|
let alertTime = 2;
|
||||||
let adminPass = "";
|
let adminPass = "";
|
||||||
const ERR_NO_ADMIN = "401"; // gonna use this later to refactor
|
const ERR_NO_ADMIN = "401"; // gonna use this later to refactor
|
||||||
|
const VALID_FILE_EXT = ["mp3","flac","wav"]
|
||||||
async function alertText(text="Song Added!") {
|
async function alertText(text="Song Added!") {
|
||||||
alertbox = document.getElementById("alert");
|
alertbox = document.getElementById("alert");
|
||||||
alertbox.innerHTML = text;
|
alertbox.innerHTML = text;
|
||||||
|
|
@ -41,7 +41,7 @@ async function getFromServer(bodyInfo, source="",password=adminPass) {
|
||||||
} else if(e == "") {
|
} else if(e == "") {
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
alertText("Error: " + e)
|
alertText("Error: " + e);
|
||||||
}
|
}
|
||||||
const response=null;
|
const response=null;
|
||||||
return response;
|
return response;
|
||||||
|
|
@ -320,7 +320,9 @@ function checkWhatSongWasClicked(e) {
|
||||||
//i feel like later kristy won't apreciate this
|
//i feel like later kristy won't apreciate this
|
||||||
//one of my files was "file.MP3" so it didn't work
|
//one of my files was "file.MP3" so it didn't work
|
||||||
//windows be like
|
//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);
|
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("settings-button").addEventListener('click',function(){controlButton("st")});
|
||||||
document.getElementById("play-pause-button").addEventListener('click', function(){controlButton("pp")});
|
document.getElementById("play-pause-button").addEventListener('click', function(){controlButton("pp")});
|
||||||
document.getElementById("playlist-button").addEventListener('click', function(){controlButton("pl")});
|
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")})
|
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
|
//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)});
|
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
|
//makes the controls look mostly normal on all screens, best solution i could find, idk man
|
||||||
let tempWidth = document.getElementById('controls').clientWidth;
|
let tempWidth = document.getElementById('controls').clientWidth;
|
||||||
document.getElementById("controls").style.marginLeft = "-"+String(parseInt(tempWidth/2))+"px";
|
document.getElementById("controls").style.marginLeft = "-"+String(parseInt(tempWidth/2))+"px";
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,8 @@
|
||||||
import os
|
import os
|
||||||
from mutagen.easyid3 import EasyID3
|
from mutagen.easyid3 import EasyID3
|
||||||
from mutagen.mp3 import MP3
|
from mutagen.mp3 import MP3
|
||||||
|
import mutagen.flac
|
||||||
|
import mutagen.wave
|
||||||
import sqlite3 as sql
|
import sqlite3 as sql
|
||||||
import requests, ast, time, math, argparse
|
import requests, ast, time, math, argparse
|
||||||
|
|
||||||
|
|
@ -60,15 +62,23 @@ if args.art.lower() == "true" and not(args.apikey == ""):
|
||||||
print("ETA "+ str(x) + " seconds")
|
print("ETA "+ str(x) + " seconds")
|
||||||
|
|
||||||
# will be used soon
|
# will be used soon
|
||||||
validFormats = [".mp3",".flac",".wav"]
|
validFormats = ["mp3","flac","wav"]
|
||||||
|
|
||||||
for i in songFiles:
|
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)
|
# skip any non music files (like directories or cover art)
|
||||||
continue
|
continue
|
||||||
try:
|
try:
|
||||||
# get the metadata
|
if(extension.lower() == "mp3"):
|
||||||
song = EasyID3(soundLocation+i)
|
# 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]
|
title = song['title'][0]
|
||||||
artist = song['artist'][0]
|
artist = song['artist'][0]
|
||||||
except:
|
except:
|
||||||
|
|
@ -102,7 +112,7 @@ for i in songFiles:
|
||||||
else:
|
else:
|
||||||
image=None
|
image=None
|
||||||
try:
|
try:
|
||||||
length = math.ceil(MP3(soundLocation+i).info.length)
|
length = math.ceil(song.info.length)
|
||||||
except:
|
except:
|
||||||
length = 0
|
length = 0
|
||||||
if len(songFiles) != 1:
|
if len(songFiles) != 1:
|
||||||
|
|
|
||||||
|
|
@ -5,7 +5,7 @@
|
||||||
- [ ] Refactoring existing code
|
- [ ] Refactoring existing code
|
||||||
- [ ] Update the SQL -> Server -> Client pipeline when searching and building playlist
|
- [ ] Update the SQL -> Server -> Client pipeline when searching and building playlist
|
||||||
- [ ] Verify all if-else sequences are correct and not redundant
|
- [ ] Verify all if-else sequences are correct and not redundant
|
||||||
- [ ] Remove old comments
|
- [x] Remove old comments
|
||||||
- [ ] Secure Password
|
- [ ] Secure Password
|
||||||
* Actually use SSL for stuff that should be using it
|
* Actually use SSL for stuff that should be using it
|
||||||
- [ ] GUI update for client
|
- [ ] GUI update for client
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue