Support for icarus v2 API #52

Merged
kdeng00 merged 12 commits from icarus_v2_support into master 2025-08-30 13:23:15 -04:00
7 changed files with 14 additions and 15 deletions
Showing only changes of commit ec0cbd7da0 - Show all commits
Generated
+1 -1
View File
@@ -479,7 +479,7 @@ dependencies = [
[[package]]
name = "icarus-dm"
version = "0.6.2"
version = "0.6.6"
dependencies = [
"futures",
"http",
+1 -1
View File
@@ -1,6 +1,6 @@
[package]
name = "icarus-dm"
version = "0.6.2"
version = "0.6.6"
rust-version = "1.88"
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
```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
+2 -1
View File
@@ -12,7 +12,8 @@ pub fn print_help() {
Required for all actions
-u username
-p password
-h host
-h api host
-ha auth api host
Required for upload with metadata
-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 token = self.parse_token(&auth_api).await;
println!("Message: {}", token.message);
let api = prsr.retrieve_api(parsers::api_parser::APIType::Main);
let mut dwn_loader = syncers::download::Download { api: api.clone() };
@@ -203,8 +204,8 @@ impl CommitManager {
id: song_id,
..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) => {
println!("Success");
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 {
let url = format!("{}/api/{}/{}/{}", api.url, api.version, api.endpoint, id);
let url = format!("{}api/{}/{}/{}", api.url, api.version, api.endpoint, id);
url
}
+5 -8
View File
@@ -20,7 +20,7 @@ impl Download {
token: &icarus_models::token::AccessToken,
song: &icarus_models::song::Song,
) -> 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 access_token = token.bearer_token();
@@ -35,13 +35,10 @@ impl Download {
.await
{
Ok(rep) => match rep.status() {
reqwest::StatusCode::OK => {
let data = rep.text();
match data.await {
Ok(e) => Ok(e),
Err(er) => Err(MyError::Other(er.to_string())),
}
}
reqwest::StatusCode::OK => match rep.text().await {
Ok(e) => Ok(e),
Err(er) => Err(MyError::Other(er.to_string())),
},
reqwest::StatusCode::UNAUTHORIZED => {
Err(MyError::Other(String::from("Need to grab a new token")))
}