mirror of
https://github.com/ivabus/lonelyradio
synced 2024-11-10 02:25:17 +03:00
lonelyradio: Fix extension validation
Signed-off-by: Ivan Bushchik <ivabus@ivabus.dev>
This commit is contained in:
parent
ec55bd2b1e
commit
7e8f797533
18
src/main.rs
18
src/main.rs
|
@ -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) {
|
||||||
|
|
Loading…
Reference in a new issue