coverart fix #34
@@ -5,8 +5,6 @@ on:
|
|||||||
branches:
|
branches:
|
||||||
- main
|
- main
|
||||||
- devel
|
- devel
|
||||||
tags:
|
|
||||||
- 'v*' # Trigger on tags matching v*
|
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
release:
|
release:
|
||||||
@@ -20,7 +18,7 @@ jobs:
|
|||||||
- name: Install Rust
|
- name: Install Rust
|
||||||
uses: actions-rs/toolchain@v1
|
uses: actions-rs/toolchain@v1
|
||||||
with:
|
with:
|
||||||
toolchain: 1.85.0
|
toolchain: 1.86.0
|
||||||
components: cargo
|
components: cargo
|
||||||
|
|
||||||
- name: Extract Version from Cargo.toml
|
- name: Extract Version from Cargo.toml
|
||||||
|
@@ -18,7 +18,7 @@ jobs:
|
|||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
- uses: actions-rust-lang/setup-rust-toolchain@v1
|
- uses: actions-rust-lang/setup-rust-toolchain@v1
|
||||||
with:
|
with:
|
||||||
toolchain: 1.85.0
|
toolchain: 1.86.0
|
||||||
- run: |
|
- run: |
|
||||||
mkdir -p ~/.ssh
|
mkdir -p ~/.ssh
|
||||||
echo "${{ secrets.MYREPO_TOKEN }}" > ~/.ssh/gitlab_deploy_key
|
echo "${{ secrets.MYREPO_TOKEN }}" > ~/.ssh/gitlab_deploy_key
|
||||||
@@ -36,7 +36,7 @@ jobs:
|
|||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
- uses: actions-rust-lang/setup-rust-toolchain@v1
|
- uses: actions-rust-lang/setup-rust-toolchain@v1
|
||||||
with:
|
with:
|
||||||
toolchain: 1.85.0
|
toolchain: 1.86.0
|
||||||
- run: |
|
- run: |
|
||||||
mkdir -p ~/.ssh
|
mkdir -p ~/.ssh
|
||||||
echo "${{ secrets.MYREPO_TOKEN }}" > ~/.ssh/gitlab_deploy_key
|
echo "${{ secrets.MYREPO_TOKEN }}" > ~/.ssh/gitlab_deploy_key
|
||||||
@@ -54,7 +54,7 @@ jobs:
|
|||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
- uses: actions-rust-lang/setup-rust-toolchain@v1
|
- uses: actions-rust-lang/setup-rust-toolchain@v1
|
||||||
with:
|
with:
|
||||||
toolchain: 1.85.0
|
toolchain: 1.86.0
|
||||||
- run: rustup component add rustfmt
|
- run: rustup component add rustfmt
|
||||||
- run: |
|
- run: |
|
||||||
mkdir -p ~/.ssh
|
mkdir -p ~/.ssh
|
||||||
@@ -73,7 +73,7 @@ jobs:
|
|||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
- uses: actions-rust-lang/setup-rust-toolchain@v1
|
- uses: actions-rust-lang/setup-rust-toolchain@v1
|
||||||
with:
|
with:
|
||||||
toolchain: 1.85.0
|
toolchain: 1.86.0
|
||||||
- run: rustup component add clippy
|
- run: rustup component add clippy
|
||||||
- run: |
|
- run: |
|
||||||
mkdir -p ~/.ssh
|
mkdir -p ~/.ssh
|
||||||
@@ -92,7 +92,7 @@ jobs:
|
|||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v4
|
||||||
- uses: actions-rust-lang/setup-rust-toolchain@v1
|
- uses: actions-rust-lang/setup-rust-toolchain@v1
|
||||||
with:
|
with:
|
||||||
toolchain: 1.85.0
|
toolchain: 1.86.0
|
||||||
- run: |
|
- run: |
|
||||||
mkdir -p ~/.ssh
|
mkdir -p ~/.ssh
|
||||||
echo "${{ secrets.MYREPO_TOKEN }}" > ~/.ssh/gitlab_deploy_key
|
echo "${{ secrets.MYREPO_TOKEN }}" > ~/.ssh/gitlab_deploy_key
|
||||||
@@ -100,5 +100,4 @@ jobs:
|
|||||||
ssh-keyscan ${{ vars.MYHOST }} >> ~/.ssh/known_hosts
|
ssh-keyscan ${{ vars.MYHOST }} >> ~/.ssh/known_hosts
|
||||||
eval $(ssh-agent -s)
|
eval $(ssh-agent -s)
|
||||||
ssh-add -v ~/.ssh/gitlab_deploy_key
|
ssh-add -v ~/.ssh/gitlab_deploy_key
|
||||||
cargo build --release
|
cargo build --release
|
||||||
|
|
@@ -2,7 +2,8 @@
|
|||||||
name = "icarus_meta"
|
name = "icarus_meta"
|
||||||
version = "0.1.0"
|
version = "0.1.0"
|
||||||
edition = "2024"
|
edition = "2024"
|
||||||
|
rust-version = "1.86"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
taglib = { version = "1.0.0" }
|
lofty = { version = "0.22.3" }
|
||||||
icarus_models = { git = "ssh://git@git.kundeng.us/phoenix/icarus_models.git", tag = "v0.2.0" }
|
icarus_models = { git = "ssh://git@git.kundeng.us/phoenix/icarus_models.git", tag = "v0.4.3" }
|
||||||
|
119
src/lib.rs
119
src/lib.rs
@@ -1,14 +1,123 @@
|
|||||||
pub fn add(left: u64, right: u64) -> u64 {
|
pub mod meta_type {
|
||||||
left + right
|
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("YEAR".to_owned()),
|
||||||
|
meta_type::Type::Track => Ok("TRACK".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) => {
|
||||||
|
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)]
|
#[cfg(test)]
|
||||||
mod tests {
|
mod tests {
|
||||||
|
use util::{file_exists, get_full_path};
|
||||||
|
|
||||||
use super::*;
|
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]
|
#[test]
|
||||||
fn it_works() {
|
fn test_get_title() {
|
||||||
let result = add(2, 2);
|
let filename = String::from("track01.flac");
|
||||||
assert_eq!(result, 4);
|
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());
|
||||||
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
BIN
tests/sample_tracks3/track01.flac
Normal file
BIN
tests/sample_tracks3/track01.flac
Normal file
Binary file not shown.
BIN
tests/sample_tracks3/track02.flac
Normal file
BIN
tests/sample_tracks3/track02.flac
Normal file
Binary file not shown.
BIN
tests/sample_tracks3/track03.flac
Normal file
BIN
tests/sample_tracks3/track03.flac
Normal file
Binary file not shown.
Reference in New Issue
Block a user