Compare commits
29 Commits
v0.2.0-dev
...
0b8ae56eb4
Author | SHA1 | Date | |
---|---|---|---|
0b8ae56eb4
|
|||
af67d5bea0
|
|||
99cb6318d6
|
|||
67d2729c46
|
|||
b8bbd66fd3
|
|||
aa93e6cc4a
|
|||
7e9392ef1f
|
|||
88ae596ae1
|
|||
b5f7943938
|
|||
62a1f8a003
|
|||
80c4c7950b
|
|||
6fafb93aaf
|
|||
0695df3f72
|
|||
3ea008868a
|
|||
ce2e4feb02
|
|||
002de87f5e
|
|||
09a129abc8
|
|||
80762b81ae | |||
af4f1acb87 | |||
d5e24f9114 | |||
27e4b30d21 | |||
99bb72ffb2 | |||
111d16515f | |||
47bf24180b | |||
c16ad062d4 | |||
a779e13a77 | |||
fe61fe3efb | |||
83eafd0005 | |||
e3895b6d1a |
@@ -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
|
||||
|
@@ -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
|
||||
|
@@ -3,7 +3,6 @@ name: Release Tagging
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- main
|
||||
- devel
|
||||
|
||||
jobs:
|
||||
@@ -18,7 +17,7 @@ jobs:
|
||||
- name: Install Rust
|
||||
uses: actions-rs/toolchain@v1
|
||||
with:
|
||||
toolchain: 1.88.0
|
||||
toolchain: 1.86.0
|
||||
components: cargo
|
||||
|
||||
- name: Extract Version from Cargo.toml
|
||||
@@ -29,7 +28,7 @@ jobs:
|
||||
BRANCH_REF="${GITHUB_REF}"
|
||||
BRANCH_NAME=$(echo "$BRANCH_REF" | cut -d '/' -f 3)
|
||||
PROJECT_TAG_RELEASE="v$VERSION-$BRANCH_NAME-$PROJECT_COMMIT_HASH"
|
||||
echo "::set-output name=project_tag_release::$PROJECT_TAG_RELEASE-431"
|
||||
echo "::set-output name=project_tag_release::$PROJECT_TAG_RELEASE-372"
|
||||
echo "Version: $VERSION"
|
||||
echo "Hash: $PROJECT_COMMIT_HASH"
|
||||
echo "Branch: $BRANCH_NAME"
|
||||
@@ -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
|
||||
|
||||
|
2
.gitignore
vendored
2
.gitignore
vendored
@@ -1,2 +1,4 @@
|
||||
/target
|
||||
.env
|
||||
.env.local
|
||||
.env.docker
|
||||
|
95
Cargo.lock
generated
95
Cargo.lock
generated
@@ -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"
|
||||
@@ -501,8 +516,8 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "icarus_envy"
|
||||
version = "0.3.0"
|
||||
source = "git+ssh://git@git.kundeng.us/phoenix/icarus_envy.git?tag=v0.3.0-devel-d73fba9899-006#d73fba9899372b0655a90cb426645930135152da"
|
||||
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",
|
||||
@@ -511,16 +526,17 @@ dependencies = [
|
||||
[[package]]
|
||||
name = "icarus_meta"
|
||||
version = "0.3.0"
|
||||
source = "git+ssh://git@git.kundeng.us/phoenix/icarus_meta.git?tag=v0.3.0-devel-f4b71de969-680#f4b71de9692029a706b1ce82c39f6715c560158e"
|
||||
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.0"
|
||||
source = "git+ssh://git@git.kundeng.us/phoenix/icarus_models.git?tag=v0.5.0-devel-7958b89abc-111#7958b89abc56bc9262015b3e201ea2906cc8a9ff"
|
||||
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",
|
||||
@@ -667,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"
|
||||
@@ -1009,6 +1042,35 @@ dependencies = [
|
||||
"bitflags",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "regex"
|
||||
version = "1.11.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
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"
|
||||
@@ -1195,6 +1257,7 @@ version = "1.0.140"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "20068b6e96dc6c9bd23e01df8827e6c7e1f2fddd43c21810382803c136b99373"
|
||||
dependencies = [
|
||||
"indexmap",
|
||||
"itoa",
|
||||
"memchr",
|
||||
"ryu",
|
||||
@@ -1255,7 +1318,7 @@ dependencies = [
|
||||
|
||||
[[package]]
|
||||
name = "songparser"
|
||||
version = "0.2.0"
|
||||
version = "0.2.5"
|
||||
dependencies = [
|
||||
"futures",
|
||||
"icarus_envy",
|
||||
@@ -1347,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"
|
||||
|
@@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "songparser"
|
||||
version = "0.2.0"
|
||||
version = "0.2.5"
|
||||
edition = "2024"
|
||||
rust-version = "1.88"
|
||||
|
||||
@@ -13,6 +13,6 @@ serde_json = { version = "1.0.140" }
|
||||
time = { version = "0.3.41", features = ["macros", "serde"] }
|
||||
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-devel-f4b71de969-680" }
|
||||
icarus_models = { git = "ssh://git@git.kundeng.us/phoenix/icarus_models.git", tag = "v0.5.0-devel-7958b89abc-111" }
|
||||
icarus_envy = { git = "ssh://git@git.kundeng.us/phoenix/icarus_envy.git", tag = "v0.3.0-devel-d73fba9899-006" }
|
||||
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" }
|
||||
|
169
src/api.rs
Normal file
169
src/api.rs
Normal 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
6
src/config.rs
Normal 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,
|
||||
}
|
426
src/main.rs
426
src/main.rs
@@ -1,3 +1,6 @@
|
||||
pub mod api;
|
||||
pub mod config;
|
||||
pub mod responses;
|
||||
pub mod the_rest;
|
||||
pub mod update_queued_song;
|
||||
pub mod util;
|
||||
@@ -8,21 +11,77 @@ 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()
|
||||
};
|
||||
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!("Base URL: {:?}", app.uri);
|
||||
println!("Auth URL: {:?}", app.auth_uri);
|
||||
println!("Token: {:?}", app.token);
|
||||
|
||||
match is_queue_empty(&app_base_url).await {
|
||||
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!("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_base_url, &song_queue_id).await {
|
||||
Ok(_) => {}
|
||||
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(_) => {
|
||||
match cleanup(&song_queue_path, &coverart_queue_path).await {
|
||||
Ok(_) => {
|
||||
println!("Successful cleanup");
|
||||
}
|
||||
Err(err) => {
|
||||
eprintln!("Error: {err:?}");
|
||||
}
|
||||
}
|
||||
}
|
||||
Err(err) => {
|
||||
eprintln!("Error: {err:?}");
|
||||
}
|
||||
}
|
||||
}
|
||||
Err(err) => {
|
||||
eprintln!("Error: {err:?}");
|
||||
}
|
||||
@@ -41,10 +100,127 @@ 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(
|
||||
api_url: &String,
|
||||
app: &config::App,
|
||||
) -> Result<(bool, responses::fetch_next_queue_item::SongQueueItem), reqwest::Error> {
|
||||
match api::fetch_next_queue_item(api_url).await {
|
||||
match api::fetch_next_queue_item(app).await {
|
||||
Ok(response) => {
|
||||
match response
|
||||
.json::<responses::fetch_next_queue_item::SongQueueItem>()
|
||||
@@ -65,15 +241,24 @@ async fn is_queue_empty(
|
||||
}
|
||||
|
||||
async fn some_work(
|
||||
app_base_url: &String,
|
||||
app: &crate::config::App,
|
||||
song_queue_id: &uuid::Uuid,
|
||||
) -> Result<(), std::io::Error> {
|
||||
match prep_song(app_base_url, song_queue_id).await {
|
||||
Ok((song_queue_path, coverart_queue_path, metadata)) => {
|
||||
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_base_url,
|
||||
app,
|
||||
&song_queue_path,
|
||||
song_queue_id,
|
||||
)
|
||||
@@ -86,7 +271,44 @@ async fn some_work(
|
||||
{
|
||||
Ok(_inner_response) => {
|
||||
println!("Response: {_inner_response:?}");
|
||||
Ok(())
|
||||
|
||||
// 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())),
|
||||
}
|
||||
@@ -102,10 +324,18 @@ async fn some_work(
|
||||
}
|
||||
|
||||
async fn prep_song(
|
||||
api_url: &String,
|
||||
app: &crate::config::App,
|
||||
song_queue_id: &uuid::Uuid,
|
||||
) -> Result<(String, String, api::get_metadata_queue::response::Metadata), reqwest::Error> {
|
||||
match api::fetch_song_queue_data::get_data(api_url, song_queue_id).await {
|
||||
) -> 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 {
|
||||
@@ -115,7 +345,7 @@ async fn prep_song(
|
||||
|
||||
println!("Saved at: {song_queue_path:?}");
|
||||
|
||||
match api::get_metadata_queue::get(api_url, song_queue_id).await {
|
||||
match api::get_metadata_queue::get(app, song_queue_id).await {
|
||||
Ok(response) => {
|
||||
match response
|
||||
.json::<api::get_metadata_queue::response::Response>()
|
||||
@@ -130,15 +360,14 @@ async fn prep_song(
|
||||
println!("Created at: {created_at:?}");
|
||||
|
||||
println!("Getting coverart queue");
|
||||
match api::get_coverart_queue::get(api_url, song_queue_id).await
|
||||
{
|
||||
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(api_url, coverart_queue_id).await {
|
||||
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;
|
||||
@@ -148,7 +377,7 @@ async fn prep_song(
|
||||
|
||||
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()))
|
||||
Ok((s_path, c_path, metadata.clone(), *coverart_queue_id))
|
||||
}
|
||||
Err(err) => {
|
||||
Err(err)
|
||||
@@ -375,158 +604,3 @@ pub async fn apply_metadata(
|
||||
Err(err) => Err(err),
|
||||
}
|
||||
}
|
||||
|
||||
mod responses {
|
||||
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,
|
||||
}
|
||||
|
||||
#[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 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(
|
||||
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 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(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(
|
||||
base_url: &String,
|
||||
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!("{base_url}/{endpoint}");
|
||||
client
|
||||
.get(api_url)
|
||||
.query(&[("song_queue_id", song_queue_id)])
|
||||
.send()
|
||||
.await
|
||||
}
|
||||
|
||||
pub async fn get_data(
|
||||
base_url: &String,
|
||||
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!("{base_url}/{endpoint}/{coverart_queue_id}");
|
||||
client.get(api_url).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>,
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
17
src/responses.rs
Normal file
17
src/responses.rs
Normal 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>,
|
||||
}
|
||||
}
|
181
src/the_rest.rs
181
src/the_rest.rs
@@ -1,6 +1,179 @@
|
||||
// TODO: Refactor this file when this app is functional
|
||||
|
||||
// TODO: Create song
|
||||
// TODO: Create coverart
|
||||
// TODO: Wipe data from queued song
|
||||
// TODO: Wipe data from queued coverart
|
||||
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()
|
||||
}
|
||||
}
|
||||
|
@@ -1,5 +1,5 @@
|
||||
pub async fn update_queued_song(
|
||||
base_url: &String,
|
||||
app: &crate::config::App,
|
||||
song_path: &String,
|
||||
song_queue_id: &uuid::Uuid,
|
||||
) -> Result<reqwest::Response, reqwest::Error> {
|
||||
@@ -14,10 +14,11 @@ pub async fn update_queued_song(
|
||||
.file_name("track01.flac"),
|
||||
);
|
||||
|
||||
let url = format!("{base_url}/api/v2/song/queue/{song_queue_id}");
|
||||
let url = format!("{}/api/v2/song/queue/{song_queue_id}", app.uri);
|
||||
println!("Url: {url:?}");
|
||||
|
||||
let request = client.patch(url).multipart(form);
|
||||
let (key, header) = crate::api::auth_header(app).await;
|
||||
let request = client.patch(url).multipart(form).header(key, header);
|
||||
|
||||
let response = request.send().await?;
|
||||
|
||||
|
Reference in New Issue
Block a user