Compare commits
2 Commits
v0.4.3-51-
...
580d73eeb8
| Author | SHA1 | Date | |
|---|---|---|---|
|
580d73eeb8
|
|||
|
9e30c6db00
|
7
Cargo.lock
generated
7
Cargo.lock
generated
@@ -83,10 +83,17 @@ dependencies = [
|
|||||||
name = "icarus_meta"
|
name = "icarus_meta"
|
||||||
version = "0.4.0"
|
version = "0.4.0"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"imghdr",
|
||||||
"lofty",
|
"lofty",
|
||||||
"tempfile",
|
"tempfile",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "imghdr"
|
||||||
|
version = "0.7.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "c8b35f3ad95576ac81603375dfe47a0450b70a368aa34d2b6e5bb0a0d7f02428"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "libc"
|
name = "libc"
|
||||||
version = "0.2.177"
|
version = "0.2.177"
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ rust-version = "1.90"
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
lofty = { version = "0.22.4" }
|
lofty = { version = "0.22.4" }
|
||||||
|
imghdr = { version = "0.7.0" }
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
tempfile = { version = "3.23.0" }
|
tempfile = { version = "3.23.0" }
|
||||||
|
|||||||
20
src/detection/coverart.rs
Normal file
20
src/detection/coverart.rs
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
/// Gets the file type of a CoverArt given it's path
|
||||||
|
pub fn file_type(filepath: &str) -> Result<String, std::io::Error> {
|
||||||
|
match imghdr::from_file(filepath) {
|
||||||
|
Ok(Some(imghdr::Type::Jpeg)) => {
|
||||||
|
Ok(String::from("jpeg"))
|
||||||
|
}
|
||||||
|
Ok(Some(imghdr::Type::Png)) => {
|
||||||
|
Ok(String::from("png"))
|
||||||
|
}
|
||||||
|
Ok(None) => {
|
||||||
|
Err(std::io::Error::other("Image file not supported"))
|
||||||
|
}
|
||||||
|
Err(err) => {
|
||||||
|
Err(err)
|
||||||
|
}
|
||||||
|
_ => {
|
||||||
|
Err(std::io::Error::other("Image file not supported"))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
1
src/detection/mod.rs
Normal file
1
src/detection/mod.rs
Normal file
@@ -0,0 +1 @@
|
|||||||
|
pub mod coverart;
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
|
pub mod detection;
|
||||||
pub mod meta;
|
pub mod meta;
|
||||||
pub mod properties;
|
pub mod properties;
|
||||||
pub mod types;
|
pub mod types;
|
||||||
|
|||||||
Reference in New Issue
Block a user