Compare commits
5 Commits
v0.3.0
...
3c8c3fa55a
Author | SHA1 | Date | |
---|---|---|---|
3c8c3fa55a
|
|||
2b9dab6e1c
|
|||
e1081aef60
|
|||
6d54664a81 | |||
b2f702c24c |
@@ -10,14 +10,14 @@ jobs:
|
|||||||
runs-on: ubuntu-24.04
|
runs-on: ubuntu-24.04
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout code
|
- name: Checkout code
|
||||||
uses: actions/checkout@v3
|
uses: actions/checkout@v5
|
||||||
with:
|
with:
|
||||||
fetch-depth: 0 # Important for git describe --tags
|
fetch-depth: 0 # Important for git describe --tags
|
||||||
|
|
||||||
- name: Install Rust
|
- name: Install Rust
|
||||||
uses: actions-rs/toolchain@v1
|
uses: actions-rs/toolchain@v1
|
||||||
with:
|
with:
|
||||||
toolchain: 1.86.0
|
toolchain: 1.88.0
|
||||||
components: cargo
|
components: cargo
|
||||||
|
|
||||||
- name: Extract Version from Cargo.toml
|
- name: Extract Version from Cargo.toml
|
||||||
|
@@ -15,7 +15,7 @@ jobs:
|
|||||||
name: Check
|
name: Check
|
||||||
runs-on: ubuntu-24.04
|
runs-on: ubuntu-24.04
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v5
|
||||||
- uses: actions-rust-lang/setup-rust-toolchain@v1
|
- uses: actions-rust-lang/setup-rust-toolchain@v1
|
||||||
with:
|
with:
|
||||||
toolchain: 1.88.0
|
toolchain: 1.88.0
|
||||||
@@ -33,7 +33,7 @@ jobs:
|
|||||||
runs-on: ubuntu-24.04
|
runs-on: ubuntu-24.04
|
||||||
needs: setup_ssh
|
needs: setup_ssh
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v5
|
||||||
- uses: actions-rust-lang/setup-rust-toolchain@v1
|
- uses: actions-rust-lang/setup-rust-toolchain@v1
|
||||||
with:
|
with:
|
||||||
toolchain: 1.88.0
|
toolchain: 1.88.0
|
||||||
@@ -51,7 +51,7 @@ jobs:
|
|||||||
runs-on: ubuntu-24.04
|
runs-on: ubuntu-24.04
|
||||||
needs: setup_ssh
|
needs: setup_ssh
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v5
|
||||||
- uses: actions-rust-lang/setup-rust-toolchain@v1
|
- uses: actions-rust-lang/setup-rust-toolchain@v1
|
||||||
with:
|
with:
|
||||||
toolchain: 1.88.0
|
toolchain: 1.88.0
|
||||||
@@ -70,7 +70,7 @@ jobs:
|
|||||||
runs-on: ubuntu-24.04
|
runs-on: ubuntu-24.04
|
||||||
needs: setup_ssh
|
needs: setup_ssh
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v5
|
||||||
- uses: actions-rust-lang/setup-rust-toolchain@v1
|
- uses: actions-rust-lang/setup-rust-toolchain@v1
|
||||||
with:
|
with:
|
||||||
toolchain: 1.88.0
|
toolchain: 1.88.0
|
||||||
@@ -89,7 +89,7 @@ jobs:
|
|||||||
runs-on: ubuntu-24.04
|
runs-on: ubuntu-24.04
|
||||||
needs: setup_ssh
|
needs: setup_ssh
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v5
|
||||||
- uses: actions-rust-lang/setup-rust-toolchain@v1
|
- uses: actions-rust-lang/setup-rust-toolchain@v1
|
||||||
with:
|
with:
|
||||||
toolchain: 1.88.0
|
toolchain: 1.88.0
|
||||||
|
100
Cargo.lock
generated
100
Cargo.lock
generated
@@ -157,12 +157,12 @@ checksum = "2a2330da5de22e8a3cb63252ce2abb30116bf5265e89c0e01bc17015ce30a476"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "deranged"
|
name = "deranged"
|
||||||
version = "0.4.0"
|
version = "0.5.4"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "9c9e6a11ca8224451684bc0d7d5a7adbf8f2fd6887261a1cfc3c0432f9d4068e"
|
checksum = "a41953f86f8a05768a6cda24def994fd2f424b04ec5c719cf89989779f199071"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"powerfmt",
|
"powerfmt",
|
||||||
"serde",
|
"serde_core",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -506,7 +506,7 @@ dependencies = [
|
|||||||
"libc",
|
"libc",
|
||||||
"percent-encoding",
|
"percent-encoding",
|
||||||
"pin-project-lite",
|
"pin-project-lite",
|
||||||
"socket2",
|
"socket2 0.5.10",
|
||||||
"system-configuration",
|
"system-configuration",
|
||||||
"tokio",
|
"tokio",
|
||||||
"tower-service",
|
"tower-service",
|
||||||
@@ -516,8 +516,8 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "icarus_envy"
|
name = "icarus_envy"
|
||||||
version = "0.3.2"
|
version = "0.4.1"
|
||||||
source = "git+ssh://git@git.kundeng.us/phoenix/icarus_envy.git?tag=v0.3.2#d84a8144aedf02e1b459d67c4023a7e0833f89fd"
|
source = "git+ssh://git@git.kundeng.us/phoenix/icarus_envy.git?tag=v0.4.1-main-8f0d123db5-006#8f0d123db51b18e9cc4ab5bd39a474ba99bd39c3"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"const_format",
|
"const_format",
|
||||||
"dotenvy",
|
"dotenvy",
|
||||||
@@ -533,8 +533,8 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "icarus_models"
|
name = "icarus_models"
|
||||||
version = "0.5.6"
|
version = "0.6.6"
|
||||||
source = "git+ssh://git@git.kundeng.us/phoenix/icarus_models.git?tag=v0.5.6#2d6b550ae6721b41ecc3039799f6a5e873869077"
|
source = "git+ssh://git@git.kundeng.us/phoenix/icarus_models.git?tag=v0.6.6-65-eac7562b80-111#eac7562b80b9f82d21ab737d1e84ba4f12e472dd"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"josekit",
|
"josekit",
|
||||||
"rand",
|
"rand",
|
||||||
@@ -663,6 +663,17 @@ dependencies = [
|
|||||||
"serde",
|
"serde",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "io-uring"
|
||||||
|
version = "0.7.10"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "046fa2d4d00aea763528b4950358d0ead425372445dc8ff86312b3c69ff7727b"
|
||||||
|
dependencies = [
|
||||||
|
"bitflags",
|
||||||
|
"cfg-if",
|
||||||
|
"libc",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "ipnet"
|
name = "ipnet"
|
||||||
version = "2.11.0"
|
version = "2.11.0"
|
||||||
@@ -714,9 +725,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "libc"
|
name = "libc"
|
||||||
version = "0.2.171"
|
version = "0.2.177"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "c19937216e9d3aa9956d9bb8dfc0b0c8beb6058fc4f7a4dc4d850edf86a237d6"
|
checksum = "2874a2af47a2325c2001a6e6fad9b16a53b802102b528163885171cf92b15976"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "linux-raw-sys"
|
name = "linux-raw-sys"
|
||||||
@@ -1008,9 +1019,9 @@ checksum = "74765f6d916ee2faa39bc8e68e4f3ed8949b48cccdac59983d287a7cb71ce9c5"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rand"
|
name = "rand"
|
||||||
version = "0.9.1"
|
version = "0.9.2"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "9fbfd9d094a40bf3ae768db9361049ace4c0e04a4fd6b359518bd7b73a73dd97"
|
checksum = "6db2770f06117d490610c7488547d543617b21bfa07796d7a12f6f1bd53850d1"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"rand_chacha",
|
"rand_chacha",
|
||||||
"rand_core",
|
"rand_core",
|
||||||
@@ -1075,9 +1086,9 @@ checksum = "2b15c43186be67a4fd63bee50d0303afffcef381492ebe2c5d87f324e1b8815c"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "reqwest"
|
name = "reqwest"
|
||||||
version = "0.12.20"
|
version = "0.12.23"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "eabf4c97d9130e2bf606614eb937e86edac8292eaa6f422f995d7e8de1eb1813"
|
checksum = "d429f34c8092b2d42c7c93cec323bb4adeb7c67698f70839adec842ec10c7ceb"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"base64",
|
"base64",
|
||||||
"bytes",
|
"bytes",
|
||||||
@@ -1235,18 +1246,28 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "serde"
|
name = "serde"
|
||||||
version = "1.0.219"
|
version = "1.0.228"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "5f0e2c6ed6606019b4e29e69dbaba95b11854410e5347d525002456dbbb786b6"
|
checksum = "9a8e94ea7f378bd32cbbd37198a4a91436180c5bb472411e48b5ec2e2124ae9e"
|
||||||
|
dependencies = [
|
||||||
|
"serde_core",
|
||||||
|
"serde_derive",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "serde_core"
|
||||||
|
version = "1.0.228"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "41d385c7d4ca58e59fc732af25c3983b67ac852c1a25000afe1175de458b67ad"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"serde_derive",
|
"serde_derive",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "serde_derive"
|
name = "serde_derive"
|
||||||
version = "1.0.219"
|
version = "1.0.228"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "5b0276cf7f2c73365f7157c8123c21cd9a50fbbd844757af28ca1f5925fc2a00"
|
checksum = "d540f220d3187173da220f885ab66608367b6574e925011a9353e4badda91d79"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
"quote",
|
"quote",
|
||||||
@@ -1255,15 +1276,16 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "serde_json"
|
name = "serde_json"
|
||||||
version = "1.0.140"
|
version = "1.0.145"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "20068b6e96dc6c9bd23e01df8827e6c7e1f2fddd43c21810382803c136b99373"
|
checksum = "402a6f66d8c709116cf22f558eab210f5a50187f702eb4d7e5ef38d9a7f1c79c"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"indexmap",
|
"indexmap",
|
||||||
"itoa",
|
"itoa",
|
||||||
"memchr",
|
"memchr",
|
||||||
"ryu",
|
"ryu",
|
||||||
"serde",
|
"serde",
|
||||||
|
"serde_core",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -1318,9 +1340,19 @@ dependencies = [
|
|||||||
"windows-sys 0.52.0",
|
"windows-sys 0.52.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "socket2"
|
||||||
|
version = "0.6.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "233504af464074f9d066d7b5416c5f9b894a5862a6506e306f7b816cdd6f1807"
|
||||||
|
dependencies = [
|
||||||
|
"libc",
|
||||||
|
"windows-sys 0.59.0",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "songparser"
|
name = "songparser"
|
||||||
version = "0.3.0"
|
version = "0.3.3"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"futures",
|
"futures",
|
||||||
"icarus_envy",
|
"icarus_envy",
|
||||||
@@ -1434,9 +1466,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "time"
|
name = "time"
|
||||||
version = "0.3.41"
|
version = "0.3.44"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "8a7619e19bc266e0f9c5e6686659d394bc57973859340060a69221e57dbc0c40"
|
checksum = "91e7d9e3bb61134e77bde20dd4825b97c010155709965fedf0f49bb138e52a9d"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"deranged",
|
"deranged",
|
||||||
"itoa",
|
"itoa",
|
||||||
@@ -1449,15 +1481,15 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "time-core"
|
name = "time-core"
|
||||||
version = "0.1.4"
|
version = "0.1.6"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "c9e9a38711f559d9e3ce1cdb06dd7c5b8ea546bc90052da6d06bb76da74bb07c"
|
checksum = "40868e7c1d2f0b8d73e4a8c7f0ff63af4f6d19be117e90bd73eb1d62cf831c6b"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "time-macros"
|
name = "time-macros"
|
||||||
version = "0.2.22"
|
version = "0.2.24"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "3526739392ec93fd8b359c8e98514cb3e8e021beb4e5f597b00a0221f8ed8a49"
|
checksum = "30cfb0125f12d9c277f35663a0a33f8c30190f4e4574868a330595412d34ebf3"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"num-conv",
|
"num-conv",
|
||||||
"time-core",
|
"time-core",
|
||||||
@@ -1475,20 +1507,22 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tokio"
|
name = "tokio"
|
||||||
version = "1.45.1"
|
version = "1.47.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "75ef51a33ef1da925cea3e4eb122833cb377c61439ca401b770f54902b806779"
|
checksum = "89e49afdadebb872d3145a5638b59eb0691ea23e46ca484037cfab3b76b95038"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"backtrace",
|
"backtrace",
|
||||||
"bytes",
|
"bytes",
|
||||||
|
"io-uring",
|
||||||
"libc",
|
"libc",
|
||||||
"mio",
|
"mio",
|
||||||
"parking_lot",
|
"parking_lot",
|
||||||
"pin-project-lite",
|
"pin-project-lite",
|
||||||
"signal-hook-registry",
|
"signal-hook-registry",
|
||||||
"socket2",
|
"slab",
|
||||||
|
"socket2 0.6.0",
|
||||||
"tokio-macros",
|
"tokio-macros",
|
||||||
"windows-sys 0.52.0",
|
"windows-sys 0.59.0",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -1672,9 +1706,9 @@ dependencies = [
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "uuid"
|
name = "uuid"
|
||||||
version = "1.17.0"
|
version = "1.18.1"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "3cf4199d1e5d15ddd86a694e4d0dffa9c323ce759fea589f00fef9d81cc1931d"
|
checksum = "2f87b8aa10b915a06587d0dec516c282ff295b475d94abf425d62b57710070a2"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"getrandom 0.3.2",
|
"getrandom 0.3.2",
|
||||||
"js-sys",
|
"js-sys",
|
||||||
|
20
Cargo.toml
20
Cargo.toml
@@ -1,18 +1,18 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "songparser"
|
name = "songparser"
|
||||||
version = "0.3.0"
|
version = "0.3.3"
|
||||||
edition = "2024"
|
edition = "2024"
|
||||||
rust-version = "1.88"
|
rust-version = "1.88"
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
tokio = { version = "1.45.1", features = ["full"] }
|
tokio = { version = "1.47.1", features = ["full"] }
|
||||||
futures = { version = "0.3.31" }
|
futures = { version = "0.3.31" }
|
||||||
reqwest = { version = "0.12.20", features = ["json", "stream", "multipart"] }
|
reqwest = { version = "0.12.23", features = ["json", "stream", "multipart"] }
|
||||||
serde = { version = "1.0.219", features = ["derive"] }
|
serde = { version = "1.0.228", features = ["derive"] }
|
||||||
serde_json = { version = "1.0.140" }
|
serde_json = { version = "1.0.145" }
|
||||||
time = { version = "0.3.41", features = ["macros", "serde"] }
|
time = { version = "0.3.44", features = ["macros", "serde"] }
|
||||||
uuid = { version = "1.17.0", features = ["v4", "serde"] }
|
uuid = { version = "1.18.1", features = ["v4", "serde"] }
|
||||||
rand = { version = "0.9.1" }
|
rand = { version = "0.9.2" }
|
||||||
icarus_meta = { git = "ssh://git@git.kundeng.us/phoenix/icarus_meta.git", tag = "v0.3.0" }
|
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.6" }
|
icarus_models = { git = "ssh://git@git.kundeng.us/phoenix/icarus_models.git", tag = "v0.6.6-65-eac7562b80-111" }
|
||||||
icarus_envy = { git = "ssh://git@git.kundeng.us/phoenix/icarus_envy.git", tag = "v0.3.2" }
|
icarus_envy = { git = "ssh://git@git.kundeng.us/phoenix/icarus_envy.git", tag = "v0.4.1-main-8f0d123db5-006" }
|
||||||
|
95
src/main.rs
95
src/main.rs
@@ -5,15 +5,17 @@ pub mod the_rest;
|
|||||||
pub mod update_queued_song;
|
pub mod update_queued_song;
|
||||||
pub mod util;
|
pub mod util;
|
||||||
|
|
||||||
use std::io::Write;
|
|
||||||
|
|
||||||
pub const SECONDS_TO_SLEEP: u64 = 5;
|
pub const SECONDS_TO_SLEEP: u64 = 5;
|
||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||||
let mut app = config::App {
|
let mut app = config::App {
|
||||||
uri: icarus_envy::environment::get_icarus_base_api_url().await,
|
uri: icarus_envy::environment::get_icarus_base_api_url()
|
||||||
auth_uri: icarus_envy::environment::get_icarus_auth_base_api_url().await,
|
.await
|
||||||
|
.value,
|
||||||
|
auth_uri: icarus_envy::environment::get_icarus_auth_base_api_url()
|
||||||
|
.await
|
||||||
|
.value,
|
||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
println!("Base URL: {:?}", app.uri);
|
println!("Base URL: {:?}", app.uri);
|
||||||
@@ -60,24 +62,22 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||||||
// TODO: Do something with the result later
|
// TODO: Do something with the result later
|
||||||
match some_work(&app, &song_queue_id, &user_id).await {
|
match some_work(&app, &song_queue_id, &user_id).await {
|
||||||
Ok((
|
Ok((
|
||||||
_song,
|
song,
|
||||||
_coverart,
|
coverart,
|
||||||
(song_queue_id, song_queue_path),
|
(song_queue_id, _song_queue_path),
|
||||||
(coverart_queue_id, coverart_queue_path),
|
(coverart_queue_id, _coverart_queue_path),
|
||||||
)) => {
|
)) => {
|
||||||
match wipe_data_from_queues(&app, &song_queue_id, &coverart_queue_id)
|
match wipe_data_from_queues(&app, &song_queue_id, &coverart_queue_id)
|
||||||
.await
|
.await
|
||||||
{
|
{
|
||||||
Ok(_) => {
|
Ok(_) => match cleanup(&song, &coverart).await {
|
||||||
match cleanup(&song_queue_path, &coverart_queue_path).await {
|
Ok(_) => {
|
||||||
Ok(_) => {
|
println!("Successful cleanup");
|
||||||
println!("Successful cleanup");
|
|
||||||
}
|
|
||||||
Err(err) => {
|
|
||||||
eprintln!("Error: {err:?}");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
Err(err) => {
|
||||||
|
eprintln!("Error: {err:?}");
|
||||||
|
}
|
||||||
|
},
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
eprintln!("Error: {err:?}");
|
eprintln!("Error: {err:?}");
|
||||||
}
|
}
|
||||||
@@ -110,7 +110,7 @@ mod auth {
|
|||||||
let api_url = format!("{}/{endpoint}", app.auth_uri);
|
let api_url = format!("{}/{endpoint}", app.auth_uri);
|
||||||
|
|
||||||
let payload = serde_json::json!({
|
let payload = serde_json::json!({
|
||||||
"passphrase": icarus_envy::environment::get_service_passphrase().await,
|
"passphrase": icarus_envy::environment::get_service_passphrase().await.value,
|
||||||
});
|
});
|
||||||
|
|
||||||
match client.post(api_url).json(&payload).send().await {
|
match client.post(api_url).json(&payload).send().await {
|
||||||
@@ -202,17 +202,17 @@ async fn wipe_data_from_queues(
|
|||||||
}
|
}
|
||||||
|
|
||||||
async fn cleanup(
|
async fn cleanup(
|
||||||
song_queue_path: &String,
|
song: &icarus_models::song::Song,
|
||||||
coverart_queue_path: &String,
|
coverart: &icarus_models::coverart::CoverArt,
|
||||||
) -> Result<(), std::io::Error> {
|
) -> Result<(), std::io::Error> {
|
||||||
match the_rest::cleanup::clean_song_queue(song_queue_path) {
|
match song.remove_from_filesystem() {
|
||||||
Ok(_) => {}
|
Ok(_) => {}
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
eprintln!("Error: Problem cleaning up SongQueue files {err:?}");
|
eprintln!("Error: Problem cleaning up SongQueue files {err:?}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
match the_rest::cleanup::clean_coverart_queue(coverart_queue_path) {
|
match coverart.remove_from_filesystem() {
|
||||||
Ok(_) => Ok(()),
|
Ok(_) => Ok(()),
|
||||||
Err(err) => Err(err),
|
Err(err) => Err(err),
|
||||||
}
|
}
|
||||||
@@ -342,7 +342,17 @@ async fn prep_song(
|
|||||||
match api::parsing::parse_response_into_bytes(response).await {
|
match api::parsing::parse_response_into_bytes(response).await {
|
||||||
Ok(song_bytes) => {
|
Ok(song_bytes) => {
|
||||||
let (directory, filename) = generate_song_queue_dir_and_filename().await;
|
let (directory, filename) = generate_song_queue_dir_and_filename().await;
|
||||||
let song_queue_path = save_file_to_fs(&directory, &filename, &song_bytes).await;
|
let song = icarus_models::song::Song {
|
||||||
|
directory,
|
||||||
|
filename,
|
||||||
|
data: song_bytes,
|
||||||
|
..Default::default()
|
||||||
|
};
|
||||||
|
let songpath = song.song_path().unwrap_or_default();
|
||||||
|
let song_queue_path = match song.save_to_filesystem() {
|
||||||
|
Ok(_) => std::path::Path::new(&songpath),
|
||||||
|
Err(_err) => std::path::Path::new(""),
|
||||||
|
};
|
||||||
|
|
||||||
println!("Saved at: {song_queue_path:?}");
|
println!("Saved at: {song_queue_path:?}");
|
||||||
|
|
||||||
@@ -372,12 +382,17 @@ async fn prep_song(
|
|||||||
Ok(response) => match api::parsing::parse_response_into_bytes(response).await {
|
Ok(response) => match api::parsing::parse_response_into_bytes(response).await {
|
||||||
Ok(coverart_queue_bytes) => {
|
Ok(coverart_queue_bytes) => {
|
||||||
let (directory, filename) = generate_coverart_queue_dir_and_filename().await;
|
let (directory, filename) = generate_coverart_queue_dir_and_filename().await;
|
||||||
let coverart_queue_path = save_file_to_fs(&directory, &filename, &coverart_queue_bytes).await;
|
let coverart = icarus_models::coverart::CoverArt {
|
||||||
|
path: directory + "/" + &filename,
|
||||||
|
data: coverart_queue_bytes,
|
||||||
|
..Default::default()
|
||||||
|
};
|
||||||
|
coverart.save_to_filesystem().unwrap();
|
||||||
|
let coverart_queue_path = std::path::Path::new(&coverart.path);
|
||||||
println!("Saved coverart queue file at: {coverart_queue_path:?}");
|
println!("Saved coverart queue file at: {coverart_queue_path:?}");
|
||||||
|
|
||||||
let c_path = util::path_buf_to_string(&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);
|
let s_path = util::path_buf_to_string(song_queue_path);
|
||||||
Ok((s_path, c_path, metadata.clone(), *coverart_queue_id))
|
Ok((s_path, c_path, metadata.clone(), *coverart_queue_id))
|
||||||
}
|
}
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
@@ -413,9 +428,12 @@ async fn prep_song(
|
|||||||
// TODO: Consider having something like this in icarus_models
|
// TODO: Consider having something like this in icarus_models
|
||||||
pub async fn generate_song_queue_dir_and_filename() -> (String, String) {
|
pub async fn generate_song_queue_dir_and_filename() -> (String, String) {
|
||||||
let mut song = icarus_models::song::Song::default();
|
let mut song = icarus_models::song::Song::default();
|
||||||
song.filename = song.generate_filename(icarus_models::types::MusicTypes::FlacExtension, true);
|
song.filename = icarus_models::song::generate_filename(
|
||||||
|
icarus_models::types::MusicTypes::FlacExtension,
|
||||||
|
true,
|
||||||
|
);
|
||||||
|
|
||||||
song.directory = icarus_envy::environment::get_root_directory().await;
|
song.directory = icarus_envy::environment::get_root_directory().await.value;
|
||||||
|
|
||||||
(song.directory, song.filename)
|
(song.directory, song.filename)
|
||||||
}
|
}
|
||||||
@@ -444,28 +462,11 @@ pub async fn generate_coverart_queue_dir_and_filename() -> (String, String) {
|
|||||||
filename += ".jpeg";
|
filename += ".jpeg";
|
||||||
|
|
||||||
// TODO: Consider separating song and coverart when saving to the filesystem
|
// TODO: Consider separating song and coverart when saving to the filesystem
|
||||||
let directory = icarus_envy::environment::get_root_directory().await;
|
let directory = icarus_envy::environment::get_root_directory().await.value;
|
||||||
|
|
||||||
(directory, filename)
|
(directory, filename)
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Check to see if this is available in icarus_models
|
|
||||||
pub async fn save_file_to_fs(
|
|
||||||
directory: &String,
|
|
||||||
filename: &String,
|
|
||||||
data: &[u8],
|
|
||||||
) -> std::path::PathBuf {
|
|
||||||
// TODO: Add function to save bytes to a file in icarus_models
|
|
||||||
// repo
|
|
||||||
let dir = std::path::Path::new(directory);
|
|
||||||
let save_path = dir.join(filename);
|
|
||||||
|
|
||||||
let mut file = std::fs::File::create(&save_path).unwrap();
|
|
||||||
file.write_all(data).unwrap();
|
|
||||||
|
|
||||||
save_path
|
|
||||||
}
|
|
||||||
|
|
||||||
pub async fn apply_metadata(
|
pub async fn apply_metadata(
|
||||||
song_queue_path: &String,
|
song_queue_path: &String,
|
||||||
coverart_queue_path: &String,
|
coverart_queue_path: &String,
|
||||||
|
@@ -126,54 +126,3 @@ pub mod wipe_data {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
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()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
Reference in New Issue
Block a user