0.1.11 upd
This commit is contained in:
parent
f4d38a7937
commit
4204fdcda8
2
Cargo.lock
generated
2
Cargo.lock
generated
@ -90,7 +90,7 @@ checksum = "d75a2a4b1b190afb6f5425f10f6a8f959d2ea0b9c2b1d79553551850539e4674"
|
|||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "itunesdb"
|
name = "itunesdb"
|
||||||
version = "0.1.9"
|
version = "0.1.11"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"bincode",
|
"bincode",
|
||||||
"env_logger",
|
"env_logger",
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
[package]
|
[package]
|
||||||
name = "itunesdb"
|
name = "itunesdb"
|
||||||
version = "0.1.10"
|
version = "0.1.11"
|
||||||
edition = "2021"
|
edition = "2021"
|
||||||
authors = ["alterwain"]
|
authors = ["alterwain"]
|
||||||
|
|
||||||
|
@ -211,7 +211,7 @@ pub struct JumpTable {
|
|||||||
count: u32, // the count of entries starting with this letter in the corresponding MHOD52.
|
count: u32, // the count of entries starting with this letter in the corresponding MHOD52.
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, PartialEq, Debug)]
|
#[derive(Serialize, Deserialize, PartialEq, Debug, Clone)]
|
||||||
pub struct Playlist {
|
pub struct Playlist {
|
||||||
data_object_child_count: u32,
|
data_object_child_count: u32,
|
||||||
pub playlist_item_count: u32,
|
pub playlist_item_count: u32,
|
||||||
|
@ -31,7 +31,7 @@ pub struct XAlbumItem {
|
|||||||
pub args: Vec<XArgument>
|
pub args: Vec<XArgument>
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, serde::Serialize)]
|
#[derive(Debug, serde::Serialize, Clone)]
|
||||||
pub struct XPlaylist {
|
pub struct XPlaylist {
|
||||||
pub header: ChunkHeader,
|
pub header: ChunkHeader,
|
||||||
pub data: Playlist,
|
pub data: Playlist,
|
||||||
@ -82,10 +82,10 @@ impl XPlaylist {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn get_arg(&self, id: u32) -> String {
|
fn get_arg(&self, id: u32) -> String {
|
||||||
for arg in self.args {
|
for arg in self.args.iter() {
|
||||||
if let XPlArgument::String(val) = arg {
|
if let XPlArgument::String(val) = arg {
|
||||||
if val.arg_type == id {
|
if val.arg_type == id {
|
||||||
return val.val;
|
return val.val.clone();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -147,7 +147,7 @@ impl XTrackItem {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn get_arg(&self, id: u32) -> String {
|
fn get_arg(&self, id: u32) -> String {
|
||||||
self.args.iter().find(|t| t.arg_type == id).map_or(String::new(), |t| t.val)
|
self.args.iter().find(|t| t.arg_type == id).map_or(String::new(), |t| t.val.clone())
|
||||||
}
|
}
|
||||||
|
|
||||||
fn update_arg(&mut self, id: u32, val: String) {
|
fn update_arg(&mut self, id: u32, val: String) {
|
||||||
@ -183,11 +183,11 @@ impl XDatabase {
|
|||||||
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 = [&mut res_pls, playlists].concat();
|
res_pls = playlists.to_vec();
|
||||||
}
|
}
|
||||||
|
|
||||||
if let XSomeList::Playlists(playlists) = &mut self.find_dataset(3).child {
|
if let XSomeList::Playlists(playlists) = &mut self.find_dataset(3).child {
|
||||||
res_pls = [&mut res_pls, playlists].concat();
|
res_pls = [res_pls, playlists.to_vec()].concat();
|
||||||
}
|
}
|
||||||
|
|
||||||
res_pls
|
res_pls
|
||||||
@ -202,6 +202,13 @@ impl XDatabase {
|
|||||||
1
|
1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn get_track(&mut self, id: u32) -> Option<&XTrackItem> {
|
||||||
|
if let XSomeList::TrackList(tracks) = &mut self.find_dataset(1).child {
|
||||||
|
return tracks.iter().find(|t| t.data.unique_id == id)
|
||||||
|
}
|
||||||
|
None
|
||||||
|
}
|
||||||
|
|
||||||
pub fn add_track(&mut self, track: XTrackItem) {
|
pub fn add_track(&mut self, track: XTrackItem) {
|
||||||
self.add_track_to_playlists(2, &track);
|
self.add_track_to_playlists(2, &track);
|
||||||
self.add_track_to_playlists(3, &track);
|
self.add_track_to_playlists(3, &track);
|
||||||
@ -213,7 +220,9 @@ impl XDatabase {
|
|||||||
|
|
||||||
fn add_track_to_playlists(&mut self, n: u32, track: &XTrackItem) {
|
fn add_track_to_playlists(&mut self, n: u32, track: &XTrackItem) {
|
||||||
if let XSomeList::Playlists(playlists) = &mut self.find_dataset(n).child {
|
if let XSomeList::Playlists(playlists) = &mut self.find_dataset(n).child {
|
||||||
let playlist = playlists.last_mut().unwrap();
|
let playlist = playlists.iter_mut().find(|t| t.data.is_master_playlist_flag != 0);
|
||||||
|
if playlist.is_none() { return; }
|
||||||
|
let playlist = playlist.unwrap();
|
||||||
playlist.data.playlist_item_count += 1;
|
playlist.data.playlist_item_count += 1;
|
||||||
|
|
||||||
let elem = playlist.elems.last().unwrap();
|
let elem = playlist.elems.last().unwrap();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user