Multi upload (#64)

* Added comments

* Added TODO

* Got it working

* Updated documentation

* Version bump

* Code formatting and cleanup
This commit was merged in pull request #64.
This commit is contained in:
KD
2025-08-29 21:57:41 -04:00
committed by GitHub
parent 07402d1b5e
commit 3ad8ac2fba
4 changed files with 33 additions and 19 deletions
Generated
+1 -1
View File
@@ -479,7 +479,7 @@ dependencies = [
[[package]] [[package]]
name = "icarus-dm" name = "icarus-dm"
version = "0.6.1" version = "0.6.2"
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.1" version = "0.6.2"
rust-version = "1.88" rust-version = "1.88"
edition = "2024" edition = "2024"
+2 -2
View File
@@ -48,13 +48,13 @@ icarus-dm download -u spacecadet -p stellar40 -h https://icarus.com -b e8407fc6-
### Uploading Song with metadata ### Uploading Song with metadata
```BASH ```BASH
icarus-dm upload-meta -u spacecadet -p stellar40 -h https://icarus.com -s /path/of/song.flac -t 1 -m /path/to/metadata/config/collection.json -ca /path/to/cover/art/image.png icarus-dm upload-meta -u spacecadet -p stellar40 -h https://icarus.com -ha https://auth.icarus.com -s /path/of/song.flac -t 1 -m /path/to/metadata/config/collection.json -ca /path/to/cover/art/image.png
``` ```
### Uploading Song with metadata from directory ### Uploading Song with metadata from directory
```BASH ```BASH
icarus-dm upload-meta -u spacecadet -p stellar40 -h https://icarus.com -smca /path/where/songs/and/metadata/exists/ icarus-dm upload-meta -u spacecadet -p stellar40 -h https://icarus.com -ha https://auth.icarus.com -smca /path/where/songs/and/metadata/exists/
``` ```
### Retrieving Song in json ### Retrieving Song in json
+29 -15
View File
@@ -332,6 +332,7 @@ impl CommitManager {
} }
} }
/// Only uploading one song
async fn sing_target_upload( async fn sing_target_upload(
&mut self, &mut self,
songpath: &String, songpath: &String,
@@ -413,6 +414,7 @@ impl CommitManager {
} }
} }
/// Upload song to the queue to get processed
async fn upload_song_process(&self, data: &UploadSongMembers) -> Result<()> { async fn upload_song_process(&self, data: &UploadSongMembers) -> Result<()> {
let mut up = syncers::upload::Upload::default(); let mut up = syncers::upload::Upload::default();
let host = self.ica_action.retrieve_flag_value(&String::from("-h")); let host = self.ica_action.retrieve_flag_value(&String::from("-h"));
@@ -558,27 +560,39 @@ impl CommitManager {
cover_art.data = cover_art.to_data().unwrap(); cover_art.data = cover_art.to_data().unwrap();
match self.get_songs(&metadatapath, sourcepath) { match self.get_songs(&metadatapath, sourcepath) {
Ok(sngs) => { Ok(sngs) => match icarus_models::album::collection::parse_album(&metadatapath) {
for song in sngs { Ok(album) => {
match Runtime::new() for song in sngs {
.unwrap() let members = UploadSongMembers {
.block_on(up.upload_song_with_metadata(&token, &song, &cover_art)) song: song,
{ coverart: cover_art.clone(),
Ok(o) => { token: token.clone(),
println!("Response: {o:?}"); album: album.clone(),
};
match self.upload_song_process(&members).await {
Ok(o) => {
println!("Response: {o:?}");
}
Err(err) => {
println!("Error: {err:?}");
return Err(err);
}
} }
Err(err) => { }
println!("Error: {err:?}");
} Ok(())
};
} }
} Err(err) => {
println!("Error: {err:?}");
Err(std::io::Error::other(err.to_string()))
}
},
Err(error) => { Err(error) => {
println!("Error: {error:?}"); println!("Error: {error:?}");
Err(std::io::Error::other(error.to_string()))
} }
} }
Ok(())
} }
fn get_cover_art_path(&self, directory_path: &String) -> Result<String> { fn get_cover_art_path(&self, directory_path: &String) -> Result<String> {