Compare commits
40 Commits
v0.1.0-dev
...
v0.4.0-mai
Author | SHA1 | Date | |
---|---|---|---|
f372d05915 | |||
bb0524ea62 | |||
f87c049ab3 | |||
5baecbaa9a | |||
f4b71de969 | |||
5288b5de30 | |||
f51b3a0c4e | |||
565d361b64 | |||
973d163ca5 | |||
e11ec6ffd0 | |||
9c7eefe7af | |||
cc02111508 | |||
f1c1fadd19 | |||
68e6c4e025 | |||
8f55b28fbe | |||
859003fc65 | |||
2a798dea9c | |||
000639b0f8 | |||
2932cdbe1c | |||
f534687292 | |||
c80bc7d7e1 | |||
805dfb269b | |||
43774fe580 | |||
e0e9eab98c | |||
7c1881d102 | |||
a69212adb0 | |||
b7df0a1994 | |||
79a7012a3a | |||
ed0ac3c156 | |||
5e57b9146c | |||
4a84fa15da | |||
ed9cdf8d7a | |||
84b9cf19b5 | |||
0db41e55b4 | |||
faf06d0d7e | |||
b9da051438 | |||
e5618fcd18 | |||
0dc8c153d2 | |||
634908e060 | |||
d2540e2513 |
@@ -4,23 +4,20 @@ on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
- devel
|
||||
tags:
|
||||
- 'v*' # Trigger on tags matching v*
|
||||
|
||||
jobs:
|
||||
release:
|
||||
runs-on: ubuntu-24.04
|
||||
steps:
|
||||
- name: Checkout code
|
||||
uses: actions/checkout@v3
|
||||
uses: actions/checkout@v5
|
||||
with:
|
||||
fetch-depth: 0 # Important for git describe --tags
|
||||
|
||||
- name: Install Rust
|
||||
uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
toolchain: 1.85.0
|
||||
toolchain: 1.90.0
|
||||
components: cargo
|
||||
|
||||
- name: Extract Version from Cargo.toml
|
||||
@@ -52,6 +49,3 @@ jobs:
|
||||
release_name: Release ${{ steps.version.outputs.project_tag_release }}
|
||||
body: |
|
||||
Release of version ${{ steps.version.outputs.project_tag_release }}
|
||||
# draft: false
|
||||
# prerelease: ${{ startsWith(github.ref, 'v') == false }} # prerelease if not a valid release tag
|
||||
|
||||
|
@@ -4,21 +4,19 @@ on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
- devel
|
||||
pull_request:
|
||||
branches:
|
||||
- main
|
||||
- devel
|
||||
|
||||
jobs:
|
||||
check:
|
||||
name: Check
|
||||
runs-on: ubuntu-24.04
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v5
|
||||
- uses: actions-rust-lang/setup-rust-toolchain@v1
|
||||
with:
|
||||
toolchain: 1.85.0
|
||||
toolchain: 1.90.0
|
||||
- run: |
|
||||
mkdir -p ~/.ssh
|
||||
echo "${{ secrets.MYREPO_TOKEN }}" > ~/.ssh/gitlab_deploy_key
|
||||
@@ -33,10 +31,10 @@ jobs:
|
||||
runs-on: ubuntu-24.04
|
||||
needs: setup_ssh
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v5
|
||||
- uses: actions-rust-lang/setup-rust-toolchain@v1
|
||||
with:
|
||||
toolchain: 1.85.0
|
||||
toolchain: 1.90.0
|
||||
- run: |
|
||||
mkdir -p ~/.ssh
|
||||
echo "${{ secrets.MYREPO_TOKEN }}" > ~/.ssh/gitlab_deploy_key
|
||||
@@ -51,10 +49,10 @@ jobs:
|
||||
runs-on: ubuntu-24.04
|
||||
needs: setup_ssh
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v5
|
||||
- uses: actions-rust-lang/setup-rust-toolchain@v1
|
||||
with:
|
||||
toolchain: 1.85.0
|
||||
toolchain: 1.90.0
|
||||
- run: rustup component add rustfmt
|
||||
- run: |
|
||||
mkdir -p ~/.ssh
|
||||
@@ -70,10 +68,10 @@ jobs:
|
||||
runs-on: ubuntu-24.04
|
||||
needs: setup_ssh
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v5
|
||||
- uses: actions-rust-lang/setup-rust-toolchain@v1
|
||||
with:
|
||||
toolchain: 1.85.0
|
||||
toolchain: 1.90.0
|
||||
- run: rustup component add clippy
|
||||
- run: |
|
||||
mkdir -p ~/.ssh
|
||||
@@ -89,10 +87,10 @@ jobs:
|
||||
runs-on: ubuntu-24.04
|
||||
needs: setup_ssh
|
||||
steps:
|
||||
- uses: actions/checkout@v4
|
||||
- uses: actions/checkout@v5
|
||||
- uses: actions-rust-lang/setup-rust-toolchain@v1
|
||||
with:
|
||||
toolchain: 1.85.0
|
||||
toolchain: 1.90.0
|
||||
- run: |
|
||||
mkdir -p ~/.ssh
|
||||
echo "${{ secrets.MYREPO_TOKEN }}" > ~/.ssh/gitlab_deploy_key
|
||||
@@ -101,4 +99,3 @@ jobs:
|
||||
eval $(ssh-agent -s)
|
||||
ssh-add -v ~/.ssh/gitlab_deploy_key
|
||||
cargo build --release
|
||||
|
||||
|
1
.gitignore
vendored
1
.gitignore
vendored
@@ -1,2 +1 @@
|
||||
/target
|
||||
Cargo.lock
|
||||
|
275
Cargo.lock
generated
Normal file
275
Cargo.lock
generated
Normal file
@@ -0,0 +1,275 @@
|
||||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
version = 4
|
||||
|
||||
[[package]]
|
||||
name = "adler2"
|
||||
version = "2.0.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "320119579fcad9c21884f5c4861d16174d0e06250625266f50fe6898340abefa"
|
||||
|
||||
[[package]]
|
||||
name = "bitflags"
|
||||
version = "2.9.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2261d10cca569e4643e526d8dc2e62e433cc8aba21ab764233731f8d369bf394"
|
||||
|
||||
[[package]]
|
||||
name = "byteorder"
|
||||
version = "1.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b"
|
||||
|
||||
[[package]]
|
||||
name = "cfg-if"
|
||||
version = "1.0.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2fd1289c04a9ea8cb22300a459a72a385d7c73d3259e2ed7dcb2af674838cfa9"
|
||||
|
||||
[[package]]
|
||||
name = "crc32fast"
|
||||
version = "1.5.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "9481c1c90cbf2ac953f07c8d4a58aa3945c425b7185c9154d67a65e4230da511"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "data-encoding"
|
||||
version = "2.9.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2a2330da5de22e8a3cb63252ce2abb30116bf5265e89c0e01bc17015ce30a476"
|
||||
|
||||
[[package]]
|
||||
name = "errno"
|
||||
version = "0.3.14"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "39cab71617ae0d63f51a36d69f866391735b51691dbda63cf6f96d042b63efeb"
|
||||
dependencies = [
|
||||
"libc",
|
||||
"windows-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "fastrand"
|
||||
version = "2.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "37909eebbb50d72f9059c3b6d82c0463f2ff062c9e95845c43a6c9c0355411be"
|
||||
|
||||
[[package]]
|
||||
name = "flate2"
|
||||
version = "1.1.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "dc5a4e564e38c699f2880d3fda590bedc2e69f3f84cd48b457bd892ce61d0aa9"
|
||||
dependencies = [
|
||||
"crc32fast",
|
||||
"miniz_oxide",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "getrandom"
|
||||
version = "0.3.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "26145e563e54f2cadc477553f1ec5ee650b00862f0a58bcd12cbdc5f0ea2d2f4"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"libc",
|
||||
"r-efi",
|
||||
"wasi",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "icarus_meta"
|
||||
version = "0.4.0"
|
||||
dependencies = [
|
||||
"lofty",
|
||||
"tempfile",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.177"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2874a2af47a2325c2001a6e6fad9b16a53b802102b528163885171cf92b15976"
|
||||
|
||||
[[package]]
|
||||
name = "linux-raw-sys"
|
||||
version = "0.11.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "df1d3c3b53da64cf5760482273a98e575c651a67eec7f77df96b5b642de8f039"
|
||||
|
||||
[[package]]
|
||||
name = "lofty"
|
||||
version = "0.22.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ca260c51a9c71f823fbfd2e6fbc8eb2ee09834b98c00763d877ca8bfa85cde3e"
|
||||
dependencies = [
|
||||
"byteorder",
|
||||
"data-encoding",
|
||||
"flate2",
|
||||
"lofty_attr",
|
||||
"log",
|
||||
"ogg_pager",
|
||||
"paste",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "lofty_attr"
|
||||
version = "0.11.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ed9983e64b2358522f745c1251924e3ab7252d55637e80f6a0a3de642d6a9efc"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"syn",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "log"
|
||||
version = "0.4.28"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "34080505efa8e45a4b816c349525ebe327ceaa8559756f0356cba97ef3bf7432"
|
||||
|
||||
[[package]]
|
||||
name = "miniz_oxide"
|
||||
version = "0.8.9"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1fa76a2c86f704bdb222d66965fb3d63269ce38518b83cb0575fca855ebb6316"
|
||||
dependencies = [
|
||||
"adler2",
|
||||
"simd-adler32",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "ogg_pager"
|
||||
version = "0.7.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "e034c10fb5c1c012c1b327b85df89fb0ef98ae66ec28af30f0d1eed804a40c19"
|
||||
dependencies = [
|
||||
"byteorder",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "once_cell"
|
||||
version = "1.21.3"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "42f5e15c9953c5e4ccceeb2e7382a716482c34515315f7b03532b8b4e8393d2d"
|
||||
|
||||
[[package]]
|
||||
name = "paste"
|
||||
version = "1.0.15"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a"
|
||||
|
||||
[[package]]
|
||||
name = "proc-macro2"
|
||||
version = "1.0.101"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "89ae43fd86e4158d6db51ad8e2b80f313af9cc74f5c0e03ccb87de09998732de"
|
||||
dependencies = [
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "quote"
|
||||
version = "1.0.41"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ce25767e7b499d1b604768e7cde645d14cc8584231ea6b295e9c9eb22c02e1d1"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "r-efi"
|
||||
version = "5.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "69cdb34c158ceb288df11e18b4bd39de994f6657d83847bdffdbd7f346754b0f"
|
||||
|
||||
[[package]]
|
||||
name = "rustix"
|
||||
version = "1.1.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "cd15f8a2c5551a84d56efdc1cd049089e409ac19a3072d5037a17fd70719ff3e"
|
||||
dependencies = [
|
||||
"bitflags",
|
||||
"errno",
|
||||
"libc",
|
||||
"linux-raw-sys",
|
||||
"windows-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "simd-adler32"
|
||||
version = "0.3.7"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d66dc143e6b11c1eddc06d5c423cfc97062865baf299914ab64caa38182078fe"
|
||||
|
||||
[[package]]
|
||||
name = "syn"
|
||||
version = "2.0.106"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ede7c438028d4436d71104916910f5bb611972c5cfd7f89b8300a8186e6fada6"
|
||||
dependencies = [
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"unicode-ident",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "tempfile"
|
||||
version = "3.23.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2d31c77bdf42a745371d260a26ca7163f1e0924b64afa0b688e61b5a9fa02f16"
|
||||
dependencies = [
|
||||
"fastrand",
|
||||
"getrandom",
|
||||
"once_cell",
|
||||
"rustix",
|
||||
"windows-sys",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "unicode-ident"
|
||||
version = "1.0.19"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f63a545481291138910575129486daeaf8ac54aee4387fe7906919f7830c7d9d"
|
||||
|
||||
[[package]]
|
||||
name = "wasi"
|
||||
version = "0.14.7+wasi-0.2.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "883478de20367e224c0090af9cf5f9fa85bed63a95c1abf3afc5c083ebc06e8c"
|
||||
dependencies = [
|
||||
"wasip2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wasip2"
|
||||
version = "1.0.1+wasi-0.2.4"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0562428422c63773dad2c345a1882263bbf4d65cf3f42e90921f787ef5ad58e7"
|
||||
dependencies = [
|
||||
"wit-bindgen",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "windows-link"
|
||||
version = "0.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f0805222e57f7521d6a62e36fa9163bc891acd422f971defe97d64e70d0a4fe5"
|
||||
|
||||
[[package]]
|
||||
name = "windows-sys"
|
||||
version = "0.61.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "ae137229bcbd6cdf0f7b80a31df61766145077ddf49416a728b02cb3921ff3fc"
|
||||
dependencies = [
|
||||
"windows-link",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "wit-bindgen"
|
||||
version = "0.46.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f17a85883d4e6d00e8a97c586de764dabcc06133f7f1d55dce5cdc070ad7fe59"
|
@@ -1,8 +1,11 @@
|
||||
[package]
|
||||
name = "icarus_meta"
|
||||
version = "0.1.0"
|
||||
version = "0.4.0"
|
||||
edition = "2024"
|
||||
rust-version = "1.90"
|
||||
|
||||
[dependencies]
|
||||
taglib = { version = "1.0.0" }
|
||||
icarus-models = { git = "ssh://git@git.kundeng.us/phoenix/icarus-models.git", tag = "v0.1.14" }
|
||||
lofty = { version = "0.22.4" }
|
||||
|
||||
[dev-dependencies]
|
||||
tempfile = { version = "3.23.0" }
|
||||
|
2
README.md
Normal file
2
README.md
Normal file
@@ -0,0 +1,2 @@
|
||||
Library to manage metadata of flac files, used in various icarus-related software
|
||||
projects.
|
70
src/lib.rs
70
src/lib.rs
@@ -1,14 +1,66 @@
|
||||
pub fn add(left: u64, right: u64) -> u64 {
|
||||
left + right
|
||||
pub mod meta;
|
||||
pub mod properties;
|
||||
pub mod types;
|
||||
|
||||
pub mod test_util {
|
||||
pub mod util {
|
||||
use std::io::{self, Write};
|
||||
|
||||
// Function to save a Vec<u8> to a file
|
||||
pub fn save_bytes_to_file(bytes: &[u8], file_path: &String) -> io::Result<()> {
|
||||
let file = std::path::Path::new(file_path);
|
||||
let mut file = std::fs::File::create(file)?;
|
||||
|
||||
match file.write_all(bytes) {
|
||||
Ok(_res) => Ok(()),
|
||||
Err(err) => Err(err),
|
||||
}
|
||||
}
|
||||
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),
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
pub fn copy_file(
|
||||
source_path: &String,
|
||||
destination_path: &String,
|
||||
) -> Result<u64, std::io::Error> {
|
||||
let src_path = std::path::Path::new(source_path);
|
||||
let dest_path = std::path::Path::new(destination_path);
|
||||
|
||||
#[test]
|
||||
fn it_works() {
|
||||
let result = add(2, 2);
|
||||
assert_eq!(result, 4);
|
||||
std::fs::copy(src_path, dest_path)
|
||||
}
|
||||
|
||||
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 const TESTFILEDIRECTORY: &str = "tests/sample_tracks3";
|
||||
|
||||
pub fn get_filename(track: i32) -> String {
|
||||
const FLAC_EXTENSION: &str = ".flac";
|
||||
|
||||
if track < 10 {
|
||||
format!("track0{track}{FLAC_EXTENSION}")
|
||||
} else {
|
||||
format!("track{track}{FLAC_EXTENSION}")
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
1201
src/meta.rs
Normal file
1201
src/meta.rs
Normal file
File diff suppressed because it is too large
Load Diff
51
src/properties.rs
Normal file
51
src/properties.rs
Normal file
@@ -0,0 +1,51 @@
|
||||
use lofty::file::AudioFile;
|
||||
|
||||
pub fn get_duration(song_path: &String) -> Result<std::time::Duration, std::io::Error> {
|
||||
match std::fs::File::open(song_path) {
|
||||
Ok(mut content) => {
|
||||
match lofty::flac::FlacFile::read_from(&mut content, lofty::config::ParseOptions::new())
|
||||
{
|
||||
Ok(flac_file) => {
|
||||
let properties = flac_file.properties();
|
||||
Ok(properties.duration())
|
||||
}
|
||||
Err(err) => Err(std::io::Error::other(err.to_string())),
|
||||
}
|
||||
}
|
||||
Err(err) => Err(err),
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use crate::test_util;
|
||||
|
||||
#[test]
|
||||
fn test_get_duration() {
|
||||
let filename = test_util::util::get_filename(1);
|
||||
let dir = String::from(test_util::util::TESTFILEDIRECTORY);
|
||||
|
||||
match test_util::util::file_exists(&dir, &filename) {
|
||||
Ok(_) => {
|
||||
let filepath = test_util::util::get_full_path(&dir, &filename).unwrap();
|
||||
match super::get_duration(&filepath) {
|
||||
Ok(duration) => {
|
||||
let song_duration: u64 = 41;
|
||||
let fetched_song_duration = duration.as_secs();
|
||||
|
||||
assert_eq!(
|
||||
song_duration, fetched_song_duration,
|
||||
"Durations should match, but they don't {song_duration} {fetched_song_duration} ({duration:?})"
|
||||
);
|
||||
}
|
||||
Err(err) => {
|
||||
assert!(false, "Error: {err:?}");
|
||||
}
|
||||
}
|
||||
}
|
||||
Err(err) => {
|
||||
assert!(false, "Error: {err:?}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
65
src/types.rs
Normal file
65
src/types.rs
Normal file
@@ -0,0 +1,65 @@
|
||||
#[derive(Debug)]
|
||||
pub enum Type {
|
||||
Title,
|
||||
Artist,
|
||||
Album,
|
||||
AlbumArtist,
|
||||
Genre,
|
||||
Date,
|
||||
Track,
|
||||
Disc,
|
||||
TrackCount,
|
||||
DiscCount,
|
||||
}
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum MetadataType {
|
||||
String(String),
|
||||
Int(i32),
|
||||
}
|
||||
|
||||
impl MetadataType {
|
||||
pub fn from_std_str(s: &str) -> Self {
|
||||
MetadataType::String(s.to_string())
|
||||
}
|
||||
|
||||
pub fn from_string(s: String) -> Self {
|
||||
MetadataType::String(s)
|
||||
}
|
||||
|
||||
pub fn from_int(i: i32) -> Self {
|
||||
MetadataType::Int(i)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn all_metadata_types() -> Vec<Type> {
|
||||
vec![
|
||||
Type::Album,
|
||||
Type::Artist,
|
||||
Type::AlbumArtist,
|
||||
Type::Date,
|
||||
Type::Disc,
|
||||
Type::Genre,
|
||||
Type::Title,
|
||||
Type::Track,
|
||||
Type::TrackCount,
|
||||
Type::DiscCount,
|
||||
]
|
||||
}
|
||||
|
||||
pub mod access {
|
||||
pub fn get_type(t: super::Type) -> Result<String, std::io::Error> {
|
||||
match t {
|
||||
super::Type::Title => Ok("TITLE".to_owned()),
|
||||
super::Type::Artist => Ok("ARTIST".to_owned()),
|
||||
super::Type::Album => Ok("ALBUM".to_owned()),
|
||||
super::Type::AlbumArtist => Ok("ALBUMARTIST".to_owned()),
|
||||
super::Type::Genre => Ok("GENRE".to_owned()),
|
||||
super::Type::Date => Ok("DATE".to_owned()),
|
||||
super::Type::Track => Ok("TRACKNUMBER".to_owned()),
|
||||
super::Type::Disc => Ok("DISCNUMBER".to_owned()),
|
||||
super::Type::TrackCount => Ok("TRACKCOUNT".to_owned()),
|
||||
super::Type::DiscCount => Ok("DISCCOUNT".to_owned()),
|
||||
}
|
||||
}
|
||||
}
|
BIN
tests/sample_tracks3/Sample Tracks 3 - Other one.png
Normal file
BIN
tests/sample_tracks3/Sample Tracks 3 - Other one.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 9.4 KiB |
BIN
tests/sample_tracks3/Sample Tracks 3.png
Normal file
BIN
tests/sample_tracks3/Sample Tracks 3.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 39 KiB |
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