modified: src/deserializer.rs

modified:   src/main.rs
	modified:   src/serializer.rs
This commit is contained in:
Michael Wain 2025-02-09 02:29:28 +03:00
parent 48f04a25b0
commit b80b866781
4 changed files with 14 additions and 11 deletions

BIN
outdb

Binary file not shown.

View File

@ -92,12 +92,10 @@ pub fn parse_bytes(data: &[u8]) -> XDatabase {
let mut h = i+header_offset;
while h < i+str_end {
if data[h] != 0 {
bytes.push(data[h]);
bytes.push(u16::from_le_bytes(data[h..h+2].try_into().unwrap()));
h+=2;
}
h+=1;
}
let g = String::from_utf8(bytes).unwrap();
let g = String::from_utf16(&bytes).unwrap();
info!("str: {}", g);
match &mut xdb.find_dataset(last_type).child {
XSomeList::AlbumList(albums) => {

View File

@ -22,7 +22,7 @@ fn main() {
.init();
// /Users/michael/Documents/ipod/iTunes/iTunesDB
let mut f = File::open("/Users/michael/Documents/ipod/iTunes/iTunesDB").unwrap(); // D:\\Documents\\iTunes\\iTunesDB
let mut f = File::open("D:\\Documents\\iTunes\\iTunesDB").unwrap(); // D:\\Documents\\iTunes\\iTunesDB
let mut buf = Vec::new();
match f.read_to_end(&mut buf) {
Ok(n) => {
@ -30,7 +30,12 @@ fn main() {
let mut xdb = deserializer::parse_bytes(data);
//info!("XDB: {:#?}", xdb);
let unique_id = rand::thread_rng().gen_range(10..99);
let json = serde_json::to_string_pretty(&xdb).unwrap();
let mut f1 = File::create("output.json").unwrap();
f1.write(json.as_bytes());
/* let unique_id = rand::thread_rng().gen_range(10..99);
if let XSomeList::TrackList(tracks) = &mut xdb.find_dataset(1).child {
/*let mut item = (*tracks.last().unwrap()).clone();
@ -46,7 +51,7 @@ fn main() {
tracks.push(item);*/
let mut item = tracks.last_mut().unwrap();
item.args.first_mut().unwrap().val = String::from("Goy next door");
}
} */
/*if let XSomeList::Playlists(playlists) = &mut xdb.find_dataset(3).child {
let playlist = playlists.last_mut().unwrap();

View File

@ -3,8 +3,8 @@ use log::info;
use crate::{objects::{ChunkHeader, ChunkType, PlaylistItem, StringEntry}, xobjects::{XArgument, XDatabase, XLetterJump, XPlArgument, XPlaylistIndexEntry, XSomeList}};
fn string_to_ipod16(str: &String) -> Vec<u8> {
str.as_bytes().iter().map(|b| [*b, 0x0]).flatten().collect()
fn string_to_ipod16(str: &str) -> Vec<u8> {
str.encode_utf16().map(|f| [f as u8, (f >> 8) as u8]).flatten().collect()
}
fn x_args_to_bytes(args: &Vec<XArgument>) -> Vec<u8> {