Update playlists

This commit is contained in:
jude
2024-03-17 17:11:46 +00:00
parent 3a196153ba
commit 587f82932b
3 changed files with 28 additions and 29 deletions

View File

@ -75,7 +75,7 @@ async fn update_playlist(
match filtered {
Some(track) => {
tracks.push(track);
tracks.push(track.clone());
}
None => {
println!(
@ -86,6 +86,10 @@ async fn update_playlist(
}
}
media_client
.update_playlist(playlist.playlist_id.unwrap().to_string(), vec![], vec![])
.await?;
Ok(())
}

View File

@ -60,20 +60,30 @@ impl Subsonic {
pub async fn update_playlist(
&self,
playlist_id: String,
add_ids: Vec<String>,
remove_indexes: Vec<usize>,
add: Vec<String>,
remove: Vec<usize>,
) -> Result<Vec<Track>, Box<dyn std::error::Error>> {
let mut query_params = vec![
("u", self.username.to_string()),
("s", self.salt.to_string()),
("t", self.hash.to_string()),
("v", String::from("16")),
("c", String::from("playlistd")),
("f", String::from("json")),
];
for id in add {
query_params.push(("songIdToAdd", id));
}
for index in remove {
query_params.push(("songIndexToRemove", index.to_string()));
}
Ok(self
.client
.get(format!("{}/search3", self.base))
.query(&[
("u", self.username.as_str()),
("s", self.salt.as_str()),
("t", self.hash.as_str()),
("v", "16"),
("c", "playlistd"),
("f", "json"),
])
.query(&query_params)
.send()
.await?
.json::<Vec<Track>>()
@ -116,7 +126,7 @@ impl SubsonicBuilder {
self
}
pub fn build(mut self) -> Result<Subsonic, Box<dyn std::error::Error>> {
pub fn build(self) -> Result<Subsonic, Box<dyn std::error::Error>> {
let salt = Uuid::new_v4().simple().to_string();
let hash = format!(
"{:?}",