Compare commits

...

8 Commits

Author SHA1 Message Date
c80bc7d7e1 remove_picture (#23)
All checks were successful
Release Tagging / release (push) Successful in 36s
Rust Build / Check (push) Successful in 42s
Rust Build / Check (pull_request) Successful in 39s
Rust Build / Test Suite (push) Successful in 47s
Rust Build / Rustfmt (push) Successful in 31s
Rust Build / Clippy (push) Successful in 40s
Rust Build / build (push) Successful in 46s
Rust Build / Test Suite (pull_request) Successful in 40s
Rust Build / Rustfmt (pull_request) Successful in 28s
Rust Build / Clippy (pull_request) Successful in 34s
Rust Build / build (pull_request) Successful in 46s
Reviewed-on: #23
Co-authored-by: phoenix <kundeng00@pm.me>
Co-committed-by: phoenix <kundeng00@pm.me>
2025-04-19 01:07:49 +00:00
805dfb269b Contains pictures (#22)
All checks were successful
Release Tagging / release (push) Successful in 38s
Rust Build / Check (push) Successful in 33s
Rust Build / Check (pull_request) Successful in 35s
Rust Build / Test Suite (push) Successful in 43s
Rust Build / Rustfmt (push) Successful in 35s
Rust Build / Clippy (push) Successful in 38s
Rust Build / build (push) Successful in 43s
Rust Build / Test Suite (pull_request) Successful in 33s
Rust Build / Rustfmt (pull_request) Successful in 31s
Rust Build / Clippy (pull_request) Successful in 34s
Rust Build / build (pull_request) Successful in 40s
Reviewed-on: #22
Co-authored-by: phoenix <kundeng00@pm.me>
Co-committed-by: phoenix <kundeng00@pm.me>
2025-04-19 00:52:14 +00:00
43774fe580 Cover art code (#21)
All checks were successful
Release Tagging / release (push) Successful in 38s
Rust Build / Check (push) Successful in 32s
Rust Build / Test Suite (push) Successful in 46s
Rust Build / Rustfmt (push) Successful in 30s
Rust Build / Clippy (push) Successful in 39s
Rust Build / build (push) Successful in 39s
Rust Build / Check (pull_request) Successful in 38s
Rust Build / Test Suite (pull_request) Successful in 49s
Rust Build / Rustfmt (pull_request) Successful in 29s
Rust Build / Clippy (pull_request) Successful in 34s
Rust Build / build (pull_request) Successful in 42s
Reviewed-on: #21
Co-authored-by: phoenix <kundeng00@pm.me>
Co-committed-by: phoenix <kundeng00@pm.me>
2025-04-18 00:37:42 +00:00
e0e9eab98c Update sample tracks with cover art (#20)
All checks were successful
Release Tagging / release (push) Successful in 47s
Rust Build / Check (push) Successful in 43s
Rust Build / Test Suite (push) Successful in 41s
Rust Build / Rustfmt (push) Successful in 36s
Rust Build / Clippy (push) Successful in 40s
Rust Build / build (push) Successful in 42s
Rust Build / Check (pull_request) Successful in 41s
Rust Build / Test Suite (pull_request) Successful in 42s
Rust Build / Rustfmt (pull_request) Successful in 29s
Rust Build / Clippy (pull_request) Successful in 41s
Rust Build / build (pull_request) Successful in 54s
Reviewed-on: #20
Co-authored-by: phoenix <kundeng00@pm.me>
Co-committed-by: phoenix <kundeng00@pm.me>
2025-04-16 23:34:54 +00:00
7c1881d102 Set Meta (#19)
All checks were successful
Release Tagging / release (push) Successful in 44s
Rust Build / Check (push) Successful in 40s
Rust Build / Test Suite (push) Successful in 40s
Rust Build / Rustfmt (push) Successful in 28s
Rust Build / Clippy (push) Successful in 37s
Rust Build / build (push) Successful in 37s
Rust Build / Check (pull_request) Successful in 55s
Rust Build / Test Suite (pull_request) Successful in 1m14s
Rust Build / Rustfmt (pull_request) Successful in 32s
Rust Build / Clippy (pull_request) Successful in 53s
Rust Build / build (pull_request) Successful in 1m27s
Reviewed-on: #19
Co-authored-by: phoenix <kundeng00@pm.me>
Co-committed-by: phoenix <kundeng00@pm.me>
2025-04-16 02:25:12 +00:00
a69212adb0 Added more fields (#18)
All checks were successful
Release Tagging / release (push) Successful in 40s
Rust Build / Check (push) Successful in 37s
Rust Build / Test Suite (push) Successful in 35s
Rust Build / Rustfmt (push) Successful in 29s
Rust Build / Clippy (push) Successful in 32s
Rust Build / build (push) Successful in 43s
Rust Build / Check (pull_request) Successful in 33s
Rust Build / Test Suite (pull_request) Successful in 39s
Rust Build / Rustfmt (pull_request) Successful in 27s
Rust Build / Clippy (pull_request) Successful in 33s
Rust Build / build (pull_request) Successful in 37s
Reviewed-on: #18
Co-authored-by: phoenix <kundeng00@pm.me>
Co-committed-by: phoenix <kundeng00@pm.me>
2025-04-15 00:49:50 +00:00
b7df0a1994 Code reorganizing (#17)
All checks were successful
Rust Build / Check (push) Successful in 36s
Rust Build / Test Suite (push) Successful in 39s
Rust Build / Rustfmt (push) Successful in 32s
Rust Build / Clippy (push) Successful in 38s
Rust Build / build (push) Successful in 41s
Release Tagging / release (push) Successful in 40s
Rust Build / Check (pull_request) Successful in 47s
Rust Build / Test Suite (pull_request) Successful in 49s
Rust Build / Rustfmt (pull_request) Successful in 31s
Rust Build / Clippy (pull_request) Successful in 40s
Rust Build / build (pull_request) Successful in 42s
Reviewed-on: #17
Co-authored-by: phoenix <kundeng00@pm.me>
Co-committed-by: phoenix <kundeng00@pm.me>
2025-04-13 20:30:10 +00:00
79a7012a3a Code refactor (#16)
All checks were successful
Rust Build / Check (push) Successful in 39s
Rust Build / Check (pull_request) Successful in 31s
Rust Build / build (push) Successful in 42s
Rust Build / Test Suite (pull_request) Successful in 36s
Rust Build / Rustfmt (pull_request) Successful in 30s
Rust Build / Clippy (pull_request) Successful in 40s
Rust Build / build (pull_request) Successful in 41s
Release Tagging / release (push) Successful in 44s
Rust Build / Test Suite (push) Successful in 35s
Rust Build / Rustfmt (push) Successful in 30s
Rust Build / Clippy (push) Successful in 33s
Reviewed-on: #16
Co-authored-by: phoenix <kundeng00@pm.me>
Co-committed-by: phoenix <kundeng00@pm.me>
2025-04-13 19:44:56 +00:00
9 changed files with 1084 additions and 245 deletions

View File

@@ -1,9 +1,12 @@
[package]
name = "icarus_meta"
version = "0.1.0"
version = "0.1.11"
edition = "2024"
rust-version = "1.86"
[dependencies]
lofty = { version = "0.22.3" }
icarus_models = { git = "ssh://git@git.kundeng.us/phoenix/icarus_models.git", tag = "v0.4.3" }
[dev-dependencies]
tempfile = { version = "3.19.1" }

View File

@@ -1,244 +1,2 @@
pub mod meta_type {
pub enum Type {
Title,
Artist,
Album,
Genre,
Year,
Track,
}
}
pub mod meta_next {
use lofty::file::AudioFile;
use super::*;
fn get_type(t: meta_type::Type) -> Result<String, std::io::Error> {
match t {
meta_type::Type::Title => Ok("TITLE".to_owned()),
meta_type::Type::Artist => Ok("ARTIST".to_owned()),
meta_type::Type::Album => Ok("ALBUM".to_owned()),
meta_type::Type::Genre => Ok("GENRE".to_owned()),
meta_type::Type::Year => Ok("DATE".to_owned()),
meta_type::Type::Track => Ok("TRACKNUMBER".to_owned()),
}
}
pub fn get_meta(t: meta_type::Type, filepath: &String) -> Result<String, std::io::Error> {
match std::fs::File::open(filepath) {
Ok(mut content) => {
match lofty::flac::FlacFile::read_from(
&mut content,
lofty::config::ParseOptions::new(),
) {
Ok(flac_file) => match flac_file.vorbis_comments() {
Some(vb) => {
println!("Info: {:?}", vb);
let type_str: String = get_type(t).unwrap();
match vb.get(&type_str) {
Some(val) => Ok(val.to_owned()),
None => Err(std::io::Error::new(
std::io::ErrorKind::InvalidData,
"Could not get tag data",
)),
}
}
None => Err(std::io::Error::new(
std::io::ErrorKind::InvalidData,
"No tags found",
)),
},
Err(err) => Err(std::io::Error::new(
std::io::ErrorKind::InvalidData,
err.to_string(),
)),
}
}
Err(err) => Err(err),
}
}
}
#[cfg(test)]
mod tests {
use util::{file_exists, get_full_path};
use super::*;
mod util {
pub fn get_full_path(
directory: &String,
filename: &String,
) -> Result<String, std::io::Error> {
match path_buf(directory, filename) {
Ok(pf) => Ok(pf.display().to_string()),
Err(err) => Err(err),
}
}
pub fn file_exists(directory: &String, filename: &String) -> Result<bool, std::io::Error> {
match path_buf(directory, filename) {
Ok(pf) => Ok(pf.exists()),
Err(err) => Err(err),
}
}
fn path_buf(
directory: &String,
filename: &String,
) -> Result<std::path::PathBuf, std::io::Error> {
let dir_path = std::path::Path::new(&directory);
Ok(dir_path.join(filename))
}
pub fn test_file_directory() -> String {
String::from("tests/sample_tracks3")
}
}
#[test]
fn test_get_title() {
let filename = String::from("track01.flac");
let dir = util::test_file_directory();
match file_exists(&dir, &filename) {
Ok(_) => {
let filepath = get_full_path(&dir, &filename).unwrap();
match meta_next::get_meta(meta_type::Type::Title, &filepath) {
Ok(title) => {
let found = title == "Just roll it";
assert!(found, "Meta information was not found {:?}", title);
}
Err(err) => {
assert!(false, "Error: {:?}", err);
}
}
}
Err(err) => {
assert!(false, "Error: File does not exist {:?}", err.to_string());
}
};
}
#[test]
fn test_get_artist() {
let filename = String::from("track01.flac");
let dir = util::test_file_directory();
match file_exists(&dir, &filename) {
Ok(_) => {
let filepath = get_full_path(&dir, &filename).unwrap();
match meta_next::get_meta(meta_type::Type::Artist, &filepath) {
Ok(artist) => {
let found = artist == "KD";
assert!(found, "Meta information was not found {:?}", artist);
}
Err(err) => {
assert!(false, "Error: {:?}", err);
}
}
}
Err(err) => {
assert!(false, "Error: File does not exist {:?}", err.to_string());
}
};
}
#[test]
fn test_get_album() {
let filename = String::from("track01.flac");
let dir = util::test_file_directory();
match file_exists(&dir, &filename) {
Ok(_) => {
let filepath = get_full_path(&dir, &filename).unwrap();
match meta_next::get_meta(meta_type::Type::Album, &filepath) {
Ok(album) => {
let found = album == "Sample Tracks 3";
assert!(found, "Meta information was not found {:?}", album);
}
Err(err) => {
assert!(false, "Error: {:?}", err);
}
}
}
Err(err) => {
assert!(false, "Error: File does not exist {:?}", err.to_string());
}
};
}
#[test]
fn test_get_genre() {
let filename = String::from("track01.flac");
let dir = util::test_file_directory();
match file_exists(&dir, &filename) {
Ok(_) => {
let filepath = get_full_path(&dir, &filename).unwrap();
match meta_next::get_meta(meta_type::Type::Genre, &filepath) {
Ok(genre) => {
let found = genre == "Metal";
assert!(found, "Meta information was not found {:?}", genre);
}
Err(err) => {
assert!(false, "Error: {:?}", err);
}
}
}
Err(err) => {
assert!(false, "Error: File does not exist {:?}", err.to_string());
}
};
}
#[test]
fn test_get_year() {
let filename = String::from("track01.flac");
let dir = util::test_file_directory();
match file_exists(&dir, &filename) {
Ok(_) => {
let filepath = get_full_path(&dir, &filename).unwrap();
match meta_next::get_meta(meta_type::Type::Year, &filepath) {
Ok(year) => {
let found = year == "2025-04-11";
assert!(found, "Meta information was not found {:?}", year);
}
Err(err) => {
assert!(false, "Error: {:?}", err);
}
}
}
Err(err) => {
assert!(false, "Error: File does not exist {:?}", err.to_string());
}
};
}
#[test]
fn test_get_track() {
let filename = String::from("track01.flac");
let dir = util::test_file_directory();
match file_exists(&dir, &filename) {
Ok(_) => {
let filepath = get_full_path(&dir, &filename).unwrap();
match meta_next::get_meta(meta_type::Type::Track, &filepath) {
Ok(track) => {
let found = track == "1";
assert!(found, "Meta information was not found {:?}", track);
}
Err(err) => {
assert!(false, "Error: {:?}", err);
}
}
}
Err(err) => {
assert!(false, "Error: File does not exist {:?}", err.to_string());
}
};
}
}
pub mod meta;
pub mod types;

1068
src/meta.rs Normal file

File diff suppressed because it is too large Load Diff

10
src/types.rs Normal file
View File

@@ -0,0 +1,10 @@
pub enum Type {
Title,
Artist,
Album,
AlbumArtist,
Genre,
Date,
Track,
Disc,
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 9.4 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 39 KiB

Binary file not shown.

Binary file not shown.

Binary file not shown.