Updated dependencies (#48)

* Updated dependencies

* Saving changes

* More changes

* More changes

* Updated dependencies

* Updated readme

* Saving changes

* Cleanup
This commit was merged in pull request #48.
This commit is contained in:
KD
2025-04-03 23:16:37 -04:00
committed by GitHub
parent 885f1db3af
commit d5f95ddf9b
10 changed files with 49 additions and 48 deletions
+2 -1
View File
@@ -16,4 +16,5 @@ serde = { version = "1.0.219", features = ["derive"] }
serde_json = "1.0.140"
tokio = { version = "1.44.1", features = ["full"] }
tokio-util = { version = "0.7.14", features = ["codec"] }
icarus_models = { git = "ssh://git@git.kundeng.us/phoenix/icarus_models.git", tag = "v0.2.0" }
uuid = { version = "1.16.0", features = ["v4", "serde"] }
icarus_models = { git = "ssh://git@git.kundeng.us/phoenix/icarus_models.git", tag = "v0.3.0-devel-6a0135c6fa-111" }
+2 -2
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 15
icarus-dm download -u spacecadet -p stellar40 -h https://icarus.com -b e8407fc6-edd2-44c1-993f-08dd7324d91a
```
### Uploading Song with metadata
@@ -66,7 +66,7 @@ icarus-dm retrieve -u spacecadet -p stellar40 -h https://icarus.com -rt songs
### Deleting Song
```BASH
icarus-dm delete -u spacecadet -p stellar40 -h https://icarus.com -D 15
icarus-dm delete -u spacecadet -p stellar40 -h https://icarus.com -D e8407fc6-edd2-44c1-993f-08dd7324d91a
```
+34 -37
View File
@@ -152,7 +152,7 @@ impl CommitManager {
let value = &arg.value;
if flag == "-D" {
song.id = value.parse::<i32>().unwrap();
song.id = uuid::Uuid::from_str(value.as_str()).unwrap();
}
}
@@ -175,7 +175,7 @@ impl CommitManager {
fn download_song(&self) {
println!("Deleting song");
let dwn = self.ica_action.retrieve_flag_value(&String::from("-b"));
let id: i32 = dwn.parse::<i32>().unwrap();
let id = uuid::Uuid::from_str(dwn.as_str()).unwrap();
let mut prsr = parsers::api_parser::APIParser {
api: models::api::API::default(),
@@ -337,7 +337,7 @@ impl CommitManager {
}
let mut cover_art = icarus_models::coverart::CoverArt {
id: 0,
id: uuid::Uuid::nil(),
title: String::new(),
path: cover_path.clone(),
data: Vec::new(),
@@ -430,7 +430,7 @@ impl CommitManager {
};
songs.push(icarus_models::song::Song {
id: -1,
id: uuid::Uuid::nil(),
title: track.title.clone(),
artist: track.artist.clone(),
disc: track.disc.clone(),
@@ -445,7 +445,7 @@ impl CommitManager {
audio_type: String::from("FLAC"),
directory: source_directory.clone(),
filename: filename,
user_id: -1,
user_id: uuid::Uuid::nil(),
data: Vec::new(),
date_created: String::new(),
});
@@ -471,15 +471,12 @@ impl CommitManager {
panic!("Directory does not exist");
}
let mut cover_art = icarus_models::coverart::CoverArt {
id: 0,
title: String::new(),
path: match self.get_cover_art_path(&sourcepath) {
Ok(o) => o,
Err(_) => String::new(),
},
data: Vec::new(),
let coverart_path = match self.get_cover_art_path(&sourcepath) {
Ok(path) => path,
Err(_) => String::new(),
};
let mut cover_art =
icarus_models::coverart::init::init_coverart_only_path(coverart_path.clone());
let metadatapath = match self.get_metadata_path(&sourcepath) {
Ok(o) => o,
Err(_) => String::new(),
@@ -517,6 +514,30 @@ impl CommitManager {
Ok(())
}
fn get_cover_art_path(&self, directory_path: &String) -> Result<String> {
for entry in read_dir(std::path::Path::new(directory_path))? {
let entry = entry?;
let file_type = entry.file_type();
let file_name = entry.file_name();
println!("file type: {:?}", file_type);
println!("file name: {:?}", file_name);
match self.find_file_extension(&file_name) {
En::ImageFile => {
let directory_part = directory_path.clone();
let fname = utilities::string::o_to_string(&file_name);
let fullpath = directory_part + "/" + &fname.unwrap();
return Ok(fullpath);
}
_ => {}
}
}
Ok(String::new())
}
fn find_file_extension(&self, file_name: &std::ffi::OsString) -> En {
let file_name_str = Some(file_name.clone().into_string());
@@ -565,30 +586,6 @@ impl CommitManager {
return En::Other;
}
fn get_cover_art_path(&self, directory_path: &String) -> Result<String> {
for entry in read_dir(std::path::Path::new(directory_path))? {
let entry = entry?;
let file_type = entry.file_type();
let file_name = entry.file_name();
println!("file type: {:?}", file_type);
println!("file name: {:?}", file_name);
match self.find_file_extension(&file_name) {
En::ImageFile => {
let directory_part = directory_path.clone();
let fname = utilities::string::o_to_string(&file_name);
let fullpath = directory_part + "/" + &fname.unwrap();
return Ok(fullpath);
}
_ => {}
}
}
Ok(String::new())
}
fn get_metadata_path(&self, directory_path: &String) -> Result<String> {
for entry in read_dir(std::path::Path::new(directory_path))? {
let entry = entry?;
+1 -1
View File
@@ -29,7 +29,7 @@ impl TokenManager {
println!("URL: {}", url);
let mut token = icarus_models::token::AccessToken {
user_id: -1,
user_id: uuid::Uuid::nil(),
username: String::new(),
token: String::new(),
token_type: String::new(),
+3 -2
View File
@@ -1,6 +1,6 @@
use crate::models;
pub fn retrieve_url(api: &models::api::API, with_id: bool, id: i32) -> String {
pub fn retrieve_url(api: &models::api::API, with_id: bool, id: &uuid::Uuid) -> String {
if with_id {
retrieve_url_with_id(&api, id)
} else {
@@ -10,6 +10,7 @@ pub fn retrieve_url(api: &models::api::API, with_id: bool, id: i32) -> String {
fn retrieve_url_reg(api: &models::api::API) -> String {
let mut url: String = String::from(&api.url);
url += &String::from("/");
url += &String::from("api/");
url += &String::from(&api.version);
url += &String::from("/");
@@ -19,7 +20,7 @@ fn retrieve_url_reg(api: &models::api::API) -> String {
return url;
}
fn retrieve_url_with_id(api: &models::api::API, id: i32) -> String {
fn retrieve_url_with_id(api: &models::api::API, id: &uuid::Uuid) -> String {
let mut url: String = String::from(&api.url);
url += &String::from("api/");
url += &String::from(&api.version);
+1 -1
View File
@@ -25,7 +25,7 @@ impl Delete {
song: &icarus_models::song::Song,
) -> Result<icarus_models::song::Song, std::io::Error> {
self.api.endpoint = "song/data/delete".to_owned();
let url = syncers::common::retrieve_url(&self.api, true, song.id);
let url = syncers::common::retrieve_url(&self.api, true, &song.id);
let client = reqwest::Client::builder().build().unwrap();
let access_token = token.bearer_token();
let response = client
+3 -1
View File
@@ -28,9 +28,11 @@ impl Download {
song: &icarus_models::song::Song,
) -> Result<String, MyError> {
self.api.endpoint = String::from("song/data/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();
println!("Url: {:?}", url);
let client = reqwest::Client::builder().build().unwrap();
match client
+1 -1
View File
@@ -22,7 +22,7 @@ impl RetrieveRecords {
token: &icarus_models::token::AccessToken,
) -> Result<Vec<icarus_models::song::Song>, Error> {
self.api.endpoint = String::from("song");
let url = syncers::common::retrieve_url(&self.api, false, 0);
let url = syncers::common::retrieve_url(&self.api, false, &uuid::Uuid::nil());
let access_token = token.bearer_token();
let client = reqwest::Client::builder().build().unwrap();
+1 -1
View File
@@ -26,7 +26,7 @@ impl Upload {
cover: &icarus_models::coverart::CoverArt,
) -> Result<reqwest::Response, reqwest::Error> {
self.api.endpoint = String::from("song/data/upload/with/data");
let url = syncers::common::retrieve_url(&self.api, false, 0);
let url = syncers::common::retrieve_url(&self.api, false, &uuid::Uuid::nil());
let access_token = token.bearer_token();
if url.is_empty() {
+1 -1
View File
@@ -23,7 +23,7 @@ impl Checks {
index += 1;
}
return index;
index
}
}