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

@ -15,24 +15,9 @@
<component name="ChangeListManager"> <component name="ChangeListManager">
<list default="true" id="52900e09-9584-4b6c-95ff-fbd4ed5d8b2c" name="Changes" comment="Add interface package. Start adding auth stuff for refreshing tokens."> <list default="true" id="52900e09-9584-4b6c-95ff-fbd4ed5d8b2c" name="Changes" comment="Add interface package. Start adding auth stuff for refreshing tokens.">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" /> <change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Cargo.lock" beforeDir="false" afterPath="$PROJECT_DIR$/Cargo.lock" afterDir="false" />
<change beforePath="$PROJECT_DIR$/Cargo.toml" beforeDir="false" afterPath="$PROJECT_DIR$/Cargo.toml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/migrations/20230816135241_initial.sql" beforeDir="false" afterPath="$PROJECT_DIR$/migrations/20230816135241_initial.sql" afterDir="false" />
<change beforePath="$PROJECT_DIR$/navidrome/Cargo.lock" beforeDir="false" afterPath="$PROJECT_DIR$/navidrome/Cargo.lock" afterDir="false" />
<change beforePath="$PROJECT_DIR$/navidrome/Cargo.toml" beforeDir="false" afterPath="$PROJECT_DIR$/navidrome/Cargo.toml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/navidrome/src/client/auth.rs" beforeDir="false" />
<change beforePath="$PROJECT_DIR$/navidrome/src/client/builder.rs" beforeDir="false" afterPath="$PROJECT_DIR$/navidrome/src/client/builder.rs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/navidrome/src/client/library.rs" beforeDir="false" afterPath="$PROJECT_DIR$/navidrome/src/client/library.rs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/navidrome/src/client/mod.rs" beforeDir="false" afterPath="$PROJECT_DIR$/navidrome/src/client/mod.rs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/navidrome/src/client/playlists.rs" beforeDir="false" afterPath="$PROJECT_DIR$/navidrome/src/client/playlists.rs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/navidrome/src/models/mod.rs" beforeDir="false" afterPath="$PROJECT_DIR$/navidrome/src/models/mod.rs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/navidrome/src/models/navidrome.rs" beforeDir="false" afterPath="$PROJECT_DIR$/navidrome/src/models/subsonic.rs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/daemon/mod.rs" beforeDir="false" afterPath="$PROJECT_DIR$/src/daemon/mod.rs" afterDir="false" /> <change beforePath="$PROJECT_DIR$/src/daemon/mod.rs" beforeDir="false" afterPath="$PROJECT_DIR$/src/daemon/mod.rs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/daemon/update_playlists.rs" beforeDir="false" afterPath="$PROJECT_DIR$/src/daemon/update_playlists.rs" afterDir="false" /> <change beforePath="$PROJECT_DIR$/src/daemon/update_playlists.rs" beforeDir="false" afterPath="$PROJECT_DIR$/src/daemon/update_playlists.rs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/daemon/update_tracks.rs" beforeDir="false" /> <change beforePath="$PROJECT_DIR$/src/subsonic.rs" beforeDir="false" afterPath="$PROJECT_DIR$/src/subsonic.rs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/listenbrainz.rs" beforeDir="false" afterPath="$PROJECT_DIR$/src/listenbrainz.rs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main.rs" beforeDir="false" afterPath="$PROJECT_DIR$/src/main.rs" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/models.rs" beforeDir="false" afterPath="$PROJECT_DIR$/src/models.rs" afterDir="false" />
</list> </list>
<option name="SHOW_DIALOG" value="false" /> <option name="SHOW_DIALOG" value="false" />
<option name="HIGHLIGHT_CONFLICTS" value="true" /> <option name="HIGHLIGHT_CONFLICTS" value="true" />
@ -167,7 +152,7 @@
<workItem from="1694621211523" duration="3713000" /> <workItem from="1694621211523" duration="3713000" />
<workItem from="1708962769688" duration="6050000" /> <workItem from="1708962769688" duration="6050000" />
<workItem from="1710605458078" duration="1011000" /> <workItem from="1710605458078" duration="1011000" />
<workItem from="1710677603495" duration="12586000" /> <workItem from="1710677603495" duration="13610000" />
</task> </task>
<task id="LOCAL-00001" summary="Structure"> <task id="LOCAL-00001" summary="Structure">
<created>1692008860369</created> <created>1692008860369</created>

View File

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

View File

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