Compare commits

...

25 Commits

Author SHA1 Message Date
6917ccf487 tsk-42: Dockerized the service
All checks were successful
Rust Build / Check (pull_request) Successful in 35s
Rust Build / Rustfmt (pull_request) Successful in 31s
Rust Build / Test Suite (pull_request) Successful in 22s
Rust Build / Clippy (pull_request) Successful in 26s
Rust Build / build (pull_request) Successful in 48s
2025-08-16 18:39:57 -04:00
1ed736d116 tsk-42: Updating exposed port for docker 2025-08-16 15:41:48 -04:00
12b1c61628 tsk-42: Updating sample docker env file
All checks were successful
Rust Build / Check (pull_request) Successful in 29s
Rust Build / Test Suite (pull_request) Successful in 30s
Rust Build / Rustfmt (pull_request) Successful in 23s
Rust Build / Clippy (pull_request) Successful in 30s
Rust Build / build (pull_request) Successful in 36s
2025-08-15 15:03:00 -04:00
b110066a61 tsk-42: Adding initial docker file
All checks were successful
Rust Build / Check (pull_request) Successful in 30s
Rust Build / Test Suite (pull_request) Successful in 34s
Rust Build / Rustfmt (pull_request) Successful in 24s
Rust Build / Clippy (pull_request) Successful in 29s
Rust Build / build (pull_request) Successful in 38s
2025-08-15 14:51:52 -04:00
f748d93b3f tsk-41: Adding auth (#43)
All checks were successful
Rust Build / Check (push) Successful in 33s
Rust Build / Rustfmt (push) Successful in 29s
Rust Build / Test Suite (push) Successful in 38s
Rust Build / Clippy (push) Successful in 41s
Rust Build / build (push) Successful in 34s
Closes #41

Reviewed-on: #43
Co-authored-by: phoenix <kundeng00@pm.me>
Co-committed-by: phoenix <kundeng00@pm.me>
2025-08-14 23:11:41 +00:00
80762b81ae Next release (#13)
All checks were successful
Rust Build / Check (push) Successful in 32s
Rust Build / Rustfmt (push) Successful in 26s
Rust Build / Test Suite (push) Successful in 35s
Rust Build / Clippy (push) Successful in 27s
Rust Build / build (push) Successful in 41s
Reviewed-on: #13
2025-07-23 21:05:30 +00:00
af4f1acb87 Reverting change (#40)
All checks were successful
Rust Build / Check (push) Successful in 32s
Release Tagging / release (push) Successful in 34s
Rust Build / Check (pull_request) Successful in 31s
Rust Build / Test Suite (push) Successful in 35s
Rust Build / Rustfmt (push) Successful in 30s
Rust Build / Clippy (push) Successful in 35s
Rust Build / build (push) Successful in 40s
Rust Build / Test Suite (pull_request) Successful in 35s
Rust Build / Rustfmt (pull_request) Successful in 31s
Rust Build / Clippy (pull_request) Successful in 35s
Rust Build / build (pull_request) Successful in 42s
Reviewed-on: #40
Co-authored-by: phoenix <kundeng00@pm.me>
Co-committed-by: phoenix <kundeng00@pm.me>
2025-07-23 21:01:36 +00:00
d5e24f9114 Minor changes (#39)
All checks were successful
Rust Build / Check (push) Successful in 28s
Release Tagging / release (push) Successful in 32s
Rust Build / Check (pull_request) Successful in 28s
Rust Build / Test Suite (push) Successful in 35s
Rust Build / Rustfmt (push) Successful in 25s
Rust Build / build (push) Successful in 34s
Rust Build / Test Suite (pull_request) Successful in 34s
Rust Build / Rustfmt (pull_request) Successful in 26s
Rust Build / Clippy (pull_request) Successful in 34s
Rust Build / Clippy (push) Successful in 36s
Rust Build / build (pull_request) Successful in 40s
Reviewed-on: #39
Co-authored-by: phoenix <kundeng00@pm.me>
Co-committed-by: phoenix <kundeng00@pm.me>
2025-07-23 20:50:40 +00:00
27e4b30d21 File cleanup post-parsing (#37)
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 27s
Rust Build / Clippy (push) Successful in 28s
Release Tagging / release (push) Successful in 29s
Rust Build / build (push) Successful in 43s
Rust Build / Check (pull_request) Successful in 33s
Rust Build / Rustfmt (pull_request) Successful in 27s
Rust Build / Test Suite (pull_request) Successful in 36s
Rust Build / Clippy (pull_request) Successful in 34s
Rust Build / build (pull_request) Successful in 37s
Reviewed-on: #37
Co-authored-by: phoenix <kundeng00@pm.me>
Co-committed-by: phoenix <kundeng00@pm.me>
2025-07-23 20:25:05 +00:00
99bb72ffb2 Removing hard coded user_id (#38)
Some checks failed
Rust Build / Check (push) Failing after 39s
Release Tagging / release (push) Successful in 43s
Rust Build / Test Suite (push) Failing after 36s
Rust Build / Rustfmt (push) Successful in 30s
Rust Build / Clippy (push) Failing after 35s
Rust Build / build (push) Failing after 1m28s
Rust Build / Check (pull_request) Failing after 32s
Rust Build / Rustfmt (pull_request) Successful in 28s
Rust Build / Clippy (pull_request) Failing after 35s
Rust Build / Test Suite (pull_request) Failing after 1m10s
Rust Build / build (pull_request) Failing after 35s
Reviewed-on: #38
Co-authored-by: phoenix <kundeng00@pm.me>
Co-committed-by: phoenix <kundeng00@pm.me>
2025-07-23 01:18:35 +00:00
111d16515f Wipe data from CoverArt queue (#36)
Some checks failed
Release Tagging / release (push) Successful in 32s
Rust Build / Check (push) Failing after 34s
Rust Build / Test Suite (push) Failing after 37s
Rust Build / Rustfmt (push) Successful in 29s
Rust Build / Clippy (push) Failing after 36s
Rust Build / build (push) Failing after 37s
Rust Build / Check (pull_request) Failing after 1m58s
Rust Build / Test Suite (pull_request) Failing after 1m21s
Rust Build / Rustfmt (pull_request) Successful in 29s
Rust Build / Clippy (pull_request) Failing after 1m7s
Rust Build / build (pull_request) Failing after 2m5s
Reviewed-on: #36
Co-authored-by: phoenix <kundeng00@pm.me>
Co-committed-by: phoenix <kundeng00@pm.me>
2025-07-15 20:10:12 +00:00
47bf24180b Wipe data from song queue (#35)
Some checks failed
Release Tagging / release (push) Successful in 33s
Rust Build / Check (push) Failing after 35s
Rust Build / Test Suite (push) Failing after 41s
Rust Build / Rustfmt (push) Successful in 30s
Rust Build / Clippy (push) Failing after 41s
Rust Build / build (push) Failing after 40s
Rust Build / Check (pull_request) Failing after 36s
Rust Build / Test Suite (pull_request) Failing after 37s
Rust Build / Rustfmt (pull_request) Successful in 28s
Rust Build / Clippy (pull_request) Failing after 34s
Rust Build / build (pull_request) Failing after 35s
Reviewed-on: #35
Co-authored-by: phoenix <kundeng00@pm.me>
Co-committed-by: phoenix <kundeng00@pm.me>
2025-07-15 19:49:24 +00:00
c16ad062d4 Create coverArt (#34)
Some checks failed
Release Tagging / release (push) Successful in 30s
Rust Build / Check (push) Failing after 32s
Rust Build / Check (pull_request) Failing after 33s
Rust Build / Test Suite (push) Failing after 34s
Rust Build / Rustfmt (push) Successful in 28s
Rust Build / Clippy (push) Failing after 37s
Rust Build / build (push) Failing after 36s
Rust Build / Test Suite (pull_request) Failing after 38s
Rust Build / Rustfmt (pull_request) Successful in 30s
Rust Build / Clippy (pull_request) Failing after 38s
Rust Build / build (pull_request) Failing after 38s
Reviewed-on: #34
Co-authored-by: phoenix <kundeng00@pm.me>
Co-committed-by: phoenix <kundeng00@pm.me>
2025-07-15 19:15:26 +00:00
a779e13a77 Create song (#33)
All checks were successful
Release Tagging / release (push) Successful in 28s
Rust Build / Check (push) Successful in 32s
Rust Build / Test Suite (push) Successful in 33s
Rust Build / Rustfmt (push) Successful in 24s
Rust Build / Clippy (push) Successful in 33s
Rust Build / build (push) Successful in 38s
Rust Build / Check (pull_request) Successful in 37s
Rust Build / Test Suite (pull_request) Successful in 38s
Rust Build / Rustfmt (pull_request) Successful in 30s
Rust Build / Clippy (pull_request) Successful in 35s
Rust Build / build (pull_request) Successful in 44s
Reviewed-on: #33
Co-authored-by: phoenix <kundeng00@pm.me>
Co-committed-by: phoenix <kundeng00@pm.me>
2025-07-15 00:53:12 +00:00
fe61fe3efb Tag release change (#32)
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 32s
Rust Build / Rustfmt (push) Successful in 24s
Rust Build / Clippy (push) Successful in 31s
Rust Build / build (push) Successful in 37s
Rust Build / Check (pull_request) Successful in 1m17s
Rust Build / Test Suite (pull_request) Successful in 1m35s
Rust Build / Rustfmt (pull_request) Successful in 25s
Rust Build / Clippy (pull_request) Successful in 1m23s
Rust Build / build (pull_request) Successful in 2m53s
Reviewed-on: #32
Co-authored-by: phoenix <kundeng00@pm.me>
Co-committed-by: phoenix <kundeng00@pm.me>
2025-06-29 22:20:40 +00:00
f9f3dbda36 Refactoring (#31)
All checks were successful
Rust Build / Check (push) Successful in 33s
Rust Build / Check (pull_request) Successful in 35s
Rust Build / build (push) Successful in 41s
Release Tagging / release (push) Successful in 32s
Rust Build / Test Suite (push) Successful in 37s
Rust Build / Rustfmt (push) Successful in 26s
Rust Build / Clippy (push) Successful in 33s
Rust Build / Test Suite (pull_request) Successful in 35s
Rust Build / Rustfmt (pull_request) Successful in 27s
Rust Build / Clippy (pull_request) Successful in 31s
Rust Build / build (pull_request) Successful in 37s
Reviewed-on: #31
Co-authored-by: phoenix <kundeng00@pm.me>
Co-committed-by: phoenix <kundeng00@pm.me>
2025-06-29 22:08:23 +00:00
59ce1c294c Update dependencies (#30)
Some checks failed
Release Tagging / release (push) Successful in 31s
Rust Build / Check (pull_request) Successful in 33s
Rust Build / Check (push) Successful in 33s
Rust Build / Test Suite (pull_request) Successful in 35s
Rust Build / Rustfmt (pull_request) Successful in 24s
Rust Build / Clippy (pull_request) Failing after 32s
Rust Build / build (pull_request) Successful in 54s
Rust Build / Test Suite (push) Successful in 30s
Rust Build / Rustfmt (push) Successful in 24s
Rust Build / Clippy (push) Failing after 29s
Rust Build / build (push) Successful in 34s
Reviewed-on: #30
Co-authored-by: phoenix <kundeng00@pm.me>
Co-committed-by: phoenix <kundeng00@pm.me>
2025-06-29 21:50:34 +00:00
cd1be017e5 rust std change (#29)
Some checks failed
Rust Build / Check (push) Has been cancelled
Release Tagging / release (push) Has been cancelled
Rust Build / Test Suite (push) Has been cancelled
Rust Build / Rustfmt (push) Has been cancelled
Rust Build / Clippy (push) Has been cancelled
Rust Build / build (push) Has been cancelled
Rust Build / Check (pull_request) Successful in 33s
Rust Build / Test Suite (pull_request) Successful in 37s
Rust Build / Rustfmt (pull_request) Successful in 25s
Rust Build / Clippy (pull_request) Failing after 32s
Rust Build / build (pull_request) Successful in 38s
Reviewed-on: #29
Co-authored-by: phoenix <kundeng00@pm.me>
Co-committed-by: phoenix <kundeng00@pm.me>
2025-06-29 21:50:04 +00:00
2f05c20d4e update queued song (#28)
All checks were successful
Rust Build / build (push) Successful in 41s
Rust Build / Check (push) Successful in 33s
Rust Build / Check (pull_request) Successful in 35s
Rust Build / Test Suite (push) Successful in 36s
Rust Build / Rustfmt (push) Successful in 25s
Rust Build / Clippy (push) Successful in 33s
Rust Build / Test Suite (pull_request) Successful in 38s
Rust Build / Clippy (pull_request) Successful in 34s
Rust Build / build (pull_request) Successful in 45s
Release Tagging / release (push) Successful in 31s
Rust Build / Rustfmt (pull_request) Successful in 25s
Reviewed-on: #28
Co-authored-by: phoenix <kundeng00@pm.me>
Co-committed-by: phoenix <kundeng00@pm.me>
2025-06-28 23:23:41 +00:00
e138bf7a2e Apply metadata to queued song (#27)
All checks were successful
Rust Build / Clippy (push) Successful in 35s
Rust Build / build (push) Successful in 41s
Rust Build / Test Suite (pull_request) Successful in 35s
Release Tagging / release (push) Successful in 31s
Rust Build / Check (push) Successful in 33s
Rust Build / Check (pull_request) Successful in 33s
Rust Build / Test Suite (push) Successful in 37s
Rust Build / Rustfmt (push) Successful in 25s
Rust Build / Rustfmt (pull_request) Successful in 28s
Rust Build / Clippy (pull_request) Successful in 36s
Rust Build / build (pull_request) Successful in 44s
Reviewed-on: #27
Co-authored-by: phoenix <kundeng00@pm.me>
Co-committed-by: phoenix <kundeng00@pm.me>
2025-06-26 22:40:04 +00:00
29b806fd02 Get queued coverart data (#26)
All checks were successful
Release Tagging / release (push) Successful in 28s
Rust Build / Check (push) Successful in 31s
Rust Build / Test Suite (push) Successful in 33s
Rust Build / Rustfmt (push) Successful in 24s
Rust Build / Clippy (push) Successful in 31s
Rust Build / build (push) Successful in 37s
Rust Build / Check (pull_request) Successful in 32s
Rust Build / Test Suite (pull_request) Successful in 32s
Rust Build / Rustfmt (pull_request) Successful in 23s
Rust Build / Clippy (pull_request) Successful in 31s
Rust Build / build (pull_request) Successful in 37s
Reviewed-on: #26
Co-authored-by: kdeng00 <kundeng00@pm.me>
Co-committed-by: kdeng00 <kundeng00@pm.me>
2025-06-19 00:54:13 +00:00
557264482f Get queued coverart (#25)
All checks were successful
Rust Build / Check (push) Successful in 31s
Rust Build / Test Suite (push) Successful in 35s
Rust Build / Rustfmt (push) Successful in 24s
Rust Build / Clippy (push) Successful in 31s
Rust Build / build (push) Successful in 39s
Release Tagging / release (push) Successful in 43s
Rust Build / Check (pull_request) Successful in 32s
Rust Build / Test Suite (pull_request) Successful in 46s
Rust Build / Rustfmt (pull_request) Successful in 25s
Rust Build / Clippy (pull_request) Successful in 36s
Rust Build / build (pull_request) Successful in 37s
Reviewed-on: #25
Co-authored-by: kdeng00 <kundeng00@pm.me>
Co-committed-by: kdeng00 <kundeng00@pm.me>
2025-06-18 01:07:03 +00:00
4e07ee5d0f Refactoring (#24)
All checks were successful
Release Tagging / release (push) Successful in 30s
Rust Build / Check (push) Successful in 32s
Rust Build / Test Suite (push) Successful in 37s
Rust Build / Rustfmt (push) Successful in 40s
Rust Build / Clippy (push) Successful in 36s
Rust Build / build (push) Successful in 43s
Rust Build / Check (pull_request) Successful in 43s
Rust Build / Test Suite (pull_request) Successful in 35s
Rust Build / Rustfmt (pull_request) Successful in 23s
Rust Build / Clippy (pull_request) Successful in 46s
Rust Build / build (pull_request) Successful in 56s
Reviewed-on: #24
Co-authored-by: kdeng00 <kundeng00@pm.me>
Co-committed-by: kdeng00 <kundeng00@pm.me>
2025-06-14 01:30:49 +00:00
83eafd0005 Workflow changes (#9) (#10)
All checks were successful
Release Tagging / release (push) Successful in 40s
Rust Build / Check (push) Successful in 42s
Rust Build / Test Suite (push) Successful in 38s
Rust Build / Rustfmt (push) Successful in 29s
Rust Build / Clippy (push) Successful in 38s
Rust Build / build (push) Successful in 55s
Reviewed-on: #9
Co-authored-by: phoenix <kundeng94@gmail.com>
Co-committed-by: phoenix <kundeng94@gmail.com>
Reviewed-on: #10
Co-committed-by: phoenix <kundeng94@gmail.com>
2025-04-12 17:27:06 +00:00
e3895b6d1a devel (#7)
All checks were successful
Release Tagging / release (push) Successful in 29s
Rust Build / Check (push) Successful in 28s
Rust Build / Test Suite (push) Successful in 28s
Rust Build / Rustfmt (push) Successful in 29s
Rust Build / Clippy (push) Successful in 29s
Rust Build / build (push) Successful in 27s
Reviewed-on: #7
2025-03-30 18:01:52 +00:00
17 changed files with 1268 additions and 204 deletions

18
.dockerignore.yaml Normal file
View File

@@ -0,0 +1,18 @@
# Ignore build artifacts
target/
pkg/
# Ignore git directory
.git/
.gitea/
# Ignore environment files (configure via docker-compose instead)
.env*
# Ignore IDE/editor specific files
.idea/
.vscode/
# Ignore OS specific files
*.DS_Store

View File

@@ -1,2 +1,4 @@
ROOT_DIRECTORY=/home/songparser/mydata
ICARUS_BASE_API_URL=http://localhost:3000
ROOT_DIRECTORY=/usr/local/bin
ICARUS_BASE_API_URL=http://localhost:8000
ICARUS_AUTH_BASE_API_URL=http://localhost:8001
SERVICE_PASSPHRASE=iUOo1fxshf3y1tUGn1yU8l9raPApHCdinW0VdCHdRFEjqhR3Bf02aZzsKbLtaDFH

View File

@@ -1,2 +1,4 @@
ROOT_DIRECTORY=/home/songparser/mydata
ICARUS_BASE_API_URL=http://localhost:3000
ICARUS_AUTH_BASE_API_URL=http://localhost:3001
SERVICE_PASSPHRASE=iUOo1fxshf3y1tUGn1yU8l9raPApHCdinW0VdCHdRFEjqhR3Bf02aZzsKbLtaDFH

View File

@@ -3,7 +3,6 @@ name: Release Tagging
on:
push:
branches:
- main
- devel
jobs:
@@ -50,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

View File

@@ -18,7 +18,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: 1.86.0
toolchain: 1.88.0
- run: |
mkdir -p ~/.ssh
echo "${{ secrets.MYREPO_TOKEN }}" > ~/.ssh/gitlab_deploy_key
@@ -36,7 +36,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: 1.86.0
toolchain: 1.88.0
- run: |
mkdir -p ~/.ssh
echo "${{ secrets.MYREPO_TOKEN }}" > ~/.ssh/gitlab_deploy_key
@@ -54,7 +54,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: 1.86.0
toolchain: 1.88.0
- run: rustup component add rustfmt
- run: |
mkdir -p ~/.ssh
@@ -73,7 +73,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: 1.86.0
toolchain: 1.88.0
- run: rustup component add clippy
- run: |
mkdir -p ~/.ssh
@@ -92,7 +92,7 @@ jobs:
- uses: actions/checkout@v4
- uses: actions-rust-lang/setup-rust-toolchain@v1
with:
toolchain: 1.86.0
toolchain: 1.88.0
- run: |
mkdir -p ~/.ssh
echo "${{ secrets.MYREPO_TOKEN }}" > ~/.ssh/gitlab_deploy_key

2
.gitignore vendored
View File

@@ -1,2 +1,4 @@
/target
.env
.env.local
.env.docker

207
Cargo.lock generated
View File

@@ -17,6 +17,21 @@ version = "2.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "512761e0bb2578dd7380c6baaa0f4ce03e84f95e960231d1dec8bf4d7d6e2627"
[[package]]
name = "aho-corasick"
version = "1.1.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916"
dependencies = [
"memchr",
]
[[package]]
name = "anyhow"
version = "1.0.99"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b0674a1ddeecb70197781e945de4b3b8ffb61fa939a5597bcf48503737663100"
[[package]]
name = "atomic-waker"
version = "1.1.2"
@@ -62,6 +77,12 @@ version = "3.17.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1628fb46dfa0b37568d12e5edd512553eccf6a22a78e8bde00bb4aed84d5bdbf"
[[package]]
name = "byteorder"
version = "1.5.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b"
[[package]]
name = "bytes"
version = "1.10.1"
@@ -119,6 +140,21 @@ version = "0.8.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "773648b94d0e5d620f64f280777445740e61fe701025087ec8b57f45c791888b"
[[package]]
name = "crc32fast"
version = "1.4.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a97769d94ddab943e4510d138150169a2758b5ef3eb191a9ee688de3e23ef7b3"
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 = "deranged"
version = "0.4.0"
@@ -177,6 +213,16 @@ version = "2.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "37909eebbb50d72f9059c3b6d82c0463f2ff062c9e95845c43a6c9c0355411be"
[[package]]
name = "flate2"
version = "1.1.2"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4a3d7db9596fecd151c5f638c0ee5d5bd487b6e0ea232e5dc96d5250f6f94b1d"
dependencies = [
"crc32fast",
"miniz_oxide",
]
[[package]]
name = "fnv"
version = "1.0.7"
@@ -470,18 +516,27 @@ dependencies = [
[[package]]
name = "icarus_envy"
version = "0.2.2"
source = "git+ssh://git@git.kundeng.us/phoenix/icarus_envy.git?tag=v0.2.2-devel-84ea6e4c22-006#84ea6e4c223f19ff96f6b7cae944e831ef4aa831"
version = "0.3.2"
source = "git+ssh://git@git.kundeng.us/phoenix/icarus_envy.git?tag=v0.3.2-18-d498f60046-006#d498f600468c7e5fcf03a640f8c5b9476765fe96"
dependencies = [
"const_format",
"dotenvy",
]
[[package]]
name = "icarus_models"
version = "0.4.3"
source = "git+ssh://git@git.kundeng.us/phoenix/icarus_models.git?tag=v0.4.3#6aa4c3d74142f5fceb4a6e95078bb3ae0a2d99c5"
name = "icarus_meta"
version = "0.3.0"
source = "git+ssh://git@git.kundeng.us/phoenix/icarus_meta.git?tag=v0.3.0#f87c049ab3139995230485b33038a0425f2e7430"
dependencies = [
"lofty",
]
[[package]]
name = "icarus_models"
version = "0.5.5"
source = "git+ssh://git@git.kundeng.us/phoenix/icarus_models.git?tag=v0.5.5-devel-bd793db08e-111#bd793db08e06b256ffecd9f4528e55e3026fede7"
dependencies = [
"josekit",
"rand",
"serde",
"serde_json",
@@ -628,6 +683,23 @@ version = "1.0.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4a5f13b858c8d314ee3e8f639011f7ccefe71f97f96e50151fb991f267928e2c"
[[package]]
name = "josekit"
version = "0.10.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a808e078330e6af222eb0044b71d4b1ff981bfef43e7bc8133a88234e0c86a0c"
dependencies = [
"anyhow",
"base64",
"flate2",
"openssl",
"regex",
"serde",
"serde_json",
"thiserror",
"time",
]
[[package]]
name = "js-sys"
version = "0.3.77"
@@ -666,6 +738,32 @@ dependencies = [
"scopeguard",
]
[[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.27"
@@ -684,6 +782,16 @@ version = "0.3.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6877bb514081ee2a7ff5ef9de3281f14a4dd4bceac4c09388074a6b5df8a139a"
[[package]]
name = "mime_guess"
version = "2.0.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f7c44f8e672c00fe5308fa235f821cb4198414e1c77935c1ab6948d3fd78550e"
dependencies = [
"mime",
"unicase",
]
[[package]]
name = "miniz_oxide"
version = "0.8.8"
@@ -736,6 +844,15 @@ dependencies = [
"memchr",
]
[[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"
@@ -809,6 +926,12 @@ dependencies = [
"windows-targets 0.52.6",
]
[[package]]
name = "paste"
version = "1.0.15"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a"
[[package]]
name = "percent-encoding"
version = "2.3.1"
@@ -883,13 +1006,12 @@ checksum = "74765f6d916ee2faa39bc8e68e4f3ed8949b48cccdac59983d287a7cb71ce9c5"
[[package]]
name = "rand"
version = "0.9.0"
version = "0.9.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "3779b94aeb87e8bd4e834cee3650289ee9e0d5677f976ecdb6d219e5f4f6cd94"
checksum = "9fbfd9d094a40bf3ae768db9361049ace4c0e04a4fd6b359518bd7b73a73dd97"
dependencies = [
"rand_chacha",
"rand_core",
"zerocopy",
]
[[package]]
@@ -921,10 +1043,39 @@ dependencies = [
]
[[package]]
name = "reqwest"
version = "0.12.19"
name = "regex"
version = "1.11.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "a2f8e5513d63f2e5b386eb5106dc67eaf3f84e95258e210489136b8b92ad6119"
checksum = "b544ef1b4eac5dc2db33ea63606ae9ffcfac26c1416a2806ae0bf5f56b201191"
dependencies = [
"aho-corasick",
"memchr",
"regex-automata",
"regex-syntax",
]
[[package]]
name = "regex-automata"
version = "0.4.9"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "809e8dc61f6de73b46c85f4c96486310fe304c434cfa43669d7b40f711150908"
dependencies = [
"aho-corasick",
"memchr",
"regex-syntax",
]
[[package]]
name = "regex-syntax"
version = "0.8.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c"
[[package]]
name = "reqwest"
version = "0.12.20"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "eabf4c97d9130e2bf606614eb937e86edac8292eaa6f422f995d7e8de1eb1813"
dependencies = [
"base64",
"bytes",
@@ -939,12 +1090,11 @@ dependencies = [
"hyper-rustls",
"hyper-tls",
"hyper-util",
"ipnet",
"js-sys",
"log",
"mime",
"mime_guess",
"native-tls",
"once_cell",
"percent-encoding",
"pin-project-lite",
"rustls-pki-types",
@@ -1107,6 +1257,7 @@ version = "1.0.140"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "20068b6e96dc6c9bd23e01df8827e6c7e1f2fddd43c21810382803c136b99373"
dependencies = [
"indexmap",
"itoa",
"memchr",
"ryu",
@@ -1167,11 +1318,13 @@ dependencies = [
[[package]]
name = "songparser"
version = "0.1.0"
version = "0.2.5"
dependencies = [
"futures",
"icarus_envy",
"icarus_meta",
"icarus_models",
"rand",
"reqwest",
"serde",
"serde_json",
@@ -1257,6 +1410,26 @@ dependencies = [
"windows-sys 0.59.0",
]
[[package]]
name = "thiserror"
version = "2.0.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0b0949c3a6c842cbde3f1686d6eea5a010516deb7085f79db747562d4102f41e"
dependencies = [
"thiserror-impl",
]
[[package]]
name = "thiserror-impl"
version = "2.0.14"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cc5b44b4ab9c2fdd0e0512e6bece8388e214c0749f5862b114cc5b7a25daf227"
dependencies = [
"proc-macro2",
"quote",
"syn",
]
[[package]]
name = "time"
version = "0.3.41"
@@ -1430,6 +1603,12 @@ version = "0.2.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e421abadd41a4225275504ea4d6566923418b7f05506fbc9c0fe86ba7396114b"
[[package]]
name = "unicase"
version = "2.8.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "75b844d17643ee918803943289730bec8aac480150456169e647ed0b576ba539"
[[package]]
name = "unicode-ident"
version = "1.0.18"

View File

@@ -1,16 +1,18 @@
[package]
name = "songparser"
version = "0.1.0"
version = "0.2.5"
edition = "2024"
rust-version = "1.86"
rust-version = "1.88"
[dependencies]
tokio = { version = "1.44.1", features = ["full"] }
tokio = { version = "1.45.1", features = ["full"] }
futures = { version = "0.3.31" }
reqwest = { version = "0.12.19", features = ["json", "stream"] }
serde = { version = "1.0.218", features = ["derive"] }
serde_json = { version = "1.0.139" }
reqwest = { version = "0.12.20", features = ["json", "stream", "multipart"] }
serde = { version = "1.0.219", features = ["derive"] }
serde_json = { version = "1.0.140" }
time = { version = "0.3.41", features = ["macros", "serde"] }
uuid = { version = "1.16.0", features = ["v4", "serde"] }
icarus_models = { git = "ssh://git@git.kundeng.us/phoenix/icarus_models.git", tag = "v0.4.3" }
icarus_envy = { git = "ssh://git@git.kundeng.us/phoenix/icarus_envy.git", tag = "v0.2.2-devel-84ea6e4c22-006" }
uuid = { version = "1.17.0", features = ["v4", "serde"] }
rand = { version = "0.9.1" }
icarus_meta = { git = "ssh://git@git.kundeng.us/phoenix/icarus_meta.git", tag = "v0.3.0" }
icarus_models = { git = "ssh://git@git.kundeng.us/phoenix/icarus_models.git", tag = "v0.5.5-devel-bd793db08e-111" }
icarus_envy = { git = "ssh://git@git.kundeng.us/phoenix/icarus_envy.git", tag = "v0.3.2-18-d498f60046-006" }

66
Dockerfile Normal file
View File

@@ -0,0 +1,66 @@
# Stage 1: Build the application
# Use a specific Rust version for reproducibility. Choose one that matches your development environment.
# Using slim variant for smaller base image
FROM rust:1.88 as builder
# Set the working directory inside the container
WORKDIR /usr/src/app
# Install build dependencies if needed (e.g., git for cloning)
RUN apt-get update && apt-get install -y --no-install-recommends \
pkg-config libssl3 \
ca-certificates \
openssh-client git \
&& rm -rf /var/lib/apt/lists/*
# << --- ADD HOST KEY HERE --- >>
# Replace 'yourgithost.com' with the actual hostname (e.g., github.com)
RUN mkdir -p -m 0700 ~/.ssh && \
ssh-keyscan git.kundeng.us >> ~/.ssh/known_hosts
# Copy Cargo manifests
COPY Cargo.toml Cargo.lock ./
# Build *only* dependencies to leverage Docker cache
# This dummy build caches dependencies as a separate layer
RUN --mount=type=ssh mkdir src && \
echo "fn main() {println!(\"if you see this, the build broke\")}" > src/main.rs && \
cargo build --release --quiet && \
rm -rf src target/release/deps/songparser* # Clean up dummy build artifacts (replace songparser)
# Copy the actual source code
COPY src ./src
# If you have other directories like `templates` or `static`, copy them too
COPY .env ./.env
# << --- SSH MOUNT ADDED HERE --- >>
# Build *only* dependencies to leverage Docker cache
# This dummy build caches dependencies as a separate layer
# Mount the SSH agent socket for this command
RUN --mount=type=ssh \
cargo build --release --quiet
# Stage 2: Create the final, smaller runtime image
# Use a minimal base image like debian-slim or even distroless for security/size
FROM ubuntu:24.04
# Install runtime dependencies if needed (e.g., SSL certificates)
RUN apt-get update && apt-get install -y ca-certificates libssl-dev libssl3 && rm -rf /var/lib/apt/lists/*
# Set the working directory
WORKDIR /usr/local/bin
# Copy the compiled binary from the builder stage
# Replace 'songparser' with the actual name of your binary (usually the crate name)
COPY --from=builder /usr/src/app/target/release/songparser .
# Copy other necessary files like .env (if used for runtime config) or static assets
# It's generally better to configure via environment variables in Docker though
COPY --from=builder /usr/src/app/.env .
# Expose the port your Axum app listens on (e.g., 3000 or 8000)
# EXPOSE 3000
# Set the command to run your application
# Ensure this matches the binary name copied above
CMD ["./songparser"]

15
docker-compose.yaml Normal file
View File

@@ -0,0 +1,15 @@
version: '3.8' # Use a recent version
services:
# Your Rust Application Service
songparser:
build: # Tells docker-compose to build the Dockerfile in the current directory
context: .
ssh: ["default"] # Uses host's SSH agent
container_name: songparser # Optional: Give the container a specific name
# ports:
# Map host port 8000 to container port 3000 (adjust as needed)
# - "8002:3002"
env_file:
- .env
restart: unless-stopped # Optional: Restart policy

169
src/api.rs Normal file
View File

@@ -0,0 +1,169 @@
pub async fn fetch_next_queue_item(
app: &crate::config::App,
) -> Result<reqwest::Response, reqwest::Error> {
let client = reqwest::Client::new();
let fetch_endpoint = String::from("api/v2/song/queue/next");
let api_url = format!("{}/{fetch_endpoint}", app.uri);
let (key, header) = auth_header(app).await;
client.get(api_url).header(key, header).send().await
}
pub async fn auth_header(
app: &crate::config::App,
) -> (reqwest::header::HeaderName, reqwest::header::HeaderValue) {
let bearer = format!("Bearer {}", app.token.token);
let header_value = reqwest::header::HeaderValue::from_str(&bearer).unwrap();
(reqwest::header::AUTHORIZATION, header_value)
}
pub mod parsing {
use futures::StreamExt;
pub async fn parse_response_into_bytes(
response: reqwest::Response,
) -> Result<Vec<u8>, reqwest::Error> {
// TODO: At some point, handle the flow if the size is small or
// large
let mut byte_stream = response.bytes_stream();
let mut all_bytes = Vec::new();
while let Some(chunk) = byte_stream.next().await {
let chunk = chunk?;
all_bytes.extend_from_slice(&chunk);
}
Ok(all_bytes)
}
}
pub mod fetch_song_queue_data {
pub async fn get_data(
app: &crate::config::App,
id: &uuid::Uuid,
) -> Result<reqwest::Response, reqwest::Error> {
let client = reqwest::Client::new();
let endpoint = String::from("api/v2/song/queue");
let api_url = format!("{}/{endpoint}/{id}", app.uri);
let (key, header) = super::auth_header(app).await;
client.get(api_url).header(key, header).send().await
}
}
pub mod get_metadata_queue {
pub async fn get(
app: &crate::config::App,
song_queue_id: &uuid::Uuid,
) -> Result<reqwest::Response, reqwest::Error> {
let client = reqwest::Client::new();
let endpoint = String::from("api/v2/song/metadata/queue");
let api_url = format!("{}/{endpoint}", app.uri);
let (key, header) = super::auth_header(app).await;
client
.get(api_url)
.query(&[("song_queue_id", song_queue_id)])
.header(key, header)
.send()
.await
}
pub mod response {
use serde::{Deserialize, Serialize};
#[derive(Clone, Debug, Deserialize, Serialize)]
pub struct Metadata {
pub song_queue_id: uuid::Uuid,
pub album: String,
pub album_artist: String,
pub artist: String,
pub disc: i32,
pub disc_count: i32,
pub duration: i64,
pub genre: String,
pub title: String,
pub track: i32,
pub track_count: i32,
pub year: i32,
}
#[derive(Debug, Deserialize, Serialize)]
pub struct QueueItem {
pub id: uuid::Uuid,
pub metadata: Metadata,
#[serde(with = "time::serde::rfc3339")]
pub created_at: time::OffsetDateTime,
pub song_queue_id: uuid::Uuid,
}
#[derive(Debug, Deserialize, Serialize)]
pub struct Response {
pub message: String,
pub data: Vec<QueueItem>,
}
}
}
pub mod get_coverart_queue {
pub async fn get(
app: &crate::config::App,
song_queue_id: &uuid::Uuid,
) -> Result<reqwest::Response, reqwest::Error> {
let client = reqwest::Client::new();
let endpoint = String::from("api/v2/coverart/queue");
let api_url = format!("{}/{endpoint}", app.uri);
let (key, header) = super::auth_header(app).await;
client
.get(api_url)
.query(&[("song_queue_id", song_queue_id)])
.header(key, header)
.send()
.await
}
pub async fn get_data(
app: &crate::config::App,
coverart_queue_id: &uuid::Uuid,
) -> Result<reqwest::Response, reqwest::Error> {
let client = reqwest::Client::new();
let endpoint = String::from("api/v2/coverart/queue/data");
let api_url = format!("{}/{endpoint}/{coverart_queue_id}", app.uri);
let (key, header) = super::auth_header(app).await;
client.get(api_url).header(key, header).send().await
}
pub mod response {
use serde::{Deserialize, Serialize};
#[derive(Debug, Deserialize, Serialize)]
pub struct CoverArtQueue {
pub id: uuid::Uuid,
pub song_queue_id: uuid::Uuid,
}
#[derive(Debug, Deserialize, Serialize)]
pub struct Response {
pub message: String,
pub data: Vec<CoverArtQueue>,
}
}
}
pub mod service_token {
pub mod response {
#[derive(Debug, serde::Deserialize, serde::Serialize)]
pub struct Response {
pub message: String,
pub data: Vec<icarus_models::login_result::LoginResult>,
}
}
}
pub mod refresh_token {
pub mod response {
#[derive(Debug, serde::Deserialize, serde::Serialize)]
pub struct Response {
pub message: String,
pub data: Vec<icarus_models::login_result::LoginResult>,
}
}
}

6
src/config.rs Normal file
View File

@@ -0,0 +1,6 @@
#[derive(Default, Debug)]
pub struct App {
pub uri: String,
pub auth_uri: String,
pub token: icarus_models::login_result::LoginResult,
}

View File

@@ -1,95 +1,99 @@
pub mod api;
pub mod config;
pub mod responses;
pub mod the_rest;
pub mod update_queued_song;
pub mod util;
use std::io::Write;
pub const SECONDS_TO_SLEEP: u64 = 5;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let app_base_url = icarus_envy::environment::get_icarus_base_api_url().await;
let mut app = config::App {
uri: icarus_envy::environment::get_icarus_base_api_url().await,
auth_uri: icarus_envy::environment::get_icarus_auth_base_api_url().await,
..Default::default()
};
println!("Base URL: {:?}", app.uri);
println!("Auth URL: {:?}", app.auth_uri);
match auth::get_token(&app).await {
Ok(login_result) => {
app.token = login_result;
}
Err(err) => {
eprintln!("Error: {err:?}");
std::process::exit(-1);
}
};
loop {
println!("Base URL: {}", app_base_url);
println!("Token: {:?}", app.token);
match api::fetch_next_queue_item(&app_base_url).await {
Ok(response) => {
match response
.json::<responses::fetch_next_queue_item::SongQueueItem>()
.await
{
Ok(song_queue_item) => {
if !song_queue_item.data.is_empty() {
println!("Song queue item: {:?}", song_queue_item);
let song_queue_id = song_queue_item.data[0].id;
if auth::did_token_expire(&app.token).await {
println!("Token expired");
app.token = match auth::get_refresh_token(&app).await {
Ok(login_result) => login_result,
Err(err) => {
eprintln!("Error: {err:?}");
continue;
}
};
println!("Fetching song queue data");
match api::fetch_song_queue_data::get_data(
&app_base_url,
&song_queue_id,
)
.await
println!("Token refreshed");
println!("Refreshed token: {:?}", app.token);
} else {
println!("Token did not expire");
}
match is_queue_empty(&app).await {
Ok((empty, song_queue_item)) => {
if !empty {
println!("Queue is not empty");
println!("SongQueueItem: {song_queue_item:?}");
let song_queue_id = song_queue_item.data[0].id;
let user_id = song_queue_item.data[0].user_id;
// TODO: Do something with the result later
match some_work(&app, &song_queue_id, &user_id).await {
Ok((
_song,
_coverart,
(song_queue_id, song_queue_path),
(coverart_queue_id, coverart_queue_path),
)) => {
match wipe_data_from_queues(&app, &song_queue_id, &coverart_queue_id)
.await
{
Ok(response) => {
// Process data here...
let all_bytes =
api::fetch_song_queue_data::response::parse_response(
response,
)
.await?;
let (directory, filename) =
generate_song_queue_dir_and_filename().await;
let save_path =
save_song_to_fs(&directory, &filename, &all_bytes).await;
println!("Saved at: {:?}", save_path);
match api::get_metadata_queue::get(
&app_base_url,
&song_queue_id,
)
.await
{
Ok(response) => {
match response.json::<api::get_metadata_queue::response::Response>().await {
Ok(response) => {
let id = &response.data[0].id;
let metadata = &response.data[0].metadata;
let created_at = &response.data[0].created_at;
println!("Id: {:?}", id);
println!("Metadata: {:?}", metadata);
println!("Created at: {:?}", created_at);
// TODO: Get queued coverart
// TODO: Get queued coverart's data
// TODO: Apply metadata to the queued song (modifying file)
// TODO: Update the queued song with the updated queued song
// TODO: Create song
// TODO: Create coverart
// TODO: Wipe data from queued song
// TODO: Wipe data from queued coverart
}
Err(err) => {
eprintln!("Error: {:?}", err);
}
}
Ok(_) => {
match cleanup(&song_queue_path, &coverart_queue_path).await {
Ok(_) => {
println!("Successful cleanup");
}
Err(err) => {
eprintln!("Error: {:?}", err);
eprintln!("Error: {err:?}");
}
}
}
Err(err) => {
eprintln!("Error fetching song queue data: {:?}", err);
eprintln!("Error: {err:?}");
}
}
} else {
println!("No data to fetch");
}
Err(err) => {
eprintln!("Error: {err:?}");
}
}
Err(err) => {
eprintln!("Error: {:?}", err);
}
} else {
println!("Queue is empty");
}
}
Err(e) => eprintln!("API call failed: {}", e),
Err(err) => {
eprintln!("Error checking if queue is empty: {err:?}");
}
}
println!("Sleeping");
@@ -97,6 +101,315 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
}
}
mod auth {
pub async fn get_token(
app: &crate::config::App,
) -> Result<icarus_models::login_result::LoginResult, std::io::Error> {
let client = reqwest::Client::new();
let endpoint = String::from("api/v2/service/login");
let api_url = format!("{}/{endpoint}", app.auth_uri);
let payload = serde_json::json!({
"passphrase": icarus_envy::environment::get_service_passphrase().await,
});
match client.post(api_url).json(&payload).send().await {
Ok(response) => match response
.json::<crate::api::service_token::response::Response>()
.await
{
Ok(resp) => {
if resp.data.is_empty() {
Err(std::io::Error::other(String::from("No token returned")))
} else {
Ok(resp.data[0].clone())
}
}
Err(err) => Err(std::io::Error::other(err.to_string())),
},
Err(err) => Err(std::io::Error::other(err.to_string())),
}
}
// TODO: Might want to put the functionality within icarus_models at some point
pub async fn did_token_expire(login_result: &icarus_models::login_result::LoginResult) -> bool {
let current_time = time::OffsetDateTime::now_utc();
let expire_time =
time::OffsetDateTime::from_unix_timestamp(login_result.expiration).unwrap();
current_time > expire_time
}
pub async fn get_refresh_token(
app: &crate::config::App,
) -> Result<icarus_models::login_result::LoginResult, std::io::Error> {
let client = reqwest::Client::new();
let endpoint = String::from("api/v2/token/refresh");
let api_url = format!("{}/{endpoint}", app.auth_uri);
let payload = serde_json::json!({
"access_token": app.token.token
});
match client.post(api_url).json(&payload).send().await {
Ok(response) => match response
.json::<crate::api::refresh_token::response::Response>()
.await
{
Ok(resp) => {
if resp.data.is_empty() {
Err(std::io::Error::other(String::from("No token returned")))
} else {
Ok(resp.data[0].clone())
}
}
Err(err) => Err(std::io::Error::other(err.to_string())),
},
Err(err) => Err(std::io::Error::other(err.to_string())),
}
}
}
async fn wipe_data_from_queues(
app: &config::App,
song_queue_id: &uuid::Uuid,
coverart_queue_id: &uuid::Uuid,
) -> Result<(), std::io::Error> {
match the_rest::wipe_data::song_queue::wipe_data(app, song_queue_id).await {
Ok(response) => match response
.json::<the_rest::wipe_data::song_queue::response::Response>()
.await
{
Ok(_resp) => {
match the_rest::wipe_data::coverart_queue::wipe_data(app, coverart_queue_id).await {
Ok(inner_response) => match inner_response
.json::<the_rest::wipe_data::coverart_queue::response::Response>()
.await
{
Ok(_inner_resp) => {
println!("Wiped data from CoverArt queue");
println!("Resp: {_inner_resp:?}");
Ok(())
}
Err(err) => Err(std::io::Error::other(err.to_string())),
},
Err(err) => Err(std::io::Error::other(err.to_string())),
}
}
Err(err) => Err(std::io::Error::other(err.to_string())),
},
Err(err) => Err(std::io::Error::other(err.to_string())),
}
}
async fn cleanup(
song_queue_path: &String,
coverart_queue_path: &String,
) -> Result<(), std::io::Error> {
match the_rest::cleanup::clean_song_queue(song_queue_path) {
Ok(_) => {}
Err(err) => {
eprintln!("Error: Problem cleaning up SongQueue files {err:?}");
}
}
match the_rest::cleanup::clean_coverart_queue(coverart_queue_path) {
Ok(_) => Ok(()),
Err(err) => Err(err),
}
}
async fn is_queue_empty(
app: &config::App,
) -> Result<(bool, responses::fetch_next_queue_item::SongQueueItem), reqwest::Error> {
match api::fetch_next_queue_item(app).await {
Ok(response) => {
match response
.json::<responses::fetch_next_queue_item::SongQueueItem>()
.await
{
Ok(response) => {
if response.data.is_empty() {
Ok((true, response))
} else {
Ok((false, response))
}
}
Err(err) => Err(err),
}
}
Err(err) => Err(err),
}
}
async fn some_work(
app: &crate::config::App,
song_queue_id: &uuid::Uuid,
user_id: &uuid::Uuid,
) -> Result<
(
icarus_models::song::Song,
icarus_models::coverart::CoverArt,
(uuid::Uuid, String),
(uuid::Uuid, String),
),
std::io::Error,
> {
match prep_song(app, song_queue_id).await {
Ok((song_queue_path, coverart_queue_path, metadata, coverart_queue_id)) => {
match apply_metadata(&song_queue_path, &coverart_queue_path, &metadata).await {
Ok(_applied) => {
match update_queued_song::update_queued_song(
app,
&song_queue_path,
song_queue_id,
)
.await
{
Ok(response) => {
match response
.json::<update_queued_song::response::Response>()
.await
{
Ok(_inner_response) => {
println!("Response: {_inner_response:?}");
// TODO: Place this somewhere else
let song_type = String::from("flac");
match the_rest::create_song::create(
app, &metadata, user_id, &song_type,
)
.await
{
Ok(response) => match response
.json::<the_rest::create_song::response::Response>()
.await
{
Ok(resp) => {
println!("Response: {resp:?}");
let song = &resp.data[0];
match the_rest::create_coverart::create(app, &song.id, &coverart_queue_id).await {
Ok(response) => match response.json::<the_rest::create_coverart::response::Response>().await {
Ok(resp) => {
println!("CoverArt sent and successfully parsed response");
println!("json: {resp:?}");
let coverart = &resp.data[0];
Ok((song.clone(), coverart.clone(), (metadata.song_queue_id, song_queue_path), (coverart_queue_id, coverart_queue_path)))
}
Err(err) => {
Err(std::io::Error::other(err.to_string()))
}
}
Err(err) => {
Err(std::io::Error::other(err.to_string()))
}
}
}
Err(err) => Err(std::io::Error::other(err.to_string())),
},
Err(err) => Err(std::io::Error::other(err.to_string())),
}
}
Err(err) => Err(std::io::Error::other(err.to_string())),
}
}
Err(err) => Err(std::io::Error::other(err.to_string())),
}
}
Err(err) => Err(err),
}
}
Err(err) => Err(std::io::Error::other(err.to_string())),
}
}
async fn prep_song(
app: &crate::config::App,
song_queue_id: &uuid::Uuid,
) -> Result<
(
String,
String,
api::get_metadata_queue::response::Metadata,
uuid::Uuid,
),
reqwest::Error,
> {
match api::fetch_song_queue_data::get_data(app, song_queue_id).await {
Ok(response) => {
// Process data here...
match api::parsing::parse_response_into_bytes(response).await {
Ok(song_bytes) => {
let (directory, filename) = generate_song_queue_dir_and_filename().await;
let song_queue_path = save_file_to_fs(&directory, &filename, &song_bytes).await;
println!("Saved at: {song_queue_path:?}");
match api::get_metadata_queue::get(app, song_queue_id).await {
Ok(response) => {
match response
.json::<api::get_metadata_queue::response::Response>()
.await
{
Ok(response) => {
let id = &response.data[0].id;
let created_at = &response.data[0].created_at;
let metadata = &response.data[0].metadata;
println!("Id: {id:?}");
println!("Metadata: {metadata:?}");
println!("Created at: {created_at:?}");
println!("Getting coverart queue");
match api::get_coverart_queue::get(app, song_queue_id).await {
Ok(response) => {
match response.json::<api::get_coverart_queue::response::Response>().await {
Ok(response) => {
let coverart_queue_id = &response.data[0].id;
println!("Coverart queue Id: {coverart_queue_id:?}");
match api::get_coverart_queue::get_data(app, coverart_queue_id).await {
Ok(response) => match api::parsing::parse_response_into_bytes(response).await {
Ok(coverart_queue_bytes) => {
let (directory, filename) = generate_coverart_queue_dir_and_filename().await;
let coverart_queue_path = save_file_to_fs(&directory, &filename, &coverart_queue_bytes).await;
println!("Saved coverart queue file at: {coverart_queue_path:?}");
let c_path = util::path_buf_to_string(&coverart_queue_path);
let s_path = util::path_buf_to_string(&song_queue_path);
Ok((s_path, c_path, metadata.clone(), *coverart_queue_id))
}
Err(err) => {
Err(err)
}
}
Err(err) => {
Err(err)
}
}
}
Err(err) => {
Err(err)
}
}
}
Err(err) => Err(err),
}
}
Err(err) => Err(err),
}
}
Err(err) => Err(err),
}
}
Err(err) => Err(err),
}
}
Err(err) => Err(err),
}
}
// TODO: Consider having something like this in icarus_models
pub async fn generate_song_queue_dir_and_filename() -> (String, String) {
let mut song = icarus_models::song::Song::default();
@@ -107,8 +420,37 @@ pub async fn generate_song_queue_dir_and_filename() -> (String, String) {
(song.directory, song.filename)
}
// TODO: Consider having something like this in icarus_models
pub async fn generate_coverart_queue_dir_and_filename() -> (String, String) {
use rand::Rng;
let mut filename: String = String::new();
let filename_len = 10;
let some_chars: String = String::from("abcdefghij0123456789");
let mut rng = rand::rng();
for _i in 0..filename_len {
let random_number: i32 = rng.random_range(0..=19);
let index = random_number as usize;
let rando_char = some_chars.chars().nth(index);
if let Some(c) = rando_char {
filename.push(c);
}
}
// TODO: Do not hard code the file extension
filename += ".jpeg";
// TODO: Consider separating song and coverart when saving to the filesystem
let directory = icarus_envy::environment::get_root_directory().await;
(directory, filename)
}
// TODO: Check to see if this is available in icarus_models
pub async fn save_song_to_fs(
pub async fn save_file_to_fs(
directory: &String,
filename: &String,
data: &[u8],
@@ -124,115 +466,142 @@ pub async fn save_song_to_fs(
save_path
}
mod responses {
pub mod fetch_next_queue_item {
use serde::{Deserialize, Serialize};
pub async fn apply_metadata(
song_queue_path: &String,
coverart_queue_path: &String,
metadata: &api::get_metadata_queue::response::Metadata,
) -> Result<bool, std::io::Error> {
// Apply metadata fields
let types = icarus_meta::types::all_metadata_types();
#[derive(Debug, Deserialize, Serialize)]
pub struct QueueItem {
pub id: uuid::Uuid,
pub filename: String,
pub status: String,
}
#[derive(Debug, Deserialize, Serialize)]
pub struct SongQueueItem {
pub message: String,
pub data: Vec<QueueItem>,
}
}
}
mod api {
pub async fn fetch_next_queue_item(
base_url: &String,
) -> Result<reqwest::Response, reqwest::Error> {
let client = reqwest::Client::new();
let fetch_endpoint = String::from("api/v2/song/queue/next");
let api_url = format!("{}/{}", base_url, fetch_endpoint);
client.get(api_url).send().await
}
pub mod fetch_song_queue_data {
pub async fn get_data(
base_url: &String,
id: &uuid::Uuid,
) -> Result<reqwest::Response, reqwest::Error> {
let client = reqwest::Client::new();
let endpoint = String::from("api/v2/song/queue");
let api_url = format!("{}/{}/{}", base_url, endpoint, id);
client.get(api_url).send().await
}
pub mod response {
use futures::StreamExt;
pub async fn parse_response(
response: reqwest::Response,
) -> Result<Vec<u8>, reqwest::Error> {
// TODO: At some point, handle the flow if the size is small or
// large
let mut byte_stream = response.bytes_stream();
let mut all_bytes = Vec::new();
while let Some(chunk) = byte_stream.next().await {
let chunk = chunk?;
all_bytes.extend_from_slice(&chunk);
for t in types {
match t {
icarus_meta::types::Type::Album => {
let meta_type =
icarus_meta::types::MetadataType::from_string(metadata.album.clone());
match icarus_meta::meta::metadata::set_meta_value(t, song_queue_path, meta_type) {
Ok(_) => {}
Err(_err) => {
return Err(_err);
}
}
}
icarus_meta::types::Type::AlbumArtist => {
let meta_type =
icarus_meta::types::MetadataType::from_string(metadata.album_artist.clone());
match icarus_meta::meta::metadata::set_meta_value(t, song_queue_path, meta_type) {
Ok(_) => {}
Err(_err) => {
return Err(_err);
}
}
}
icarus_meta::types::Type::Artist => {
let meta_type =
icarus_meta::types::MetadataType::from_string(metadata.artist.clone());
match icarus_meta::meta::metadata::set_meta_value(t, song_queue_path, meta_type) {
Ok(_) => {}
Err(_err) => {
return Err(_err);
}
}
}
icarus_meta::types::Type::Date => {
// TODO: Do something about this discrepancy
let meta_type =
icarus_meta::types::MetadataType::from_string(metadata.year.to_string());
match icarus_meta::meta::metadata::set_meta_value(t, song_queue_path, meta_type) {
Ok(_) => {}
Err(_err) => {
return Err(_err);
}
}
}
icarus_meta::types::Type::Disc => {
let meta_type = icarus_meta::types::MetadataType::from_int(metadata.disc);
match icarus_meta::meta::metadata::set_meta_value(t, song_queue_path, meta_type) {
Ok(_) => {}
Err(_err) => {
return Err(_err);
}
}
}
icarus_meta::types::Type::Genre => {
let meta_type =
icarus_meta::types::MetadataType::from_string(metadata.genre.clone());
match icarus_meta::meta::metadata::set_meta_value(t, song_queue_path, meta_type) {
Ok(_) => {}
Err(_err) => {
return Err(_err);
}
}
}
icarus_meta::types::Type::Title => {
let meta_type =
icarus_meta::types::MetadataType::from_string(metadata.title.clone());
match icarus_meta::meta::metadata::set_meta_value(t, song_queue_path, meta_type) {
Ok(_) => {}
Err(_err) => {
return Err(_err);
}
}
}
icarus_meta::types::Type::Track => {
let meta_type = icarus_meta::types::MetadataType::from_int(metadata.track);
match icarus_meta::meta::metadata::set_meta_value(t, song_queue_path, meta_type) {
Ok(_) => {}
Err(_err) => {
return Err(_err);
}
}
}
icarus_meta::types::Type::TrackCount => {
let meta_type = icarus_meta::types::MetadataType::from_int(metadata.track_count);
match icarus_meta::meta::metadata::set_meta_value(t, song_queue_path, meta_type) {
Ok(_) => {}
Err(_err) => {
return Err(_err);
}
}
}
icarus_meta::types::Type::DiscCount => {
let meta_type = icarus_meta::types::MetadataType::from_int(metadata.disc_count);
match icarus_meta::meta::metadata::set_meta_value(t, song_queue_path, meta_type) {
Ok(_) => {}
Err(_err) => {
return Err(_err);
}
}
Ok(all_bytes)
}
}
}
pub mod get_metadata_queue {
pub async fn get(
base_url: &String,
song_queue_id: &uuid::Uuid,
) -> Result<reqwest::Response, reqwest::Error> {
let client = reqwest::Client::new();
let endpoint = String::from("api/v2/song/metadata/queue");
let api_url = format!("{}/{}", base_url, endpoint);
client
.get(api_url)
.query(&[("song_queue_id", song_queue_id)])
.send()
.await
}
pub mod response {
use serde::{Deserialize, Serialize};
#[derive(Debug, Deserialize, Serialize)]
pub struct Metadata {
pub id: uuid::Uuid,
pub album: String,
pub album_artist: String,
pub artist: String,
pub disc: i32,
pub disc_count: i32,
pub duration: i64,
pub genre: String,
pub title: String,
pub track: i32,
pub track_count: i32,
pub year: i32,
// Apply coverart
match icarus_meta::meta::coverart::contains_coverart(song_queue_path) {
Ok((exists, size)) => {
if exists {
println!("Coverart exists: {size:?} size");
match icarus_meta::meta::coverart::remove_coverart(song_queue_path) {
Ok(_data) => {}
Err(err) => {
return Err(err);
}
}
}
#[derive(Debug, Deserialize, Serialize)]
pub struct QueueItem {
pub id: uuid::Uuid,
pub metadata: Metadata,
#[serde(with = "time::serde::rfc3339")]
pub created_at: time::OffsetDateTime,
pub song_queue_id: uuid::Uuid,
}
#[derive(Debug, Deserialize, Serialize)]
pub struct Response {
pub message: String,
pub data: Vec<QueueItem>,
match icarus_meta::meta::coverart::set_coverart(song_queue_path, coverart_queue_path) {
Ok(_data) => {
if _data.is_empty() {
println!("There was an issue");
Ok(false)
} else {
println!("Success in applying coverart to song");
Ok(true)
}
}
Err(err) => Err(err),
}
}
Err(err) => Err(err),
}
}

17
src/responses.rs Normal file
View File

@@ -0,0 +1,17 @@
pub mod fetch_next_queue_item {
use serde::{Deserialize, Serialize};
#[derive(Debug, Deserialize, Serialize)]
pub struct QueueItem {
pub id: uuid::Uuid,
pub filename: String,
pub status: String,
pub user_id: uuid::Uuid,
}
#[derive(Debug, Deserialize, Serialize)]
pub struct SongQueueItem {
pub message: String,
pub data: Vec<QueueItem>,
}
}

179
src/the_rest.rs Normal file
View File

@@ -0,0 +1,179 @@
// TODO: Refactor this file when this app is functional
pub mod create_song {
pub async fn create(
app: &crate::config::App,
metadata_queue: &crate::api::get_metadata_queue::response::Metadata,
user_id: &uuid::Uuid,
song_type: &String,
) -> Result<reqwest::Response, reqwest::Error> {
let payload = serde_json::json!(
{
"album": &metadata_queue.album,
"album_artist": &metadata_queue.album_artist,
"artist": &metadata_queue.artist,
"disc": metadata_queue.disc,
"disc_count": metadata_queue.disc_count,
"duration": metadata_queue.duration,
"genre": &metadata_queue.genre,
"title": &metadata_queue.title,
"track": metadata_queue.track,
"track_count": metadata_queue.track_count,
"date": metadata_queue.year.to_string(),
"audio_type": &song_type,
"user_id": &user_id,
"song_queue_id": &metadata_queue.song_queue_id,
}
);
let client = reqwest::Client::builder().build()?;
let url = format!("{}/api/v2/song", app.uri);
let (key, header) = crate::api::auth_header(app).await;
let request = client.post(url).json(&payload).header(key, header);
request.send().await
}
pub mod response {
#[derive(Debug, serde::Deserialize, serde::Serialize)]
pub struct Response {
pub message: String,
pub data: Vec<icarus_models::song::Song>,
}
}
}
pub mod create_coverart {
pub async fn create(
app: &crate::config::App,
song_id: &uuid::Uuid,
coverart_queue_id: &uuid::Uuid,
) -> Result<reqwest::Response, reqwest::Error> {
let client = reqwest::Client::builder().build()?;
let url = format!("{}/api/v2/coverart", app.uri);
let payload = get_payload(song_id, coverart_queue_id);
let (key, header) = crate::api::auth_header(app).await;
let request = client.post(url).json(&payload).header(key, header);
request.send().await
}
fn get_payload(song_id: &uuid::Uuid, coverart_queue_id: &uuid::Uuid) -> serde_json::Value {
serde_json::json!({
"song_id": &song_id,
"coverart_queue_id": &coverart_queue_id,
})
}
pub mod response {
#[derive(Debug, serde::Deserialize, serde::Serialize)]
pub struct Response {
pub message: String,
pub data: Vec<icarus_models::coverart::CoverArt>,
}
}
}
pub mod wipe_data {
pub mod song_queue {
pub async fn wipe_data(
app: &crate::config::App,
song_queue_id: &uuid::Uuid,
) -> Result<reqwest::Response, reqwest::Error> {
let client = reqwest::Client::builder().build()?;
let url = format!("{}/api/v2/song/queue/data/wipe", app.uri);
let payload = serde_json::json!({
"song_queue_id": song_queue_id
});
let (key, header) = crate::api::auth_header(app).await;
let request = client.patch(url).json(&payload).header(key, header);
request.send().await
}
pub mod response {
#[derive(Debug, serde::Deserialize, serde::Serialize)]
pub struct Response {
pub message: String,
pub data: Vec<uuid::Uuid>,
}
}
}
pub mod coverart_queue {
pub async fn wipe_data(
app: &crate::config::App,
coverart_queue_id: &uuid::Uuid,
) -> Result<reqwest::Response, reqwest::Error> {
let client = reqwest::Client::builder().build()?;
let url = format!("{}/api/v2/coverart/queue/data/wipe", app.uri);
let payload = serde_json::json!({
"coverart_queue_id": coverart_queue_id
});
let (key, header) = crate::api::auth_header(app).await;
let request = client.patch(url).json(&payload).header(key, header);
request.send().await
}
pub mod response {
#[derive(Debug, serde::Deserialize, serde::Serialize)]
pub struct Response {
pub message: String,
pub data: Vec<uuid::Uuid>,
}
}
}
}
pub mod cleanup {
pub fn clean_song_queue(song_queue_path: &String) -> Result<(), std::io::Error> {
let file_path = std::path::Path::new(song_queue_path);
if file_path.exists() {
match std::fs::remove_file(file_path) {
Ok(_) => {
if check_file_existence(song_queue_path) {
Err(std::io::Error::other(String::from(
"SongQueue file exists after a deletion",
)))
} else {
Ok(())
}
}
Err(err) => Err(std::io::Error::other(err.to_string())),
}
} else {
Err(std::io::Error::other(String::from(
"SongQueue file path does not exists",
)))
}
}
pub fn clean_coverart_queue(coverart_queue_path: &String) -> Result<(), std::io::Error> {
let coverart_file_path = std::path::Path::new(coverart_queue_path);
if coverart_file_path.exists() {
match std::fs::remove_file(coverart_file_path) {
Ok(_) => {
if !check_file_existence(coverart_queue_path) {
Ok(())
} else {
Err(std::io::Error::other(String::from(
"CoverArt file stil exists",
)))
}
}
Err(err) => Err(std::io::Error::other(err.to_string())),
}
} else {
Err(std::io::Error::other(String::from(
"CoverArt file does not exists",
)))
}
}
fn check_file_existence(file_path: &String) -> bool {
let path = std::path::Path::new(file_path);
path.exists()
}
}

36
src/update_queued_song.rs Normal file
View File

@@ -0,0 +1,36 @@
pub async fn update_queued_song(
app: &crate::config::App,
song_path: &String,
song_queue_id: &uuid::Uuid,
) -> Result<reqwest::Response, reqwest::Error> {
let client = reqwest::Client::builder().build()?;
println!("Song path: {song_path:?}");
// TODO: Make the filename random
let form = reqwest::multipart::Form::new().part(
"file",
reqwest::multipart::Part::bytes(std::fs::read(song_path).unwrap())
.file_name("track01.flac"),
);
let url = format!("{}/api/v2/song/queue/{song_queue_id}", app.uri);
println!("Url: {url:?}");
let (key, header) = crate::api::auth_header(app).await;
let request = client.patch(url).multipart(form).header(key, header);
let response = request.send().await?;
Ok(response)
}
pub mod response {
use serde::{Deserialize, Serialize};
#[derive(Debug, Deserialize, Serialize)]
pub struct Response {
pub message: String,
pub data: Vec<uuid::Uuid>,
}
}

6
src/util.rs Normal file
View File

@@ -0,0 +1,6 @@
pub fn path_buf_to_string(path: &std::path::Path) -> String {
match path.to_str() {
Some(val) => String::from(val),
None => String::new(),
}
}