modified: src/deserializer.rs
modified: src/main.rs modified: src/serializer.rs
This commit is contained in:
parent
48f04a25b0
commit
b80b866781
@ -92,12 +92,10 @@ pub fn parse_bytes(data: &[u8]) -> XDatabase {
|
|||||||
|
|
||||||
let mut h = i+header_offset;
|
let mut h = i+header_offset;
|
||||||
while h < i+str_end {
|
while h < i+str_end {
|
||||||
if data[h] != 0 {
|
bytes.push(u16::from_le_bytes(data[h..h+2].try_into().unwrap()));
|
||||||
bytes.push(data[h]);
|
h+=2;
|
||||||
}
|
}
|
||||||
h+=1;
|
let g = String::from_utf16(&bytes).unwrap();
|
||||||
}
|
|
||||||
let g = String::from_utf8(bytes).unwrap();
|
|
||||||
info!("str: {}", g);
|
info!("str: {}", g);
|
||||||
match &mut xdb.find_dataset(last_type).child {
|
match &mut xdb.find_dataset(last_type).child {
|
||||||
XSomeList::AlbumList(albums) => {
|
XSomeList::AlbumList(albums) => {
|
||||||
|
11
src/main.rs
11
src/main.rs
@ -22,7 +22,7 @@ fn main() {
|
|||||||
.init();
|
.init();
|
||||||
|
|
||||||
// /Users/michael/Documents/ipod/iTunes/iTunesDB
|
// /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();
|
let mut buf = Vec::new();
|
||||||
match f.read_to_end(&mut buf) {
|
match f.read_to_end(&mut buf) {
|
||||||
Ok(n) => {
|
Ok(n) => {
|
||||||
@ -30,7 +30,12 @@ fn main() {
|
|||||||
let mut xdb = deserializer::parse_bytes(data);
|
let mut xdb = deserializer::parse_bytes(data);
|
||||||
//info!("XDB: {:#?}", xdb);
|
//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 {
|
if let XSomeList::TrackList(tracks) = &mut xdb.find_dataset(1).child {
|
||||||
/*let mut item = (*tracks.last().unwrap()).clone();
|
/*let mut item = (*tracks.last().unwrap()).clone();
|
||||||
@ -46,7 +51,7 @@ fn main() {
|
|||||||
tracks.push(item);*/
|
tracks.push(item);*/
|
||||||
let mut item = tracks.last_mut().unwrap();
|
let mut item = tracks.last_mut().unwrap();
|
||||||
item.args.first_mut().unwrap().val = String::from("Goy next door");
|
item.args.first_mut().unwrap().val = String::from("Goy next door");
|
||||||
}
|
} */
|
||||||
|
|
||||||
/*if let XSomeList::Playlists(playlists) = &mut xdb.find_dataset(3).child {
|
/*if let XSomeList::Playlists(playlists) = &mut xdb.find_dataset(3).child {
|
||||||
let playlist = playlists.last_mut().unwrap();
|
let playlist = playlists.last_mut().unwrap();
|
||||||
|
@ -3,8 +3,8 @@ use log::info;
|
|||||||
use crate::{objects::{ChunkHeader, ChunkType, PlaylistItem, StringEntry}, xobjects::{XArgument, XDatabase, XLetterJump, XPlArgument, XPlaylistIndexEntry, XSomeList}};
|
use crate::{objects::{ChunkHeader, ChunkType, PlaylistItem, StringEntry}, xobjects::{XArgument, XDatabase, XLetterJump, XPlArgument, XPlaylistIndexEntry, XSomeList}};
|
||||||
|
|
||||||
|
|
||||||
fn string_to_ipod16(str: &String) -> Vec<u8> {
|
fn string_to_ipod16(str: &str) -> Vec<u8> {
|
||||||
str.as_bytes().iter().map(|b| [*b, 0x0]).flatten().collect()
|
str.encode_utf16().map(|f| [f as u8, (f >> 8) as u8]).flatten().collect()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn x_args_to_bytes(args: &Vec<XArgument>) -> Vec<u8> {
|
fn x_args_to_bytes(args: &Vec<XArgument>) -> Vec<u8> {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user