Code formatting
Some checks failed
Rust Build / Check (pull_request) Failing after 37s
Rust Build / Test Suite (pull_request) Failing after 43s
Rust Build / Rustfmt (pull_request) Successful in 26s
Rust Build / Clippy (pull_request) Failing after 36s
Rust Build / build (pull_request) Failing after 50s
Some checks failed
Rust Build / Check (pull_request) Failing after 37s
Rust Build / Test Suite (pull_request) Failing after 43s
Rust Build / Rustfmt (pull_request) Successful in 26s
Rust Build / Clippy (pull_request) Failing after 36s
Rust Build / build (pull_request) Failing after 50s
This commit is contained in:
36
src/main.rs
36
src/main.rs
@@ -23,8 +23,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
|||||||
// TODO: Do something with the result later
|
// TODO: Do something with the result later
|
||||||
// let _ = prep_song(&app_base_url, &song_queue_id).await;
|
// let _ = prep_song(&app_base_url, &song_queue_id).await;
|
||||||
match some_work(&app_base_url, &song_queue_id).await {
|
match some_work(&app_base_url, &song_queue_id).await {
|
||||||
Ok(_) => {
|
Ok(_) => {}
|
||||||
}
|
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
eprintln!("Error: {:?}", err);
|
eprintln!("Error: {:?}", err);
|
||||||
}
|
}
|
||||||
@@ -66,19 +65,27 @@ async fn is_queue_empty(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn some_work(app_base_url: &String, song_queue_id: &uuid::Uuid) -> Result<(), std::io::Error> {
|
async fn some_work(
|
||||||
|
app_base_url: &String,
|
||||||
|
song_queue_id: &uuid::Uuid,
|
||||||
|
) -> Result<(), std::io::Error> {
|
||||||
match prep_song(app_base_url, song_queue_id).await {
|
match prep_song(app_base_url, song_queue_id).await {
|
||||||
Ok((song_queue_path, coverart_queue_path, metadata)) => {
|
Ok((song_queue_path, coverart_queue_path, metadata)) => {
|
||||||
match apply_metadata(&song_queue_path, &coverart_queue_path, &metadata).await {
|
match apply_metadata(&song_queue_path, &coverart_queue_path, &metadata).await {
|
||||||
Ok(_applied) => {
|
Ok(_applied) => {
|
||||||
// let s_path = util::path_buf_to_string(&song_queue_path);
|
// let s_path = util::path_buf_to_string(&song_queue_path);
|
||||||
match update_queued_song::update_queued_song(app_base_url, &song_queue_path, song_queue_id).await {
|
match update_queued_song::update_queued_song(
|
||||||
Ok(_response) => {
|
app_base_url,
|
||||||
Ok(())
|
&song_queue_path,
|
||||||
}
|
song_queue_id,
|
||||||
Err(err) => {
|
)
|
||||||
Err(std::io::Error::new(std::io::ErrorKind::Other, err.to_string()))
|
.await
|
||||||
}
|
{
|
||||||
|
Ok(_response) => Ok(()),
|
||||||
|
Err(err) => Err(std::io::Error::new(
|
||||||
|
std::io::ErrorKind::Other,
|
||||||
|
err.to_string(),
|
||||||
|
)),
|
||||||
}
|
}
|
||||||
// Ok((s_path))
|
// Ok((s_path))
|
||||||
}
|
}
|
||||||
@@ -88,13 +95,14 @@ async fn some_work(app_base_url: &String, song_queue_id: &uuid::Uuid) -> Result<
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Err(_err) => {
|
Err(_err) => Ok(()),
|
||||||
Ok(())
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn prep_song(api_url: &String, song_queue_id: &uuid::Uuid) -> Result<(String, String, api::get_metadata_queue::response::Metadata), reqwest::Error> {
|
async fn prep_song(
|
||||||
|
api_url: &String,
|
||||||
|
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 {
|
match api::fetch_song_queue_data::get_data(api_url, song_queue_id).await {
|
||||||
Ok(response) => {
|
Ok(response) => {
|
||||||
// Process data here...
|
// Process data here...
|
||||||
|
@@ -1,7 +1,5 @@
|
|||||||
// TODO: Refactor this file when this app is functional
|
// TODO: Refactor this file when this app is functional
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// TODO: Create song
|
// TODO: Create song
|
||||||
// TODO: Create coverart
|
// TODO: Create coverart
|
||||||
// TODO: Wipe data from queued song
|
// TODO: Wipe data from queued song
|
||||||
|
@@ -1,18 +1,23 @@
|
|||||||
|
|
||||||
use reqwest::multipart;
|
use reqwest::multipart;
|
||||||
|
|
||||||
// TODO: Update the queued song with the updated queued song
|
// TODO: Update the queued song with the updated queued song
|
||||||
pub async fn update_queued_song(base_url: &String, song_path: &String, song_queue_id: &uuid::Uuid) -> Result<reqwest::Response, reqwest::Error> {
|
pub async fn update_queued_song(
|
||||||
let client = reqwest::Client::builder()
|
base_url: &String,
|
||||||
.build()?;
|
song_path: &String,
|
||||||
|
song_queue_id: &uuid::Uuid,
|
||||||
|
) -> Result<reqwest::Response, reqwest::Error> {
|
||||||
|
let client = reqwest::Client::builder().build()?;
|
||||||
|
|
||||||
let form = reqwest::multipart::Form::new()
|
let form = reqwest::multipart::Form::new().part(
|
||||||
.part("file",
|
"file",
|
||||||
reqwest::multipart::Part::bytes(std::fs::read(song_path).unwrap()).file_name("track01.flac"));
|
reqwest::multipart::Part::bytes(std::fs::read(song_path).unwrap())
|
||||||
|
.file_name("track01.flac"),
|
||||||
|
);
|
||||||
|
|
||||||
let method = "PATCH";
|
let method = "PATCH";
|
||||||
let url = format!("{}/api/v2/song/queue/{}", base_url, song_queue_id);
|
let url = format!("{}/api/v2/song/queue/{}", base_url, song_queue_id);
|
||||||
let request = client.request(reqwest::Method::from_bytes(method.as_bytes()).unwrap(), url)
|
let request = client
|
||||||
|
.request(reqwest::Method::from_bytes(method.as_bytes()).unwrap(), url)
|
||||||
.multipart(form);
|
.multipart(form);
|
||||||
|
|
||||||
let response = request.send().await?;
|
let response = request.send().await?;
|
||||||
@@ -20,7 +25,6 @@ pub async fn update_queued_song(base_url: &String, song_path: &String, song_queu
|
|||||||
Ok(response)
|
Ok(response)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
pub mod response {
|
pub mod response {
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
}
|
}
|
||||||
|
@@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
pub fn path_buf_to_string(path: &std::path::PathBuf) -> String {
|
pub fn path_buf_to_string(path: &std::path::PathBuf) -> String {
|
||||||
let s_path = match path.to_str() {
|
let s_path = match path.to_str() {
|
||||||
Some(val) => String::from(val),
|
Some(val) => String::from(val),
|
||||||
@@ -7,4 +6,3 @@ pub fn path_buf_to_string(path: &std::path::PathBuf) -> String {
|
|||||||
|
|
||||||
s_path
|
s_path
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user