modified: Cargo.lock
modified: Cargo.toml modified: outdb modified: src/main.rs modified: src/objects.rs modified: src/xobjects.rs new file: two_tracks
This commit is contained in:
parent
c2b6f178c9
commit
48f04a25b0
92
Cargo.lock
generated
92
Cargo.lock
generated
@ -1,6 +1,6 @@
|
|||||||
# This file is automatically @generated by Cargo.
|
# This file is automatically @generated by Cargo.
|
||||||
# It is not intended for manual editing.
|
# It is not intended for manual editing.
|
||||||
version = 3
|
version = 4
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "aho-corasick"
|
name = "aho-corasick"
|
||||||
@ -31,6 +31,18 @@ dependencies = [
|
|||||||
"serde",
|
"serde",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "byteorder"
|
||||||
|
version = "1.5.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "cfg-if"
|
||||||
|
version = "1.0.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "env_logger"
|
name = "env_logger"
|
||||||
version = "0.9.3"
|
version = "0.9.3"
|
||||||
@ -44,6 +56,17 @@ dependencies = [
|
|||||||
"termcolor",
|
"termcolor",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "getrandom"
|
||||||
|
version = "0.2.15"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7"
|
||||||
|
dependencies = [
|
||||||
|
"cfg-if",
|
||||||
|
"libc",
|
||||||
|
"wasi",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "hermit-abi"
|
name = "hermit-abi"
|
||||||
version = "0.1.19"
|
version = "0.1.19"
|
||||||
@ -72,6 +95,7 @@ dependencies = [
|
|||||||
"bincode",
|
"bincode",
|
||||||
"env_logger",
|
"env_logger",
|
||||||
"log",
|
"log",
|
||||||
|
"rand",
|
||||||
"serde",
|
"serde",
|
||||||
"serde_json",
|
"serde_json",
|
||||||
]
|
]
|
||||||
@ -94,6 +118,15 @@ version = "2.7.4"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3"
|
checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "ppv-lite86"
|
||||||
|
version = "0.2.20"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "77957b295656769bb8ad2b6a6b09d897d94f05c41b069aede1fcdaa675eaea04"
|
||||||
|
dependencies = [
|
||||||
|
"zerocopy",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "proc-macro2"
|
name = "proc-macro2"
|
||||||
version = "1.0.93"
|
version = "1.0.93"
|
||||||
@ -112,6 +145,36 @@ dependencies = [
|
|||||||
"proc-macro2",
|
"proc-macro2",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "rand"
|
||||||
|
version = "0.8.5"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "34af8d1a0e25924bc5b7c43c079c942339d8f0a8b57c39049bef581b46327404"
|
||||||
|
dependencies = [
|
||||||
|
"libc",
|
||||||
|
"rand_chacha",
|
||||||
|
"rand_core",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "rand_chacha"
|
||||||
|
version = "0.3.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "e6c10a63a0fa32252be49d21e7709d4d4baf8d231c2dbce1eaa8141b9b127d88"
|
||||||
|
dependencies = [
|
||||||
|
"ppv-lite86",
|
||||||
|
"rand_core",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "rand_core"
|
||||||
|
version = "0.6.4"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "ec0be4795e2f6a28069bec0b5ff3e2ac9bafc99e6a9a7dc3547996c5c816922c"
|
||||||
|
dependencies = [
|
||||||
|
"getrandom",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "regex"
|
name = "regex"
|
||||||
version = "1.11.1"
|
version = "1.11.1"
|
||||||
@ -205,6 +268,12 @@ version = "1.0.16"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "a210d160f08b701c8721ba1c726c11662f877ea6b7094007e1ca9a1041945034"
|
checksum = "a210d160f08b701c8721ba1c726c11662f877ea6b7094007e1ca9a1041945034"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "wasi"
|
||||||
|
version = "0.11.0+wasi-snapshot-preview1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "winapi"
|
name = "winapi"
|
||||||
version = "0.3.9"
|
version = "0.3.9"
|
||||||
@ -308,3 +377,24 @@ name = "windows_x86_64_msvc"
|
|||||||
version = "0.52.6"
|
version = "0.52.6"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec"
|
checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "zerocopy"
|
||||||
|
version = "0.7.35"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0"
|
||||||
|
dependencies = [
|
||||||
|
"byteorder",
|
||||||
|
"zerocopy-derive",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "zerocopy-derive"
|
||||||
|
version = "0.7.35"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"syn",
|
||||||
|
]
|
||||||
|
@ -10,3 +10,4 @@ log = "0.4.20"
|
|||||||
bincode = "1.3.3"
|
bincode = "1.3.3"
|
||||||
serde = { version = "1.0.217", features = ["derive"] }
|
serde = { version = "1.0.217", features = ["derive"] }
|
||||||
serde_json = "1.0.138"
|
serde_json = "1.0.138"
|
||||||
|
rand = "0.8"
|
31
src/main.rs
31
src/main.rs
@ -1,6 +1,7 @@
|
|||||||
use std::{fs::File, io::{Read, Write}};
|
use std::{fs::File, io::{Read, Write}};
|
||||||
use env_logger::Builder;
|
use env_logger::Builder;
|
||||||
use log::{error, info, LevelFilter};
|
use log::{error, info, LevelFilter};
|
||||||
|
use rand::Rng;
|
||||||
use xobjects::{XArgument, XSomeList};
|
use xobjects::{XArgument, XSomeList};
|
||||||
|
|
||||||
mod objects;
|
mod objects;
|
||||||
@ -21,26 +22,40 @@ fn main() {
|
|||||||
.init();
|
.init();
|
||||||
|
|
||||||
// /Users/michael/Documents/ipod/iTunes/iTunesDB
|
// /Users/michael/Documents/ipod/iTunes/iTunesDB
|
||||||
let mut f = File::open("D:\\Documents\\iTunes\\iTunesDB").unwrap(); // D:\\Documents\\iTunes\\iTunesDB
|
let mut f = File::open("/Users/michael/Documents/ipod/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) => {
|
||||||
let data = &buf[..n];
|
let data = &buf[..n];
|
||||||
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);
|
||||||
|
|
||||||
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();
|
||||||
let mut xargs = Vec::new();
|
let mut xargs = Vec::new();
|
||||||
xargs.push(XArgument { arg_type: 1, val: String::from("They beat you") });
|
xargs.push(XArgument { arg_type: 1, val: String::from("They beat you") });
|
||||||
xargs.push(XArgument { arg_type: 3, val: String::from("IC3PEAK EP") });
|
|
||||||
xargs.push(XArgument { arg_type: 4, val: String::from("IC3PEAK") });
|
|
||||||
xargs.push(XArgument { arg_type: 6, val: String::from("MPEG audio file")});
|
xargs.push(XArgument { arg_type: 6, val: String::from("MPEG audio file")});
|
||||||
xargs.push(XArgument { arg_type: 2, val: String::from(":iPod_Control:Music:F38:ZJUQ.mp3") });
|
xargs.push(XArgument { arg_type: 2, val: String::from(":iPod_Control:Music:F38:ZXXX.mp3") });
|
||||||
item.args = xargs;
|
item.args = xargs;
|
||||||
item.data.number_of_strings = 5;
|
item.data.number_of_strings = 3;
|
||||||
item.data.unique_id = 99;
|
item.data.unique_id = unique_id;
|
||||||
tracks.push(item);
|
item.data.dbid = rand::thread_rng().gen_range(0..10000);
|
||||||
|
item.data.dbid2 = rand::thread_rng().gen_range(0..10000);
|
||||||
|
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();
|
||||||
|
let elem = playlist.elems.last().unwrap();
|
||||||
|
let mut pl_item = elem.0.clone();
|
||||||
|
pl_item.track_id = unique_id;
|
||||||
|
playlist.elems.push((pl_item, elem.1.clone()));
|
||||||
|
}*/
|
||||||
|
|
||||||
let mut op = File::create("outdb").unwrap();
|
let mut op = File::create("outdb").unwrap();
|
||||||
info!("Write res: {:?}", op.write(&serializer::to_bytes(xdb)));
|
info!("Write res: {:?}", op.write(&serializer::to_bytes(xdb)));
|
||||||
},
|
},
|
||||||
|
@ -116,7 +116,7 @@ pub struct TrackItem {
|
|||||||
userid: u32,
|
userid: u32,
|
||||||
date_added: u32,
|
date_added: u32,
|
||||||
bookmark_time: u32,
|
bookmark_time: u32,
|
||||||
dbid: u64,
|
pub dbid: u64,
|
||||||
checked: u8,
|
checked: u8,
|
||||||
application_rating: u8,
|
application_rating: u8,
|
||||||
bpm: u16,
|
bpm: u16,
|
||||||
@ -135,7 +135,7 @@ pub struct TrackItem {
|
|||||||
skip_when_shuffling: u8,
|
skip_when_shuffling: u8,
|
||||||
remember_playback_position: u8,
|
remember_playback_position: u8,
|
||||||
flag4: u8,
|
flag4: u8,
|
||||||
dbid2: u64,
|
pub dbid2: u64,
|
||||||
lyrics_flag: u8,
|
lyrics_flag: u8,
|
||||||
movie_file_flag: u8,
|
movie_file_flag: u8,
|
||||||
played_mark: u8,
|
played_mark: u8,
|
||||||
@ -178,7 +178,7 @@ pub struct StringEntry { // mhod
|
|||||||
pub unk4: u32
|
pub unk4: u32
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, PartialEq, Debug)]
|
#[derive(Serialize, Deserialize, PartialEq, Debug, Clone)]
|
||||||
pub struct PlaylistIndexEntry { // mhod
|
pub struct PlaylistIndexEntry { // mhod
|
||||||
entry_type: u32,
|
entry_type: u32,
|
||||||
unk1: u32,
|
unk1: u32,
|
||||||
@ -192,7 +192,7 @@ pub struct PlaylistIndexEntry { // mhod
|
|||||||
null_padding4: u64
|
null_padding4: u64
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, PartialEq, Debug)]
|
#[derive(Serialize, Deserialize, PartialEq, Debug, Clone)]
|
||||||
pub struct LetterJumpEntry {
|
pub struct LetterJumpEntry {
|
||||||
entry_type: u32,
|
entry_type: u32,
|
||||||
unk1: u32,
|
unk1: u32,
|
||||||
@ -202,7 +202,7 @@ pub struct LetterJumpEntry {
|
|||||||
null_padding: u64
|
null_padding: u64
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, PartialEq, Debug)]
|
#[derive(Serialize, Deserialize, PartialEq, Debug, Clone)]
|
||||||
pub struct JumpTable {
|
pub struct JumpTable {
|
||||||
letter: u32, // UTF-16 LE Uppercase with two padding null bytes
|
letter: u32, // UTF-16 LE Uppercase with two padding null bytes
|
||||||
entry_num: u32, // the number of the first entry in the corresponding MHOD52 index starting with this letter. Zero-based and incremented by one for each entry, not 4.
|
entry_num: u32, // the number of the first entry in the corresponding MHOD52 index starting with this letter. Zero-based and incremented by one for each entry, not 4.
|
||||||
@ -225,13 +225,13 @@ pub struct Playlist {
|
|||||||
unk2: [u8; 22],
|
unk2: [u8; 22],
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, PartialEq, Debug)]
|
#[derive(Serialize, Deserialize, PartialEq, Debug, Clone)]
|
||||||
pub struct PlaylistItem {
|
pub struct PlaylistItem {
|
||||||
data_object_child_count: u32,
|
data_object_child_count: u32,
|
||||||
podcast_grouping_flag: u16,
|
podcast_grouping_flag: u16,
|
||||||
unk4: u16,
|
unk4: u16,
|
||||||
group_id: u32,
|
group_id: u32,
|
||||||
track_id: u32,
|
pub track_id: u32,
|
||||||
timestamp: u32,
|
timestamp: u32,
|
||||||
podcast_grouping_reference: u32,
|
podcast_grouping_reference: u32,
|
||||||
unk: [u8; 30],
|
unk: [u8; 30],
|
||||||
|
@ -37,7 +37,7 @@ pub struct XPlaylist {
|
|||||||
pub elems: Vec<(PlaylistItem, Vec<XPlArgument>)>
|
pub elems: Vec<(PlaylistItem, Vec<XPlArgument>)>
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, serde::Serialize)]
|
#[derive(Debug, serde::Serialize, Clone)]
|
||||||
pub enum XPlArgument {
|
pub enum XPlArgument {
|
||||||
String(XArgument),
|
String(XArgument),
|
||||||
IndexEntry(XPlaylistIndexEntry),
|
IndexEntry(XPlaylistIndexEntry),
|
||||||
@ -45,13 +45,13 @@ pub enum XPlArgument {
|
|||||||
RawArgument(Vec<u8>)
|
RawArgument(Vec<u8>)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, serde::Serialize)]
|
#[derive(Debug, serde::Serialize, Clone)]
|
||||||
pub struct XPlaylistIndexEntry {
|
pub struct XPlaylistIndexEntry {
|
||||||
pub data: PlaylistIndexEntry,
|
pub data: PlaylistIndexEntry,
|
||||||
pub v: Vec<u32>
|
pub v: Vec<u32>
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, serde::Serialize)]
|
#[derive(Debug, serde::Serialize, Clone)]
|
||||||
pub struct XLetterJump {
|
pub struct XLetterJump {
|
||||||
pub data: LetterJumpEntry,
|
pub data: LetterJumpEntry,
|
||||||
pub v: Vec<JumpTable>
|
pub v: Vec<JumpTable>
|
||||||
|
BIN
two_tracks
Executable file
BIN
two_tracks
Executable file
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user