mirror of
https://github.com/ivabus/lonelyradio
synced 2024-11-21 23:55:09 +03:00
lonelyradio: Fix extension validation
Signed-off-by: Ivan Bushchik <ivabus@ivabus.dev>
This commit is contained in:
parent
ec55bd2b1e
commit
7e8f797533
1 changed files with 14 additions and 6 deletions
20
src/main.rs
20
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;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// Skipping "images" (covers)
|
if let Some(ext) = track.extension() {
|
||||||
if "jpgjpegpngwebp".contains(&track.extension().unwrap().to_str().unwrap().to_ascii_lowercase())
|
[
|
||||||
{
|
"aac", "mp1", "mp2", "mp3", "wav", "wave", "webm", "mkv", "mp4", "m4a", "m4p", "m4b",
|
||||||
return false;
|
"m4r", "m4v", "mov", "aiff", "aif", "aifc", "ogg", "ogv", "oga", "ogx", "ogm", "spx",
|
||||||
|
"opus", "caf", "flac",
|
||||||
|
]
|
||||||
|
.contains(&ext.to_str().unwrap())
|
||||||
|
} else {
|
||||||
|
false
|
||||||
}
|
}
|
||||||
true
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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