Download song #65

Merged
kdeng00 merged 5 commits from download_song into icarus_v2_support 2025-08-30 11:52:05 -04:00
7 changed files with 14 additions and 15 deletions
Generated
+1 -1
View File
@@ -479,7 +479,7 @@ dependencies = [
[[package]] [[package]]
name = "icarus-dm" name = "icarus-dm"
version = "0.6.2" version = "0.6.6"
dependencies = [ dependencies = [
"futures", "futures",
"http", "http",
+1 -1
View File
@@ -1,6 +1,6 @@
[package] [package]
name = "icarus-dm" name = "icarus-dm"
version = "0.6.2" version = "0.6.6"
rust-version = "1.88" rust-version = "1.88"
edition = "2024" edition = "2024"
+1 -1
View File
@@ -42,7 +42,7 @@ The program has been built and can be executed by the binary file *icarus-dm*. F
### Downloading Song ### Downloading Song
```BASH ```BASH
icarus-dm download -u spacecadet -p stellar40 -h https://icarus.com -b e8407fc6-edd2-44c1-993f-08dd7324d91a icarus-dm download -u spacecadet -p stellar40 -h https://icarus.com -ha https://auth.icarus.com -b e8407fc6-edd2-44c1-993f-08dd7324d91a
``` ```
### Uploading Song with metadata ### Uploading Song with metadata
+2 -1
View File
@@ -12,7 +12,8 @@ pub fn print_help() {
Required for all actions Required for all actions
-u username -u username
-p password -p password
-h host -h api host
-ha auth api host
Required for upload with metadata Required for upload with metadata
-s path of song -s path of song
+3 -2
View File
@@ -196,6 +196,7 @@ impl CommitManager {
let auth_api = prsr.retrieve_api(parsers::api_parser::APIType::Auth); let auth_api = prsr.retrieve_api(parsers::api_parser::APIType::Auth);
let token = self.parse_token(&auth_api).await; let token = self.parse_token(&auth_api).await;
println!("Message: {}", token.message); println!("Message: {}", token.message);
let api = prsr.retrieve_api(parsers::api_parser::APIType::Main); let api = prsr.retrieve_api(parsers::api_parser::APIType::Main);
let mut dwn_loader = syncers::download::Download { api: api.clone() }; let mut dwn_loader = syncers::download::Download { api: api.clone() };
@@ -203,8 +204,8 @@ impl CommitManager {
id: song_id, id: song_id,
..Default::default() ..Default::default()
}; };
let result_fut = dwn_loader.download_song(&token, &song);
match Runtime::new().unwrap().block_on(result_fut) { match dwn_loader.download_song(&token, &song).await {
Ok(o) => { Ok(o) => {
println!("Success"); println!("Success");
let filename = String::from("audio") let filename = String::from("audio")
+1 -1
View File
@@ -15,7 +15,7 @@ fn retrieve_url_reg(api: &models::api::Api) -> String {
} }
fn retrieve_url_with_id(api: &models::api::Api, id: &uuid::Uuid) -> String { fn retrieve_url_with_id(api: &models::api::Api, id: &uuid::Uuid) -> String {
let url = format!("{}/api/{}/{}/{}", api.url, api.version, api.endpoint, id); let url = format!("{}api/{}/{}/{}", api.url, api.version, api.endpoint, id);
url url
} }
+3 -6
View File
@@ -20,7 +20,7 @@ impl Download {
token: &icarus_models::token::AccessToken, token: &icarus_models::token::AccessToken,
song: &icarus_models::song::Song, song: &icarus_models::song::Song,
) -> Result<String, MyError> { ) -> Result<String, MyError> {
self.api.endpoint = String::from("song/data/download"); self.api.endpoint = String::from("song/download");
let url = syncers::common::retrieve_url(&self.api, true, &song.id); let url = syncers::common::retrieve_url(&self.api, true, &song.id);
let access_token = token.bearer_token(); let access_token = token.bearer_token();
@@ -35,13 +35,10 @@ impl Download {
.await .await
{ {
Ok(rep) => match rep.status() { Ok(rep) => match rep.status() {
reqwest::StatusCode::OK => { reqwest::StatusCode::OK => match rep.text().await {
let data = rep.text();
match data.await {
Ok(e) => Ok(e), Ok(e) => Ok(e),
Err(er) => Err(MyError::Other(er.to_string())), Err(er) => Err(MyError::Other(er.to_string())),
} },
}
reqwest::StatusCode::UNAUTHORIZED => { reqwest::StatusCode::UNAUTHORIZED => {
Err(MyError::Other(String::from("Need to grab a new token"))) Err(MyError::Other(String::from("Need to grab a new token")))
} }