Compare commits

...

23 Commits

Author SHA1 Message Date
c0607597f1 tsk-45: Identify type of Song (#48)
All checks were successful
Release Tagging / release (push) Successful in 40s
Rust Build / Check (push) Successful in 44s
Rust Build / Test Suite (push) Successful in 42s
Rust Build / build (push) Successful in 54s
Rust Build / Clippy (push) Successful in 38s
Rust Build / Rustfmt (push) Successful in 43s
Closes #45

Reviewed-on: #48
Co-authored-by: phoenix <kundeng00@pm.me>
Co-committed-by: phoenix <kundeng00@pm.me>
2025-10-22 02:26:18 +00:00
71374eb731 tsk-44 (#47)
All checks were successful
Release Tagging / release (push) Successful in 28s
Rust Build / Check (push) Successful in 33s
Rust Build / Rustfmt (push) Successful in 33s
Rust Build / Clippy (push) Successful in 40s
Rust Build / Test Suite (push) Successful in 52s
Rust Build / build (push) Successful in 35s
Reviewed-on: #47
Co-authored-by: phoenix <kundeng00@pm.me>
Co-committed-by: phoenix <kundeng00@pm.me>
2025-10-21 16:20:51 +00:00
5101f36aed tsk-44: Identify CoverArt type (#46)
Some checks failed
Rust Build / Check (push) Successful in 27s
Release Tagging / release (push) Successful in 35s
Rust Build / Test Suite (push) Successful in 38s
Rust Build / Clippy (push) Successful in 35s
Rust Build / Rustfmt (push) Failing after 37s
Rust Build / build (push) Successful in 36s
Closes #44

Reviewed-on: #46
Co-authored-by: phoenix <kundeng00@pm.me>
Co-committed-by: phoenix <kundeng00@pm.me>
2025-10-21 15:48:40 +00:00
f372d05915 rust bump (#43)
All checks were successful
Release Tagging / release (push) Successful in 31s
Rust Build / Check (push) Successful in 29s
Rust Build / Test Suite (push) Successful in 30s
Rust Build / Rustfmt (push) Successful in 31s
Rust Build / Clippy (push) Successful in 31s
Rust Build / build (push) Successful in 33s
Closes #41

Reviewed-on: #43
Co-authored-by: phoenix <kundeng00@pm.me>
Co-committed-by: phoenix <kundeng00@pm.me>
2025-10-12 20:15:11 +00:00
bb0524ea62 dependency update (#42)
All checks were successful
Rust Build / Check (push) Successful in 39s
Rust Build / Test Suite (push) Successful in 32s
Rust Build / Rustfmt (push) Successful in 31s
Rust Build / Clippy (push) Successful in 29s
Rust Build / build (push) Successful in 41s
Reviewed-on: #42
Co-authored-by: phoenix <kundeng00@pm.me>
Co-committed-by: phoenix <kundeng00@pm.me>
2025-10-12 19:58:06 +00:00
f87c049ab3 Bug fix release (#35)
All checks were successful
Rust Build / Check (push) Successful in 34s
Rust Build / Test Suite (push) Successful in 30s
Rust Build / Rustfmt (push) Successful in 30s
Rust Build / Clippy (push) Successful in 33s
Rust Build / build (push) Successful in 29s
Reviewed-on: #35
2025-07-23 22:07:54 +00:00
5baecbaa9a Duration (#40)
Some checks failed
Release Tagging / release (push) Successful in 31s
Rust Build / Check (push) Successful in 29s
Rust Build / Check (pull_request) Successful in 28s
Rust Build / Test Suite (push) Failing after 29s
Rust Build / Rustfmt (push) Successful in 28s
Rust Build / Clippy (push) Successful in 29s
Rust Build / build (push) Successful in 34s
Rust Build / Test Suite (pull_request) Successful in 29s
Rust Build / Clippy (pull_request) Successful in 31s
Rust Build / build (pull_request) Successful in 33s
Rust Build / Rustfmt (pull_request) Successful in 29s
Reviewed-on: #40
Co-authored-by: phoenix <kundeng00@pm.me>
Co-committed-by: phoenix <kundeng00@pm.me>
2025-07-04 21:45:48 +00:00
f4b71de969 Version bump (#39)
All checks were successful
Release Tagging / release (push) Successful in 29s
Rust Build / Check (push) Successful in 25s
Rust Build / Test Suite (push) Successful in 28s
Rust Build / Rustfmt (push) Successful in 27s
Rust Build / Clippy (push) Successful in 28s
Rust Build / build (push) Successful in 30s
Rust Build / Check (pull_request) Successful in 29s
Rust Build / Test Suite (pull_request) Successful in 31s
Rust Build / Rustfmt (pull_request) Successful in 29s
Rust Build / Clippy (pull_request) Successful in 27s
Rust Build / build (pull_request) Successful in 33s
Reviewed-on: #39
Co-authored-by: phoenix <kundeng00@pm.me>
Co-committed-by: phoenix <kundeng00@pm.me>
2025-06-29 19:39:02 +00:00
5288b5de30 Updated lofty and tempfile (#38)
Some checks failed
Rust Build / Check (push) Successful in 27s
Rust Build / Check (pull_request) Successful in 27s
Release Tagging / release (push) Successful in 32s
Rust Build / Test Suite (push) Successful in 28s
Rust Build / Rustfmt (push) Successful in 28s
Rust Build / Clippy (push) Successful in 29s
Rust Build / build (push) Successful in 33s
Rust Build / Test Suite (pull_request) Failing after 32s
Rust Build / Rustfmt (pull_request) Successful in 26s
Rust Build / Clippy (pull_request) Successful in 27s
Rust Build / build (pull_request) Successful in 29s
Reviewed-on: #38
Co-authored-by: phoenix <kundeng00@pm.me>
Co-committed-by: phoenix <kundeng00@pm.me>
2025-06-29 19:30:29 +00:00
f51b3a0c4e Rust std change (#37)
Some checks failed
Rust Build / Test Suite (push) Successful in 26s
Rust Build / Clippy (push) Successful in 26s
Rust Build / build (push) Successful in 31s
Rust Build / Test Suite (pull_request) Failing after 27s
Rust Build / Clippy (pull_request) Successful in 26s
Rust Build / build (pull_request) Successful in 30s
Release Tagging / release (push) Successful in 31s
Rust Build / Check (push) Successful in 26s
Rust Build / Check (pull_request) Successful in 25s
Rust Build / Rustfmt (push) Successful in 26s
Rust Build / Rustfmt (pull_request) Successful in 26s
Reviewed-on: #37
Co-authored-by: phoenix <kundeng00@pm.me>
Co-committed-by: phoenix <kundeng00@pm.me>
2025-06-29 19:24:51 +00:00
565d361b64 Added function to get all Types (#36)
All checks were successful
Release Tagging / release (push) Successful in 33s
Rust Build / Check (push) Successful in 26s
Rust Build / Test Suite (push) Successful in 29s
Rust Build / Rustfmt (push) Successful in 27s
Rust Build / Clippy (push) Successful in 29s
Rust Build / build (push) Successful in 34s
Rust Build / Check (pull_request) Successful in 36s
Rust Build / Test Suite (pull_request) Successful in 41s
Rust Build / Rustfmt (pull_request) Successful in 28s
Rust Build / Clippy (pull_request) Successful in 38s
Rust Build / build (pull_request) Successful in 32s
Reviewed-on: #36
Co-authored-by: phoenix <kundeng00@pm.me>
Co-committed-by: phoenix <kundeng00@pm.me>
2025-06-26 22:23:25 +00:00
973d163ca5 coverart fix (#34)
All checks were successful
Release Tagging / release (push) Successful in 29s
Rust Build / Check (pull_request) Successful in 27s
Rust Build / Rustfmt (push) Successful in 29s
Rust Build / Clippy (push) Successful in 28s
Rust Build / Test Suite (pull_request) Successful in 31s
Rust Build / Rustfmt (pull_request) Successful in 29s
Rust Build / Clippy (pull_request) Successful in 29s
Rust Build / Check (push) Successful in 27s
Rust Build / Test Suite (push) Successful in 29s
Rust Build / build (push) Successful in 35s
Rust Build / build (pull_request) Successful in 33s
Reviewed-on: #34
Co-authored-by: phoenix <kundeng00@pm.me>
Co-committed-by: phoenix <kundeng00@pm.me>
2025-06-25 21:44:04 +00:00
e11ec6ffd0 Bug fix and minor changes release (#28)
All checks were successful
Rust Build / Check (push) Successful in 25s
Rust Build / Test Suite (push) Successful in 27s
Rust Build / Rustfmt (push) Successful in 24s
Rust Build / Clippy (push) Successful in 27s
Rust Build / build (push) Successful in 29s
Rust Build / Check (pull_request) Successful in 28s
Rust Build / Test Suite (pull_request) Successful in 29s
Rust Build / Rustfmt (pull_request) Successful in 28s
Rust Build / Clippy (pull_request) Successful in 27s
Rust Build / build (pull_request) Successful in 31s
Reviewed-on: #28
2025-06-24 23:53:20 +00:00
9c7eefe7af Version bump (#32)
All checks were successful
Rust Build / Check (push) Successful in 25s
Rust Build / Test Suite (push) Successful in 27s
Rust Build / Rustfmt (push) Successful in 25s
Rust Build / Clippy (push) Successful in 26s
Rust Build / build (push) Successful in 32s
Release Tagging / release (push) Successful in 31s
Rust Build / Check (pull_request) Successful in 30s
Rust Build / Test Suite (pull_request) Successful in 29s
Rust Build / Rustfmt (pull_request) Successful in 26s
Rust Build / Clippy (pull_request) Successful in 26s
Rust Build / build (pull_request) Successful in 32s
Reviewed-on: #32
Co-authored-by: phoenix <kundeng00@pm.me>
Co-committed-by: phoenix <kundeng00@pm.me>
2025-06-24 23:46:51 +00:00
cc02111508 Remove dependency (#33)
All checks were successful
Rust Build / build (pull_request) Successful in 29s
Release Tagging / release (push) Successful in 31s
Rust Build / Check (push) Successful in 24s
Rust Build / Check (pull_request) Successful in 25s
Rust Build / Test Suite (push) Successful in 27s
Rust Build / Rustfmt (push) Successful in 26s
Rust Build / Clippy (push) Successful in 27s
Rust Build / build (push) Successful in 30s
Rust Build / Test Suite (pull_request) Successful in 26s
Rust Build / Rustfmt (pull_request) Successful in 25s
Rust Build / Clippy (pull_request) Successful in 27s
Reviewed-on: #33
Co-authored-by: phoenix <kundeng00@pm.me>
Co-committed-by: phoenix <kundeng00@pm.me>
2025-06-24 23:38:43 +00:00
f1c1fadd19 CI changes (#31)
All checks were successful
Release Tagging / release (push) Successful in 30s
Rust Build / Check (push) Successful in 27s
Rust Build / Test Suite (push) Successful in 29s
Rust Build / Rustfmt (push) Successful in 25s
Rust Build / Clippy (push) Successful in 29s
Rust Build / build (push) Successful in 33s
Rust Build / Check (pull_request) Successful in 26s
Rust Build / Test Suite (pull_request) Successful in 30s
Rust Build / Rustfmt (pull_request) Successful in 25s
Rust Build / Clippy (pull_request) Successful in 27s
Rust Build / build (pull_request) Successful in 32s
Reviewed-on: #31
Co-authored-by: phoenix <kundeng00@pm.me>
Co-committed-by: phoenix <kundeng00@pm.me>
2025-06-24 23:16:35 +00:00
68e6c4e025 Refactoring (#30)
All checks were successful
Release Tagging / release (push) Successful in 31s
Rust Build / Check (push) Successful in 26s
Rust Build / Test Suite (push) Successful in 27s
Rust Build / Rustfmt (push) Successful in 24s
Rust Build / Clippy (push) Successful in 26s
Rust Build / build (push) Successful in 30s
Rust Build / Check (pull_request) Successful in 27s
Rust Build / Test Suite (pull_request) Successful in 29s
Rust Build / Rustfmt (pull_request) Successful in 25s
Rust Build / Clippy (pull_request) Successful in 27s
Rust Build / build (pull_request) Successful in 33s
Reviewed-on: #30
Co-authored-by: phoenix <kundeng00@pm.me>
Co-committed-by: phoenix <kundeng00@pm.me>
2025-06-24 23:01:59 +00:00
8f55b28fbe Added function to set value for metadata for known types (#29)
All checks were successful
Release Tagging / release (push) Successful in 28s
Rust Build / Check (push) Successful in 28s
Rust Build / Check (pull_request) Successful in 25s
Rust Build / Test Suite (push) Successful in 27s
Rust Build / Rustfmt (push) Successful in 23s
Rust Build / Clippy (push) Successful in 27s
Rust Build / build (push) Successful in 32s
Rust Build / Test Suite (pull_request) Successful in 28s
Rust Build / Rustfmt (pull_request) Successful in 23s
Rust Build / Clippy (pull_request) Successful in 27s
Rust Build / build (pull_request) Successful in 31s
Reviewed-on: #29
Co-authored-by: phoenix <kundeng00@pm.me>
Co-committed-by: phoenix <kundeng00@pm.me>
2025-06-21 20:40:15 +00:00
859003fc65 Set meta bug fix (#27)
All checks were successful
Release Tagging / release (push) Successful in 28s
Rust Build / Check (push) Successful in 27s
Rust Build / Test Suite (push) Successful in 27s
Rust Build / Rustfmt (push) Successful in 24s
Rust Build / Clippy (push) Successful in 27s
Rust Build / build (push) Successful in 34s
Rust Build / Check (pull_request) Successful in 25s
Rust Build / Test Suite (pull_request) Successful in 25s
Rust Build / Rustfmt (pull_request) Successful in 22s
Rust Build / Clippy (pull_request) Successful in 27s
Rust Build / build (pull_request) Successful in 30s
Reviewed-on: #27
Co-authored-by: phoenix <kundeng00@pm.me>
Co-committed-by: phoenix <kundeng00@pm.me>
2025-06-21 01:01:53 +00:00
2a798dea9c Next release (#14)
All checks were successful
Release Tagging / release (push) Successful in 36s
Rust Build / Check (push) Successful in 32s
Rust Build / Test Suite (push) Successful in 39s
Rust Build / Rustfmt (push) Successful in 27s
Rust Build / Clippy (push) Successful in 39s
Rust Build / build (push) Successful in 43s
Reviewed-on: #14
2025-04-19 21:27:21 +00:00
000639b0f8 added_types (#26)
All checks were successful
Release Tagging / release (push) Successful in 32s
Rust Build / Check (push) Successful in 44s
Rust Build / Test Suite (push) Successful in 59s
Rust Build / Rustfmt (push) Successful in 32s
Rust Build / Clippy (push) Successful in 35s
Rust Build / build (push) Successful in 43s
Rust Build / Check (pull_request) Successful in 23s
Rust Build / Test Suite (pull_request) Successful in 25s
Rust Build / Rustfmt (pull_request) Successful in 21s
Rust Build / Clippy (pull_request) Successful in 26s
Rust Build / build (pull_request) Successful in 29s
Reviewed-on: #26
Co-authored-by: phoenix <kundeng00@pm.me>
Co-committed-by: phoenix <kundeng00@pm.me>
2025-04-19 21:19:01 +00:00
5e57b9146c Release (#8)
All checks were successful
Release Tagging / release (push) Successful in 35s
Rust Build / Check (push) Successful in 38s
Rust Build / Test Suite (push) Successful in 34s
Rust Build / Rustfmt (push) Successful in 34s
Rust Build / Clippy (push) Successful in 37s
Rust Build / build (push) Successful in 41s
Reviewed-on: #8
2025-04-12 19:32:16 +00:00
0dc8c153d2 devel (#3)
All checks were successful
Release Tagging / release (push) Successful in 35s
Rust Build / Check (push) Successful in 31s
Rust Build / Test Suite (push) Successful in 28s
Rust Build / Rustfmt (push) Successful in 25s
Rust Build / Clippy (push) Successful in 33s
Rust Build / build (push) Successful in 29s
Reviewed-on: #3
2025-03-30 18:11:03 +00:00
13 changed files with 1075 additions and 112 deletions

View File

@@ -4,21 +4,23 @@ on:
push:
branches:
- main
- devel
pull_request:
branches:
- main
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.86.0
toolchain: 1.90.0
components: cargo
- name: Extract Version from Cargo.toml
@@ -50,6 +52,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

View File

@@ -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.86.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.86.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.86.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.86.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.86.0
toolchain: 1.90.0
- run: |
mkdir -p ~/.ssh
echo "${{ secrets.MYREPO_TOKEN }}" > ~/.ssh/gitlab_deploy_key
@@ -100,4 +98,4 @@ jobs:
ssh-keyscan ${{ vars.MYHOST }} >> ~/.ssh/known_hosts
eval $(ssh-agent -s)
ssh-add -v ~/.ssh/gitlab_deploy_key
cargo build --release
cargo build --release

1
.gitignore vendored
View File

@@ -1,2 +1 @@
/target
Cargo.lock

450
Cargo.lock generated Normal file
View File

@@ -0,0 +1,450 @@
# 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.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "812e12b5285cc515a9c72a5c1d3b6d46a19dac5acfef5265968c166106e31dd3"
[[package]]
name = "bumpalo"
version = "3.19.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "46c5e41b57b8bba42a04676d81cb89e9ee8e859a1a66f80a5a72e1cb76b34d43"
[[package]]
name = "byteorder"
version = "1.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b"
[[package]]
name = "cfb"
version = "0.7.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d38f2da7a0a2c4ccf0065be06397cc26a81f4e528be095826eee9d4adbb8c60f"
dependencies = [
"byteorder",
"fnv",
"uuid",
]
[[package]]
name = "cfg-if"
version = "1.0.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9330f8b2ff13f34540b44e946ef35111825727b38d33286ef986142615121801"
[[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 = "fnv"
version = "1.0.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3f9eec918d3f24069decb9af1554cad7c880e2da24a9afd88aca000531ab82c1"
[[package]]
name = "getrandom"
version = "0.3.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "899def5c37c4fd7b2664648c28120ecec138e4d395b459e5ca34f9cce2dd77fd"
dependencies = [
"cfg-if",
"libc",
"r-efi",
"wasip2",
]
[[package]]
name = "icarus_meta"
version = "0.4.3"
dependencies = [
"imghdr",
"infer",
"lofty",
"rand",
"tempfile",
]
[[package]]
name = "imghdr"
version = "0.7.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c8b35f3ad95576ac81603375dfe47a0450b70a368aa34d2b6e5bb0a0d7f02428"
[[package]]
name = "infer"
version = "0.19.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a588916bfdfd92e71cacef98a63d9b1f0d74d6599980d11894290e7ddefffcf7"
dependencies = [
"cfb",
]
[[package]]
name = "js-sys"
version = "0.3.81"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ec48937a97411dcb524a265206ccd4c90bb711fca92b2792c407f268825b9305"
dependencies = [
"once_cell",
"wasm-bindgen",
]
[[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 = "ppv-lite86"
version = "0.2.21"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "85eae3c4ed2f50dcfe72643da4befc30deadb458a9b590d720cde2f2b1e97da9"
dependencies = [
"zerocopy",
]
[[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 = "rand"
version = "0.9.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6db2770f06117d490610c7488547d543617b21bfa07796d7a12f6f1bd53850d1"
dependencies = [
"rand_chacha",
"rand_core",
]
[[package]]
name = "rand_chacha"
version = "0.9.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "d3022b5f1df60f26e1ffddd6c66e8aa15de382ae63b3a0c1bfc0e4d3e3f325cb"
dependencies = [
"ppv-lite86",
"rand_core",
]
[[package]]
name = "rand_core"
version = "0.9.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "99d9a13982dcf210057a8a78572b2217b667c3beacbf3a0d8b454f6f82837d38"
dependencies = [
"getrandom",
]
[[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 = "rustversion"
version = "1.0.22"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b39cdef0fa800fc44525c84ccb54a029961a8215f9619753635a9c0d2538d46d"
[[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.107"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2a26dbd934e5451d21ef060c018dae56fc073894c5a7896f882928a76e6d081b"
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 = "uuid"
version = "1.18.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2f87b8aa10b915a06587d0dec516c282ff295b475d94abf425d62b57710070a2"
dependencies = [
"js-sys",
"wasm-bindgen",
]
[[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 = "wasm-bindgen"
version = "0.2.104"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c1da10c01ae9f1ae40cbfac0bac3b1e724b320abfcf52229f80b547c0d250e2d"
dependencies = [
"cfg-if",
"once_cell",
"rustversion",
"wasm-bindgen-macro",
"wasm-bindgen-shared",
]
[[package]]
name = "wasm-bindgen-backend"
version = "0.2.104"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "671c9a5a66f49d8a47345ab942e2cb93c7d1d0339065d4f8139c486121b43b19"
dependencies = [
"bumpalo",
"log",
"proc-macro2",
"quote",
"syn",
"wasm-bindgen-shared",
]
[[package]]
name = "wasm-bindgen-macro"
version = "0.2.104"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7ca60477e4c59f5f2986c50191cd972e3a50d8a95603bc9434501cf156a9a119"
dependencies = [
"quote",
"wasm-bindgen-macro-support",
]
[[package]]
name = "wasm-bindgen-macro-support"
version = "0.2.104"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "9f07d2f20d4da7b26400c9f4a0511e6e0345b040694e8a75bd41d578fa4421d7"
dependencies = [
"proc-macro2",
"quote",
"syn",
"wasm-bindgen-backend",
"wasm-bindgen-shared",
]
[[package]]
name = "wasm-bindgen-shared"
version = "0.2.104"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bad67dc8b2a1a6e5448428adec4c3e84c43e561d8c9ee8a9e5aabeb193ec41d1"
dependencies = [
"unicode-ident",
]
[[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"
[[package]]
name = "zerocopy"
version = "0.8.27"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0894878a5fa3edfd6da3f88c4805f4c8558e2b996227a3d864f47fe11e38282c"
dependencies = [
"zerocopy-derive",
]
[[package]]
name = "zerocopy-derive"
version = "0.8.27"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "88d2b8d9c68ad2b9e4340d7832716a4d21a22a1154777ad56ea55c51a9cf3831"
dependencies = [
"proc-macro2",
"quote",
"syn",
]

View File

@@ -1,12 +1,14 @@
[package]
name = "icarus_meta"
version = "0.1.20"
version = "0.4.3"
edition = "2024"
rust-version = "1.86"
rust-version = "1.90"
[dependencies]
lofty = { version = "0.22.3" }
icarus_models = { git = "ssh://git@git.kundeng.us/phoenix/icarus_models.git", tag = "v0.4.3" }
lofty = { version = "0.22.4" }
imghdr = { version = "0.7.0" }
infer = { version = "0.19.0" }
rand = { version = "0.9.2" }
[dev-dependencies]
tempfile = { version = "3.19.1" }
tempfile = { version = "3.23.0" }

2
README.md Normal file
View File

@@ -0,0 +1,2 @@
Library to manage metadata of flac files, used in various icarus-related software
projects.

89
src/detection/coverart.rs Normal file
View File

@@ -0,0 +1,89 @@
/// Gets the file type of a CoverArt given it's path
pub fn file_type_from_filepath(
filepath: &str,
) -> Result<crate::detection::FileType, std::io::Error> {
match imghdr::from_file(filepath) {
Ok(Some(imghdr::Type::Jpeg)) => Ok(crate::detection::FileType {
mime: String::from(constants::mime::JPEG),
file_type: String::from(constants::JPEG_TYPE),
}),
Ok(Some(imghdr::Type::Png)) => Ok(crate::detection::FileType {
mime: String::from(constants::mime::PNG),
file_type: String::from(constants::PNG_TYPE),
}),
Ok(None) => Err(std::io::Error::other("Image file not supported")),
Err(err) => Err(err),
_ => Err(std::io::Error::other("Image file not supported")),
}
}
/// Gets the file type of a CoverArt given it's data
pub fn file_type_from_data(data: &Vec<u8>) -> Result<crate::detection::FileType, std::io::Error> {
match imghdr::from_bytes(data) {
Some(imghdr::Type::Jpeg) => Ok(crate::detection::FileType {
mime: String::from(constants::mime::JPEG),
file_type: String::from(constants::JPEG_TYPE),
}),
Some(imghdr::Type::Png) => Ok(crate::detection::FileType {
mime: String::from(constants::mime::PNG),
file_type: String::from(constants::PNG_TYPE),
}),
None => Err(std::io::Error::other("Image file not supported")),
_ => Err(std::io::Error::other("Image file not supported")),
}
}
pub mod constants {
pub const PNG_TYPE: &str = "png";
pub const JPEG_TYPE: &str = "jpeg";
pub const JPG_TYPE: &str = "jpg";
pub mod mime {
pub const JPEG: &str = "image/jpeg";
pub const PNG: &str = "image/png";
}
}
#[cfg(test)]
mod tests {
#[test]
fn test_coverart_file_type() {
let directory = String::from(crate::test_util::util::TESTFILEDIRECTORY);
let filename = String::from("Sample Tracks 3.png");
let filepath = format!("{directory}/{filename}");
match super::file_type_from_filepath(&filepath) {
Ok(filetype) => {
assert_eq!(
filetype.file_type,
super::constants::PNG_TYPE,
"The file type of the CoverArt should have been png"
);
}
Err(err) => {
assert!(false, "Error: {err:?}");
}
}
}
#[test]
fn test_coverart_file_type_from_data() {
let directory = String::from(crate::test_util::util::TESTFILEDIRECTORY);
let filename = String::from("Sample Tracks 3.png");
let filepath = format!("{directory}/{filename}");
let data = crate::test_util::util::get_data_from_file(&filepath).unwrap();
match super::file_type_from_data(&data) {
Ok(filetype) => {
assert_eq!(
filetype.file_type,
super::constants::PNG_TYPE,
"The file type of the CoverArt should have been png"
);
}
Err(err) => {
assert!(false, "Error: {err:?}");
}
}
}
}

8
src/detection/mod.rs Normal file
View File

@@ -0,0 +1,8 @@
pub mod coverart;
pub mod song;
#[derive(Debug, Default)]
pub struct FileType {
pub mime: String,
pub file_type: String,
}

90
src/detection/song.rs Normal file
View File

@@ -0,0 +1,90 @@
/// Gets the file type of a Song from it's path
pub fn file_type_from_filepath(
filepath: &str,
) -> Result<crate::detection::FileType, std::io::Error> {
match infer::get_from_path(filepath) {
Ok(Some(kind)) => {
let mime = kind.mime_type();
if mime == constants::mime::FLAC {
Ok(crate::detection::FileType {
mime: String::from(mime),
file_type: String::from(constants::FLAC_TYPE),
})
} else {
Err(std::io::Error::other("Unsupported file type"))
}
}
Ok(None) => Err(std::io::Error::other("File type not determined")),
Err(err) => Err(err),
}
}
/// Gets the file type of a Song given it's data
pub fn file_type_from_data(data: &[u8]) -> Result<crate::detection::FileType, std::io::Error> {
match infer::get(data) {
Some(kind) => {
let mime = kind.mime_type();
if mime == constants::mime::FLAC {
Ok(crate::detection::FileType {
mime: String::from(mime),
file_type: String::from(constants::FLAC_TYPE),
})
} else {
Err(std::io::Error::other("Unsupported file type"))
}
}
None => Err(std::io::Error::other("File type not determined")),
}
}
pub mod constants {
pub const FLAC_TYPE: &str = "flac";
pub mod mime {
pub const FLAC: &str = "audio/x-flac";
}
}
#[cfg(test)]
mod tests {
#[test]
fn test_song_file_type() {
let directory = String::from(crate::test_util::util::TESTFILEDIRECTORY);
let filename = String::from("track01.flac");
let filepath = format!("{directory}/{filename}");
match super::file_type_from_filepath(&filepath) {
Ok(filetype) => {
assert_eq!(
filetype.file_type,
crate::detection::song::constants::FLAC_TYPE,
"Types do not match"
)
}
Err(err) => {
assert!(false, "Error: {err:?}")
}
}
}
#[test]
fn test_song_file_type_from_data() {
let directory = String::from(crate::test_util::util::TESTFILEDIRECTORY);
let filename = String::from("track01.flac");
let filepath = format!("{directory}/{filename}");
let data = crate::test_util::util::get_data_from_file(&filepath).unwrap();
match super::file_type_from_data(&data) {
Ok(filetype) => {
assert_eq!(
filetype.file_type,
crate::detection::song::constants::FLAC_TYPE,
"Types do not match"
)
}
Err(err) => {
assert!(false, "Error: {err:?}")
}
}
}
}

View File

@@ -1,2 +1,101 @@
pub mod detection;
pub mod meta;
pub mod properties;
pub mod types;
pub mod test_util {
pub mod util {
use std::io::{self, Read, Write};
use rand::Rng;
// 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),
}
}
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);
std::fs::copy(src_path, dest_path)
}
pub fn get_data_from_file(source_path: &str) -> Result<Vec<u8>, std::io::Error> {
match std::fs::File::open(source_path) {
Ok(mut file) => {
let mut data: Vec<u8> = Vec::new();
match file.read_to_end(&mut data) {
Ok(_) => Ok(data),
Err(err) => Err(err),
}
}
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),
}
}
pub fn generate_filename() -> Result<String, std::io::Error> {
let mut filename = String::from("track-");
let length = 20;
let characters = "abcdef0123456789";
let amount_of_characters = characters.len() - 1;
let mut rng = rand::rng();
for _ in 0..length {
let index = rng.random_range(0..=amount_of_characters);
let random_c = characters.chars().nth(index);
if let Some(c) = random_c {
filename.push(c);
}
}
Ok(format!("{filename}.flac"))
}
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}")
}
}
}
}

View File

@@ -21,7 +21,17 @@ pub mod coverart {
match lofty::picture::PictureInformation::from_picture(&pic) {
Ok(info) => {
flac_file.set_picture(0, pic.clone(), info);
Ok(pic.into_data())
match flac_file.save_to_path(
song_filepath,
lofty::config::WriteOptions::default(),
) {
Ok(_) => Ok(pic.into_data()),
Err(err) => Err(std::io::Error::new(
std::io::ErrorKind::InvalidData,
err.to_string(),
)),
}
}
Err(err) => Err(std::io::Error::new(
std::io::ErrorKind::InvalidData,
@@ -135,9 +145,11 @@ pub mod coverart {
}
pub mod metadata {
use crate::types;
use lofty::file::AudioFile;
use lofty::tag::Accessor;
use lofty::tag::TagExt;
use crate::types;
pub fn get_meta(t: types::Type, filepath: &String) -> Result<String, std::io::Error> {
match std::fs::File::open(filepath) {
@@ -211,9 +223,22 @@ pub mod metadata {
types::Type::Track => {
vb.set_track(pre_value.parse().unwrap());
}
types::Type::TrackCount => {
vb.set_track_total(pre_value.parse().unwrap());
}
types::Type::DiscCount => {
vb.set_disk_total(pre_value.parse().unwrap());
}
};
Ok(value.to_owned())
match vb.save_to_path(filepath, lofty::config::WriteOptions::default())
{
Ok(_) => Ok(value.to_owned()),
Err(err) => Err(std::io::Error::new(
std::io::ErrorKind::InvalidData,
err.to_string(),
)),
}
}
None => Err(std::io::Error::new(
std::io::ErrorKind::InvalidData,
@@ -229,87 +254,31 @@ pub mod metadata {
Err(err) => Err(err),
}
}
pub fn parse_value(value: types::MetadataType) -> String {
match value {
types::MetadataType::String(val) => val,
types::MetadataType::Int(val) => val.to_string(),
}
}
pub fn set_meta_value(
t: types::Type,
filepath: &String,
value: types::MetadataType,
) -> Result<String, std::io::Error> {
let parsed_val = parse_value(value);
set_meta(t, filepath, &parsed_val)
}
}
#[cfg(test)]
mod tests {
use util::{file_exists, get_full_path};
use super::*;
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),
}
}
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);
match std::fs::copy(src_path, dest_path) {
Ok(bytes) => Ok(bytes),
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 const TESTFILEDIRECTORY: &str = "tests/sample_tracks3";
pub fn get_filename(track: i32) -> String {
let mut filename = String::from("track");
if track < 10 {
filename += "0";
filename += &track.to_string();
} else {
filename += &track.to_string();
}
filename += ".flac";
filename
}
}
mod get {
use super::metadata::get_meta;
use super::*;
use super::super::metadata::get_meta;
use crate::test_util::util;
use crate::test_util::util::{file_exists, get_full_path};
use crate::types;
#[test]
@@ -510,11 +479,62 @@ mod tests {
}
};
}
#[test]
fn test_get_track_total() {
let filename = util::get_filename(1);
let dir = String::from(util::TESTFILEDIRECTORY);
match file_exists(&dir, &filename) {
Ok(_) => {
let filepath = get_full_path(&dir, &filename).unwrap();
match get_meta(types::Type::TrackCount, &filepath) {
Ok(track_total) => {
let found = track_total == "3";
assert!(found, "Meta information was not found {:?}", track_total);
}
Err(err) => {
assert!(false, "Error: {:?}", err);
}
}
}
Err(err) => {
assert!(false, "Error: File does not exist {:?}", err.to_string());
}
};
}
#[test]
fn test_get_disc_total() {
let filename = util::get_filename(1);
let dir = String::from(util::TESTFILEDIRECTORY);
match file_exists(&dir, &filename) {
Ok(_) => {
let filepath = get_full_path(&dir, &filename).unwrap();
match get_meta(types::Type::DiscCount, &filepath) {
Ok(disc_total) => {
let found = disc_total == "1";
assert!(found, "Meta information was not found {:?}", disc_total);
}
Err(err) => {
assert!(false, "Error: {:?}", err);
}
}
}
Err(err) => {
assert!(false, "Error: File does not exist {:?}", err.to_string());
}
};
}
}
mod set {
use super::metadata::{get_meta, set_meta};
use super::*;
use super::super::metadata::{get_meta, set_meta};
use crate::test_util::util;
use crate::test_util::util::{file_exists, get_full_path};
use crate::types;
#[test]
@@ -524,7 +544,7 @@ mod tests {
let temp_file = tempfile::tempdir().expect("Could not create test directory");
let test_dir = String::from(temp_file.path().to_str().unwrap());
let test_filename = String::from("track08.flac");
let test_filename = util::generate_filename().unwrap();
let new_filepath = test_dir + "/" + &test_filename;
match file_exists(&dir, &filename) {
@@ -577,7 +597,7 @@ mod tests {
let temp_file = tempfile::tempdir().expect("Could not create test directory");
let test_dir = String::from(temp_file.path().to_str().unwrap());
let test_filename = String::from("track08.flac");
let test_filename = util::generate_filename().unwrap();
let new_filepath = test_dir + "/" + &test_filename;
match file_exists(&dir, &filename) {
@@ -786,7 +806,7 @@ mod tests {
let temp_file = tempfile::tempdir().expect("Could not create test directory");
let test_dir = String::from(temp_file.path().to_str().unwrap());
let test_filename = String::from("track08.flac");
let test_filename = util::generate_filename().unwrap();
let new_filepath = test_dir + "/" + &test_filename;
match file_exists(&dir, &filename) {
@@ -879,6 +899,121 @@ mod tests {
}
};
}
#[test]
fn test_set_track_total() {
let filename = util::get_filename(1);
let dir = String::from(util::TESTFILEDIRECTORY);
let temp_file = tempfile::tempdir().expect("Could not create test directory");
let test_dir = String::from(temp_file.path().to_str().unwrap());
let test_filename = util::generate_filename().unwrap();
let new_filepath = test_dir + "/" + &test_filename;
match file_exists(&dir, &filename) {
Ok(_) => {
let filepath = get_full_path(&dir, &filename).unwrap();
match util::copy_file(&filepath, &new_filepath) {
Ok(_o) => match get_meta(types::Type::TrackCount, &filepath) {
Ok(track_total) => {
let found = track_total == "3";
assert!(found, "Meta information was not found {:?}", track_total);
let new_track_total = String::from("5");
match set_meta(
types::Type::TrackCount,
&new_filepath,
&new_track_total,
) {
Ok(m) => {
assert_eq!(
new_track_total, m,
"New track does not match {:?}",
m
);
}
Err(err) => {
assert!(false, "Error: {:?}", err);
}
}
}
Err(err) => {
assert!(false, "Error: {:?}", err);
}
},
Err(err) => {
assert!(
false,
"Error: {:?} source {:?} destination {:?}",
err, filepath, new_filepath
);
}
};
}
Err(err) => {
assert!(false, "Error: File does not exist {:?}", err.to_string());
}
};
}
#[test]
fn test_set_disc_total() {
let filename = util::get_filename(1);
let dir = String::from(util::TESTFILEDIRECTORY);
let temp_file = tempfile::tempdir().expect("Could not create test directory");
let test_dir = String::from(temp_file.path().to_str().unwrap());
let test_filename = String::from("track08.flac");
let new_filepath = test_dir + "/" + &test_filename;
match file_exists(&dir, &filename) {
Ok(_) => {
let filepath = get_full_path(&dir, &filename).unwrap();
match util::copy_file(&filepath, &new_filepath) {
Ok(_o) => match get_meta(types::Type::DiscCount, &filepath) {
Ok(disc_total) => {
let found = disc_total == "1";
assert!(found, "Meta information was not found {:?}", disc_total);
let new_disc_total = String::from("2");
match set_meta(
types::Type::DiscCount,
&new_filepath,
&new_disc_total,
) {
Ok(m) => {
assert_eq!(
new_disc_total, m,
"New disc_total does not match {:?}",
m
);
}
Err(err) => {
assert!(false, "Error: {:?}", err);
}
}
}
Err(err) => {
assert!(false, "Error: {:?}", err);
}
},
Err(err) => {
assert!(
false,
"Error: {:?} source {:?} destination {:?}",
err, filepath, new_filepath
);
}
};
}
Err(err) => {
assert!(false, "Error: File does not exist {:?}", err.to_string());
}
};
}
#[test]
fn test_set_genre() {
let filename = util::get_filename(1);
@@ -886,7 +1021,7 @@ mod tests {
let temp_file = tempfile::tempdir().expect("Could not create test directory");
let test_dir = String::from(temp_file.path().to_str().unwrap());
let test_filename = String::from("track08.flac");
let test_filename = util::generate_filename().unwrap();
let new_filepath = test_dir + "/" + &test_filename;
match file_exists(&dir, &filename) {
@@ -935,7 +1070,9 @@ mod tests {
mod pictures {
use super::*;
use super::super::*;
use crate::test_util::util;
use crate::test_util::util::{file_exists, get_full_path};
#[test]
fn test_get_picture() {

51
src/properties.rs Normal file
View 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:?}");
}
}
}
}

View File

@@ -1,3 +1,4 @@
#[derive(Debug)]
pub enum Type {
Title,
Artist,
@@ -7,10 +8,46 @@ pub enum Type {
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()),
@@ -21,6 +58,8 @@ pub mod access {
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()),
}
}
}