diff --git a/Cargo.lock b/Cargo.lock index ae0460b..432efec 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -90,7 +90,7 @@ checksum = "d75a2a4b1b190afb6f5425f10f6a8f959d2ea0b9c2b1d79553551850539e4674" [[package]] name = "itunesdb" -version = "0.1.18" +version = "0.1.19" dependencies = [ "bincode", "env_logger", diff --git a/Cargo.toml b/Cargo.toml index 43987f6..abddeb9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "itunesdb" -version = "0.1.18" +version = "0.1.19" edition = "2021" authors = ["alterwain"] diff --git a/src/xobjects.rs b/src/xobjects.rs index 3e307b7..7d0083a 100644 --- a/src/xobjects.rs +++ b/src/xobjects.rs @@ -256,7 +256,7 @@ impl XDatabase { let mut pl_item = elem.0.clone(); pl_item.track_id = track.data.unique_id; - pl_item.group_id = rand::thread_rng().gen_range(10..255); + pl_item.group_id = rand::random(); let mut args = elem.1.clone(); if let XPlArgument::RawArgument(raw) = args.last_mut().unwrap() { raw[24] = pl_item.group_id as u8; @@ -265,4 +265,14 @@ impl XDatabase { playlist.elems.push((pl_item, args)); } } + + pub fn add_playlist(&mut self, playlist: XPlaylist) { + if let XSomeList::Playlists(playlists) = &mut self.find_dataset(2).child { + playlists.push(playlist.clone()); + } + + if let XSomeList::Playlists(playlists) = &mut self.find_dataset(3).child { + playlists.push(playlist); + } + } } \ No newline at end of file