Skip to content

Commit 8123970

Browse files
authored
Merge pull request #98 from tsirysndr/refactoring-scanner
[scanner] use `supported_formats` vec
2 parents ff61277 + 92f8350 commit 8123970

File tree

3 files changed

+10
-9
lines changed

3 files changed

+10
-9
lines changed

Cargo.lock

-1
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

-1
Original file line numberDiff line numberDiff line change
@@ -119,4 +119,3 @@ serde_json = "1.0.85"
119119
parking_lot = "0.12.1"
120120
dirs = "4.0.0"
121121
spinners = "4.1.0"
122-
ndk-sys = "0.4.1"

scanner/src/lib.rs

+10-7
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ use music_player_storage::{
1414
};
1515
use music_player_types::types::{Album, Artist, Song};
1616

17-
use lofty::{Accessor, AudioFile, ItemKey, LoftyError, Probe, Tag};
17+
use lofty::{AudioFile, LoftyError, Probe, Tag};
1818
use music_player_settings::{read_settings, Settings};
1919
use walkdir::WalkDir;
2020

@@ -28,6 +28,14 @@ pub async fn scan_directory(
2828

2929
let mut songs: Vec<Song> = Vec::new();
3030

31+
let supported_formats = vec![
32+
"audio/mpeg",
33+
"audio/mp4",
34+
// "audio/ogg",
35+
"audio/m4a",
36+
"audio/aac",
37+
];
38+
3139
for entry in WalkDir::new(settings.music_directory)
3240
.follow_links(true)
3341
.into_iter()
@@ -37,12 +45,7 @@ pub async fn scan_directory(
3745
let guess = mime_guess::from_path(&path);
3846
let mime = guess.first_or_octet_stream();
3947

40-
if mime == "audio/mpeg"
41-
|| mime == "audio/mp4"
42-
// || mime == "audio/ogg"
43-
|| mime == "audio/m4a"
44-
|| mime == "audio/aac"
45-
{
48+
if supported_formats.iter().any(|x| x.to_owned() == mime) {
4649
match Probe::open(&path)
4750
.expect("ERROR: Bad path provided!")
4851
.read()

0 commit comments

Comments
 (0)