0.1.95 upd

This commit is contained in:
Michael Wain 2025-02-23 19:33:06 +03:00
parent efb59315e9
commit 2ecbe7666b
2 changed files with 26 additions and 19 deletions

View File

@ -1,6 +1,6 @@
[package] [package]
name = "itunesdb" name = "itunesdb"
version = "0.1.94" version = "0.1.95"
edition = "2021" edition = "2021"
authors = ["alterwain"] authors = ["alterwain"]

View File

@ -223,7 +223,8 @@ impl XDatabase {
tracks.retain_mut(|t| t.data.unique_id != unique_id); tracks.retain_mut(|t| t.data.unique_id != unique_id);
} }
if let XSomeList::Playlists(playlists) = &mut self.find_dataset(2).child { for ds_id in 2..=3 {
if let XSomeList::Playlists(playlists) = &mut self.find_dataset(ds_id).child {
for playlist in playlists.iter_mut() { for playlist in playlists.iter_mut() {
let mut s = playlist.elems.len(); let mut s = playlist.elems.len();
playlist.elems.retain_mut(|t| t.0.track_id != unique_id); playlist.elems.retain_mut(|t| t.0.track_id != unique_id);
@ -232,9 +233,11 @@ impl XDatabase {
} }
} }
} }
}
pub fn remove_track(&mut self, unique_id: u32, playlist_id: u64) { pub fn remove_track(&mut self, unique_id: u32, playlist_id: u64) {
if let XSomeList::Playlists(playlists) = &mut self.find_dataset(2).child { for ds_id in 2..=3 {
if let XSomeList::Playlists(playlists) = &mut self.find_dataset(ds_id).child {
for playlist in playlists.iter_mut() { for playlist in playlists.iter_mut() {
if playlist.data.persistent_playlist_id != playlist_id { continue } if playlist.data.persistent_playlist_id != playlist_id { continue }
let mut s = playlist.elems.len(); let mut s = playlist.elems.len();
@ -244,10 +247,10 @@ impl XDatabase {
} }
} }
} }
}
pub fn get_playlists(&mut self) -> Vec<XPlaylist> { pub fn get_playlists(&mut self) -> Vec<XPlaylist> {
let mut res_pls = Vec::new(); let mut res_pls = Vec::new();
if let XSomeList::Playlists(playlists) = &mut self.find_dataset(2).child { if let XSomeList::Playlists(playlists) = &mut self.find_dataset(2).child {
res_pls = playlists.to_vec(); res_pls = playlists.to_vec();
} }
@ -343,14 +346,18 @@ impl XDatabase {
} }
pub fn add_playlist(&mut self, playlist: XPlaylist) { pub fn add_playlist(&mut self, playlist: XPlaylist) {
if let XSomeList::Playlists(playlists) = &mut self.find_dataset(2).child { for ds_id in 2..=3 {
if let XSomeList::Playlists(playlists) = &mut self.find_dataset(ds_id).child {
playlists.push(playlist.clone()); playlists.push(playlist.clone());
} }
} }
}
pub fn remove_playlist(&mut self, pl_id: u64) { pub fn remove_playlist(&mut self, pl_id: u64) {
if let XSomeList::Playlists(playlists) = &mut self.find_dataset(2).child { for ds_id in 2..=3 {
if let XSomeList::Playlists(playlists) = &mut self.find_dataset(ds_id).child {
playlists.retain_mut(|p| p.data.persistent_playlist_id != pl_id); playlists.retain_mut(|p| p.data.persistent_playlist_id != pl_id);
} }
} }
}
} }