0.1.30 upd

This commit is contained in:
Michael Wain 2025-02-15 22:14:17 +03:00
parent bd2173cf16
commit 103ddec880
3 changed files with 23 additions and 41 deletions

2
Cargo.lock generated
View File

@ -90,7 +90,7 @@ checksum = "d75a2a4b1b190afb6f5425f10f6a8f959d2ea0b9c2b1d79553551850539e4674"
[[package]]
name = "itunesdb"
version = "0.1.28"
version = "0.1.30"
dependencies = [
"bincode",
"env_logger",

View File

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

View File

@ -1,6 +1,6 @@
pub mod deserializer {
use log::info;
use crate::artworkdb::aobjects::{ADataSet, ADatabase, AImageArg, AImageItem, AImageName, ASomeList};
use crate::artworkdb::aobjects::{ADataSet, ADatabase, AImageItem, ALocationTag, ASomeList};
use crate::artworkdb::objects::{ChunkHeader, ChunkType, DataSet, Database, ImageItem, ImageName, LocationTag};
enum ChunkState {
@ -54,36 +54,23 @@ pub mod deserializer {
}
},
ChunkType::LocationTag => {
u = usize::try_from(header.children_count).unwrap() - 12;
u = usize::try_from(header.end_of_chunk).unwrap() - 12;
let ds: LocationTag = bincode::deserialize(&data[i..i + u]).unwrap();
if ds.tag_type == 3 {
if let ASomeList::Images(images) = &mut adb.find_dataset(1).child {
if let AImageArg::Name(name) = images.last_mut().unwrap().args.iter_mut().filter(|t| {
if let AImageArg::Name(name) = t {
return true;
}
false
})
.last()
.unwrap() {
let mut bytes = Vec::new();
let str_end = u32::from_le_bytes(data[i+12..i+16].try_into().unwrap()) as usize;
let mut h = i+24;
while h < i+24+str_end {
bytes.push(u16::from_le_bytes(data[h..h+2].try_into().unwrap()));
h+=2;
}
let g = String::from_utf16(&bytes).unwrap();
info!("str: {}", g);
name.args.push((ds, g));
if let ASomeList::Images(images) = &mut adb.find_dataset(1).child {
let mut str = None;
if ds.tag_type == 3 {
let mut bytes = Vec::new();
let str_end = u32::from_le_bytes(data[i+12..i+16].try_into().unwrap()) as usize;
let mut h = i+24;
while h < i+24+str_end {
bytes.push(u16::from_le_bytes(data[h..h+2].try_into().unwrap()));
h+=2;
}
let g = String::from_utf16(&bytes).unwrap();
info!("str: {}", g);
str = Some(g);
}
} else {
if let ASomeList::Images(images) = &mut adb.find_dataset(1).child {
images.last_mut().unwrap().args.push(AImageArg::Location(ds));
}
images.last_mut().unwrap().args.push(ALocationTag { data: ds, str, child: None });
}
},
ChunkType::ImageName => {
@ -91,7 +78,7 @@ pub mod deserializer {
u = usize::try_from(header.end_of_chunk).unwrap() - 12;
let ds: ImageName = bincode::deserialize(&data[i..i + u]).unwrap();
if let ASomeList::Images(images) = &mut adb.find_dataset(1).child {
images.last_mut().unwrap().args.push(AImageArg::Name(AImageName{ data: ds, args: Vec::new() }));
images.last_mut().unwrap().args.last_mut().unwrap().child = Some(ds);
}
},
_ => { u = 1; info!("Unknown stuff happened"); }
@ -139,19 +126,14 @@ pub mod aobjects {
#[derive(Debug, serde::Serialize)]
pub struct AImageItem {
pub data: ImageItem,
pub args: Vec<AImageArg>,
pub args: Vec<ALocationTag>,
}
#[derive(Debug, serde::Serialize)]
pub enum AImageArg {
Name(AImageName),
Location(LocationTag),
}
#[derive(Debug, serde::Serialize)]
pub struct AImageName {
pub data: ImageName,
pub args: Vec<(LocationTag, String)>
pub struct ALocationTag {
pub data: LocationTag,
pub str: Option<String>,
pub child: Option<ImageName>
}
}