0.1.43 upd

This commit is contained in:
Michael Wain 2025-02-17 04:42:45 +03:00
parent 103b17b85e
commit 4d46a01b87
2 changed files with 24 additions and 23 deletions

View File

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

View File

@ -47,13 +47,13 @@ pub mod deserializer {
u = usize::try_from(header.end_of_chunk).unwrap() - 12;
let ai: ImageItem = bincode::deserialize(&data[i..i+u]).unwrap();
let images = &mut adb.find_dataset(last_type).child;
images.push(AImageItem { data: Some(ai), tag: None, file: None });
images.push(AImageItem { data: Some(ai), tag: Vec::new(), file: None });
},
ChunkType::FileImage => {
u = usize::try_from(header.end_of_chunk).unwrap() - 12;
let ai: ImageFile = bincode::deserialize(&data[i..i+u]).unwrap();
let images = &mut adb.find_dataset(last_type).child;
images.push(AImageItem { data: None, tag: None, file: Some(ai) });
images.push(AImageItem { data: None, tag: Vec::new(), file: Some(ai) });
},
ChunkType::LocationTag => {
u = usize::try_from(header.end_of_chunk).unwrap() - 12;
@ -73,10 +73,10 @@ pub mod deserializer {
let g = String::from_utf16(&bytes).unwrap();
info!("str: {}", g);
str = Some(g);
images.last_mut().unwrap().tag.as_mut().unwrap().child.as_mut().unwrap().tag = Some(ThirdTypeTag { data: ds, str });
images.last_mut().unwrap().tag.last_mut().unwrap().child.as_mut().unwrap().tag = Some(ThirdTypeTag { data: ds, str });
},
2 => {
images.last_mut().unwrap().tag = Some(SecondTypeTag { data: ds, str, child: None });
images.last_mut().unwrap().tag.push(SecondTypeTag { data: ds, str, child: None });
},
_ => { u = usize::try_from(header.children_count).unwrap() - 12; }
}
@ -86,7 +86,7 @@ pub mod deserializer {
u = usize::try_from(header.end_of_chunk).unwrap() - 12;
let ds: ImageName = bincode::deserialize(&data[i..i + u]).unwrap();
let images = &mut adb.find_dataset(last_type).child;
images.last_mut().unwrap().tag.as_mut().unwrap().child = Some(AImageName { iname: ds, tag: None });
images.last_mut().unwrap().tag.last_mut().unwrap().child = Some(AImageName { iname: ds, tag: None });
},
_ => { u = 1; info!("Unknown stuff happened {:X?}", header.chunk_type.to_vec()); }
}
@ -127,23 +127,24 @@ pub mod serializer {
item.append(&mut bincode::serialize(img.data.as_ref().unwrap()).unwrap());
item.append(&mut [0; 100].to_vec());
entry_bytes.append(&mut item);
let o = img.tag.as_ref().unwrap();
let mut data = [2u32.to_le_bytes(), 0u32.to_le_bytes(), 0u32.to_le_bytes()].concat();
entry_bytes.append(&mut generate_header(ChunkType::LocationTag, 12, 0));
entry_bytes.append(&mut data);
for o in &img.tag {
let mut data = [2u32.to_le_bytes(), 0u32.to_le_bytes(), 0u32.to_le_bytes()].concat();
entry_bytes.append(&mut generate_header(ChunkType::LocationTag, 12, 0));
entry_bytes.append(&mut data);
if let Some(name) = &o.child {
let mut nb = Vec::new();
let arg = name.tag.as_ref().unwrap();
let mut str_b = string_to_ipod16(arg.str.as_ref().unwrap());
str_b = [3u32.to_le_bytes().to_vec(), 0u32.to_le_bytes().to_vec(), 0u32.to_le_bytes().to_vec(), (str_b.len() as u32).to_le_bytes().to_vec(), 2u32.to_le_bytes().to_vec(), 0u32.to_le_bytes().to_vec(), str_b ].concat();
nb.append(&mut generate_header(ChunkType::LocationTag, 12, str_b.len()));
nb.append(&mut str_b);
args.append(&mut generate_header(ChunkType::ImageName, 76, nb.len()));
args.append(&mut bincode::serialize(name).unwrap());
if let Some(name) = &o.child {
let mut nb = Vec::new();
let arg = name.tag.as_ref().unwrap();
let mut str_b = string_to_ipod16(arg.str.as_ref().unwrap());
str_b = [3u32.to_le_bytes().to_vec(), 0u32.to_le_bytes().to_vec(), 0u32.to_le_bytes().to_vec(), (str_b.len() as u32).to_le_bytes().to_vec(), 2u32.to_le_bytes().to_vec(), 0u32.to_le_bytes().to_vec(), str_b ].concat();
nb.append(&mut generate_header(ChunkType::LocationTag, 12, str_b.len()));
nb.append(&mut str_b);
args.append(&mut generate_header(ChunkType::ImageName, 76, nb.len()));
args.append(&mut bincode::serialize(name).unwrap());
}
}
}
@ -207,7 +208,7 @@ pub mod aobjects {
#[derive(Debug, serde::Serialize)]
pub struct AImageItem {
pub tag: Option<SecondTypeTag>,
pub tag: Vec<SecondTypeTag>,
pub data: Option<ImageItem>,
pub file: Option<ImageFile>,
}