lonelyradio: Fix extension validation

Signed-off-by: Ivan Bushchik <ivabus@ivabus.dev>
This commit is contained in:
Ivan Bushchik 2024-07-13 22:19:26 +03:00
parent ec55bd2b1e
commit 7e8f797533
No known key found for this signature in database
GPG key ID: 2F16FBF3262E090C

View file

@ -193,15 +193,23 @@ fn is_not_hidden(entry: &DirEntry) -> bool {
} }
fn track_valid(track: &Path) -> bool { fn track_valid(track: &Path) -> bool {
if !track.metadata().unwrap().is_file() { if let Ok(meta) = track.metadata() {
if !meta.is_file() {
return false; return false;
} }
// Skipping "images" (covers) } else {
if "jpgjpegpngwebp".contains(&track.extension().unwrap().to_str().unwrap().to_ascii_lowercase())
{
return false; return false;
} }
true if let Some(ext) = track.extension() {
[
"aac", "mp1", "mp2", "mp3", "wav", "wave", "webm", "mkv", "mp4", "m4a", "m4p", "m4b",
"m4r", "m4v", "mov", "aiff", "aif", "aifc", "ogg", "ogv", "oga", "ogx", "ogm", "spx",
"opus", "caf", "flac",
]
.contains(&ext.to_str().unwrap())
} else {
false
}
} }
async fn stream(mut s: TcpStream, tracklist: Arc<Vec<PathBuf>>, settings: Settings) { async fn stream(mut s: TcpStream, tracklist: Arc<Vec<PathBuf>>, settings: Settings) {