0.1.95 upd
This commit is contained in:
parent
efb59315e9
commit
2ecbe7666b
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "itunesdb"
|
||||
version = "0.1.94"
|
||||
version = "0.1.95"
|
||||
edition = "2021"
|
||||
authors = ["alterwain"]
|
||||
|
||||
|
@ -223,31 +223,34 @@ impl XDatabase {
|
||||
tracks.retain_mut(|t| t.data.unique_id != unique_id);
|
||||
}
|
||||
|
||||
if let XSomeList::Playlists(playlists) = &mut self.find_dataset(2).child {
|
||||
for playlist in playlists.iter_mut() {
|
||||
let mut s = playlist.elems.len();
|
||||
playlist.elems.retain_mut(|t| t.0.track_id != unique_id);
|
||||
s -= playlist.elems.len();
|
||||
playlist.data.playlist_item_count -= (s as u32);
|
||||
for ds_id in 2..=3 {
|
||||
if let XSomeList::Playlists(playlists) = &mut self.find_dataset(ds_id).child {
|
||||
for playlist in playlists.iter_mut() {
|
||||
let mut s = playlist.elems.len();
|
||||
playlist.elems.retain_mut(|t| t.0.track_id != unique_id);
|
||||
s -= playlist.elems.len();
|
||||
playlist.data.playlist_item_count -= (s as u32);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn remove_track(&mut self, unique_id: u32, playlist_id: u64) {
|
||||
if let XSomeList::Playlists(playlists) = &mut self.find_dataset(2).child {
|
||||
for playlist in playlists.iter_mut() {
|
||||
if playlist.data.persistent_playlist_id != playlist_id { continue }
|
||||
let mut s = playlist.elems.len();
|
||||
playlist.elems.retain_mut(|t| t.0.track_id != unique_id);
|
||||
s -= playlist.elems.len();
|
||||
playlist.data.playlist_item_count -= (s as u32);
|
||||
for ds_id in 2..=3 {
|
||||
if let XSomeList::Playlists(playlists) = &mut self.find_dataset(ds_id).child {
|
||||
for playlist in playlists.iter_mut() {
|
||||
if playlist.data.persistent_playlist_id != playlist_id { continue }
|
||||
let mut s = playlist.elems.len();
|
||||
playlist.elems.retain_mut(|t| t.0.track_id != unique_id);
|
||||
s -= playlist.elems.len();
|
||||
playlist.data.playlist_item_count -= (s as u32);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn get_playlists(&mut self) -> Vec<XPlaylist> {
|
||||
let mut res_pls = Vec::new();
|
||||
|
||||
if let XSomeList::Playlists(playlists) = &mut self.find_dataset(2).child {
|
||||
res_pls = playlists.to_vec();
|
||||
}
|
||||
@ -343,14 +346,18 @@ impl XDatabase {
|
||||
}
|
||||
|
||||
pub fn add_playlist(&mut self, playlist: XPlaylist) {
|
||||
if let XSomeList::Playlists(playlists) = &mut self.find_dataset(2).child {
|
||||
playlists.push(playlist.clone());
|
||||
for ds_id in 2..=3 {
|
||||
if let XSomeList::Playlists(playlists) = &mut self.find_dataset(ds_id).child {
|
||||
playlists.push(playlist.clone());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn remove_playlist(&mut self, pl_id: u64) {
|
||||
if let XSomeList::Playlists(playlists) = &mut self.find_dataset(2).child {
|
||||
playlists.retain_mut(|p| p.data.persistent_playlist_id != pl_id);
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user