From 2a867778b7bbd82956247f2f17b98fdb6865a910 Mon Sep 17 00:00:00 2001 From: "alterwain@protonmail.com" Date: Sat, 22 Feb 2025 00:25:51 +0300 Subject: [PATCH] 0.1.89 upd --- Cargo.toml | 2 +- src/artworkdb.rs | 25 +++++++++---------------- 2 files changed, 10 insertions(+), 17 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 8c472e2..e6cdcca 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "itunesdb" -version = "0.1.88" +version = "0.1.89" edition = "2021" authors = ["alterwain"] diff --git a/src/artworkdb.rs b/src/artworkdb.rs index 2d4f691..1405f05 100644 --- a/src/artworkdb.rs +++ b/src/artworkdb.rs @@ -233,14 +233,7 @@ pub mod aobjects { self.children.iter_mut().find(|d| d.data.data_type == p0).unwrap() } - fn get_last_cor_id(&mut self) -> u32{ - let files = self.find_dataset(3); - let image_files = &mut files.child; - image_files.iter().map(|p| p.file.as_ref().unwrap().correlation_id).max().unwrap_or(1027) - } - - pub fn add_images(&mut self, song_dbid: u64) -> (String, String) { - let last_cor_id = self.get_last_cor_id(); + pub fn add_images(&mut self, song_dbid: u64, song_unique: u32) -> (String, String) { let ds = self.find_dataset(1); let image_items = &mut ds.child; let new_id = image_items.last().map_or(100, |p| p.data.as_ref().unwrap().id + 1); @@ -267,7 +260,7 @@ pub mod aobjects { AImageName { iname: ImageName { number_of_children: 1, - correlation_id: last_cor_id + 1, + correlation_id: 1028, ithmb_offset: 0, image_size: 20000, vertical_padding: 0, @@ -285,7 +278,7 @@ pub mod aobjects { unk2: 0, }, str: Some( - [":F", &(last_cor_id + 1).to_string(), "_1.ithmb"].concat(), + [":F", &format!("{:X}", song_unique) ,".ithmb"].concat(), ), } ), @@ -304,7 +297,7 @@ pub mod aobjects { AImageName { iname: ImageName { number_of_children: 1, - correlation_id: last_cor_id + 2, + correlation_id: 1029, ithmb_offset: 0, image_size: 80000, vertical_padding: 0, @@ -322,7 +315,7 @@ pub mod aobjects { unk2: 0, }, str: Some( - [":F", &(last_cor_id + 2).to_string(), "_1.ithmb"].concat(), + [":F", &format!("{:X}", song_unique) ,"_1.ithmb"].concat(), ), } ), @@ -338,7 +331,7 @@ pub mod aobjects { let files = self.find_dataset(3); let image_files = &mut files.child; - + image_files.clear(); image_files.append(&mut vec![ AImageItem { tag: Vec::new(), @@ -346,7 +339,7 @@ pub mod aobjects { file: Some( ImageFile { unknown1: 0, - correlation_id: last_cor_id + 1, + correlation_id: 1028, image_size: 20000, }, ), @@ -357,14 +350,14 @@ pub mod aobjects { file: Some( ImageFile { unknown1: 0, - correlation_id: last_cor_id + 2, + correlation_id: 1029, image_size: 80000, }, ), }, ]); self.data.as_mut().unwrap().next_id_for_mhii = new_id + 1; - (["F", &(last_cor_id + 1).to_string(), "_1.ithmb"].concat(), ["F", &(last_cor_id + 2).to_string(), "_1.ithmb"].concat()) + (["F", &format!("{:X}", song_unique) ,".ithmb"].concat(), ["F", &format!("{:X}", song_unique) ,"_1.ithmb"].concat()) } }