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
				
			
		
		
	
	
				
					
				
			
		
			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>
This commit is contained in:
		
							
								
								
									
										6
									
								
								Cargo.lock
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										6
									
								
								Cargo.lock
									
									
									
										generated
									
									
									
								
							| @@ -518,8 +518,8 @@ dependencies = [ | ||||
|  | ||||
| [[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.4.5" | ||||
| source = "git+ssh://git@git.kundeng.us/phoenix/icarus_models.git?tag=v0.4.5-devel-655d05dabb-111#655d05dabbdadb9b28940564a1eb82470aa4f166" | ||||
| dependencies = [ | ||||
|  "rand", | ||||
|  "serde", | ||||
| @@ -1255,7 +1255,7 @@ dependencies = [ | ||||
|  | ||||
| [[package]] | ||||
| name = "songparser" | ||||
| version = "0.2.0" | ||||
| version = "0.2.1" | ||||
| dependencies = [ | ||||
|  "futures", | ||||
|  "icarus_envy", | ||||
|   | ||||
| @@ -1,6 +1,6 @@ | ||||
| [package] | ||||
| name = "songparser" | ||||
| version = "0.2.0" | ||||
| version = "0.2.1" | ||||
| edition = "2024" | ||||
| rust-version = "1.88" | ||||
|  | ||||
| @@ -14,5 +14,5 @@ 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_models = { git = "ssh://git@git.kundeng.us/phoenix/icarus_models.git", tag = "v0.4.5-devel-655d05dabb-111" } | ||||
| icarus_envy = { git = "ssh://git@git.kundeng.us/phoenix/icarus_envy.git", tag = "v0.3.0-devel-d73fba9899-006" } | ||||
|   | ||||
							
								
								
									
										45
									
								
								src/main.rs
									
									
									
									
									
								
							
							
						
						
									
										45
									
								
								src/main.rs
									
									
									
									
									
								
							| @@ -24,7 +24,15 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> { | ||||
|  | ||||
|                     // TODO: Do something with the result later | ||||
|                     match some_work(&app_base_url, &song_queue_id).await { | ||||
|                         Ok(_) => {} | ||||
|                         Ok(( | ||||
|                             song, | ||||
|                             coverart, | ||||
|                             (song_queue_id, song_queue_path), | ||||
|                             (coverart_queue_id, coverart_queue_path), | ||||
|                         )) => { | ||||
|                             // TODO: Wipe data from song and coverart queues | ||||
|                             // TODO: Cleanup files in local filesystem | ||||
|                         } | ||||
|                         Err(err) => { | ||||
|                             eprintln!("Error: {err:?}"); | ||||
|                         } | ||||
| @@ -69,7 +77,15 @@ async fn is_queue_empty( | ||||
| async fn some_work( | ||||
|     app_base_url: &String, | ||||
|     song_queue_id: &uuid::Uuid, | ||||
| ) -> Result<(), std::io::Error> { | ||||
| ) -> Result< | ||||
|     ( | ||||
|         icarus_models::song::Song, | ||||
|         icarus_models::coverart::CoverArt, | ||||
|         (uuid::Uuid, String), | ||||
|         (uuid::Uuid, String), | ||||
|     ), | ||||
|     std::io::Error, | ||||
| > { | ||||
|     match prep_song(app_base_url, 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 { | ||||
| @@ -111,15 +127,22 @@ async fn some_work( | ||||
|                                                 println!("Response: {resp:?}"); | ||||
|  | ||||
|                                                 let song = &resp.data[0]; | ||||
|                                                 let url = format!("{app_base_url}/api/v2/coverart"); | ||||
|                                                 let payload = serde_json::json!({ | ||||
|                                                     "song_id": &song.id, | ||||
|                                                     "coverart_queue_id": &coverart_queue_id, | ||||
|                                                 }); | ||||
|                                                 println!("Payload: {payload:?}"); | ||||
|                                                 println!("Url: {url:?}"); | ||||
|                                                 // println!("Response json: {:?}", response.text().await); | ||||
|                                                 Ok(()) | ||||
|                                                 match the_rest::create_coverart::create(app_base_url, &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())), | ||||
|                                         }, | ||||
|   | ||||
| @@ -45,5 +45,36 @@ pub mod create_song { | ||||
| } | ||||
|  | ||||
| // TODO: Create coverart | ||||
| pub mod create_coverart { | ||||
|  | ||||
|     pub async fn create( | ||||
|         base_url: &String, | ||||
|         song_id: &uuid::Uuid, | ||||
|         coverart_queue_id: &uuid::Uuid, | ||||
|     ) -> Result<reqwest::Response, reqwest::Error> { | ||||
|         let client = reqwest::Client::builder().build()?; | ||||
|         let url = format!("{base_url}/api/v2/coverart"); | ||||
|         let payload = get_payload(song_id, coverart_queue_id); | ||||
|         let request = client.post(url).json(&payload); | ||||
|  | ||||
|         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>, | ||||
|         } | ||||
|     } | ||||
| } | ||||
|  | ||||
| // TODO: Wipe data from queued song | ||||
| // TODO: Wipe data from queued coverart | ||||
|   | ||||
		Reference in New Issue
	
	Block a user