mirror of
https://github.com/tsirysndr/music-player.git
synced 2026-01-10 05:37:57 -05:00
[scanner] use supported_formats vec
This commit is contained in:
1
Cargo.lock
generated
1
Cargo.lock
generated
@@ -2952,7 +2952,6 @@ dependencies = [
|
||||
"music-player-tracklist",
|
||||
"music-player-types",
|
||||
"music-player-webui",
|
||||
"ndk-sys 0.4.1+23.1.7779620",
|
||||
"owo-colors",
|
||||
"parking_lot 0.12.1",
|
||||
"sea-orm",
|
||||
|
||||
@@ -119,4 +119,3 @@ serde_json = "1.0.85"
|
||||
parking_lot = "0.12.1"
|
||||
dirs = "4.0.0"
|
||||
spinners = "4.1.0"
|
||||
ndk-sys = "0.4.1"
|
||||
|
||||
@@ -14,7 +14,7 @@ use music_player_storage::{
|
||||
};
|
||||
use music_player_types::types::{Album, Artist, Song};
|
||||
|
||||
use lofty::{Accessor, AudioFile, ItemKey, LoftyError, Probe, Tag};
|
||||
use lofty::{AudioFile, LoftyError, Probe, Tag};
|
||||
use music_player_settings::{read_settings, Settings};
|
||||
use walkdir::WalkDir;
|
||||
|
||||
@@ -28,6 +28,14 @@ pub async fn scan_directory(
|
||||
|
||||
let mut songs: Vec<Song> = Vec::new();
|
||||
|
||||
let supported_formats = vec![
|
||||
"audio/mpeg",
|
||||
"audio/mp4",
|
||||
// "audio/ogg",
|
||||
"audio/m4a",
|
||||
"audio/aac",
|
||||
];
|
||||
|
||||
for entry in WalkDir::new(settings.music_directory)
|
||||
.follow_links(true)
|
||||
.into_iter()
|
||||
@@ -37,12 +45,7 @@ pub async fn scan_directory(
|
||||
let guess = mime_guess::from_path(&path);
|
||||
let mime = guess.first_or_octet_stream();
|
||||
|
||||
if mime == "audio/mpeg"
|
||||
|| mime == "audio/mp4"
|
||||
// || mime == "audio/ogg"
|
||||
|| mime == "audio/m4a"
|
||||
|| mime == "audio/aac"
|
||||
{
|
||||
if supported_formats.iter().any(|x| x.to_owned() == mime) {
|
||||
match Probe::open(&path)
|
||||
.expect("ERROR: Bad path provided!")
|
||||
.read()
|
||||
|
||||
Reference in New Issue
Block a user