Updated icarus-model (#33)
* Updated icarus-model * Updated icarus-model * Saving changes * Code formatting * Removing code * Updated icarus-model * Updated token secret * Added host * Fix build issue * Fix build warnings * Saving changes * Saving changes * Refactoring * Migrating over icarus-model coverart * Removed song module * Another one * Meta single upload is functional * Cleanup * More cleanup * Added test files (#37) * Added test files Need to add a coverarg image file * Updated test album file * Added coverart * Uploading meta is operational * Code cleanup * Moved function * Added string module
This commit was merged in pull request #33.
This commit is contained in:
+20
-22
@@ -24,7 +24,7 @@ impl Download {
|
||||
pub async fn download_song(
|
||||
&mut self,
|
||||
token: &icarus_models::token::AccessToken,
|
||||
song: &models::song::Song,
|
||||
song: &icarus_models::song::Song,
|
||||
) -> Result<String, MyError> {
|
||||
self.api.endpoint = String::from("song/data/download");
|
||||
let url = self.retrieve_url(&song);
|
||||
@@ -44,27 +44,25 @@ impl Download {
|
||||
.await;
|
||||
|
||||
match response {
|
||||
Ok(rep) => {
|
||||
match rep.status() {
|
||||
reqwest::StatusCode::OK => {
|
||||
let data = rep.text();
|
||||
match data.await {
|
||||
Ok(e) => {
|
||||
return Ok(e);
|
||||
}
|
||||
Err(er) => {
|
||||
println!("Error {:?}", er);
|
||||
Ok(rep) => match rep.status() {
|
||||
reqwest::StatusCode::OK => {
|
||||
let data = rep.text();
|
||||
match data.await {
|
||||
Ok(e) => {
|
||||
return Ok(e);
|
||||
}
|
||||
Err(er) => {
|
||||
println!("Error {:?}", er);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
reqwest::StatusCode::UNAUTHORIZED => {
|
||||
println!("Need to grab a new token");
|
||||
}
|
||||
other => {
|
||||
panic!("Uh oh! Something unexpected happened: {:?}", other);
|
||||
}
|
||||
}
|
||||
}
|
||||
reqwest::StatusCode::UNAUTHORIZED => {
|
||||
println!("Need to grab a new token");
|
||||
}
|
||||
other => {
|
||||
panic!("Uh oh! Something unexpected happened: {:?}", other);
|
||||
}
|
||||
},
|
||||
Err(er) => {
|
||||
return Err(MyError::Request(er));
|
||||
}
|
||||
@@ -73,7 +71,7 @@ impl Download {
|
||||
return Err(MyError::Other(String::from("Error downloading")));
|
||||
}
|
||||
|
||||
fn retrieve_url(&self, song: &models::song::Song) -> String {
|
||||
fn retrieve_url(&self, song: &icarus_models::song::Song) -> String {
|
||||
let api = &self.api;
|
||||
let mut url: String = String::from(&api.url);
|
||||
url += &String::from("api/");
|
||||
@@ -81,7 +79,7 @@ impl Download {
|
||||
url += &String::from("/");
|
||||
url += &String::from(&api.endpoint);
|
||||
url += &String::from("/");
|
||||
url += &song.id.unwrap().to_string();
|
||||
url += &song.id.to_string();
|
||||
|
||||
return url;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user