0.1.13 upd

This commit is contained in:
Michael Wain 2025-02-14 23:34:35 +03:00
parent cd2fa25ae7
commit e3aaf2b319
4 changed files with 105 additions and 2 deletions

2
Cargo.lock generated
View File

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

View File

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

View File

@ -57,6 +57,16 @@ pub struct ChunkHeader {
pub children_count: u32, pub children_count: u32,
} }
impl ChunkHeader {
pub(crate) fn empty() -> Self {
Self {
chunk_type: [0,0,0,0],
end_of_chunk: 0,
children_count: 0
}
}
}
#[derive(Serialize, Deserialize, PartialEq, Debug)] #[derive(Serialize, Deserialize, PartialEq, Debug)]
pub struct Database { pub struct Database {
unknown: u32, unknown: u32,
@ -167,6 +177,90 @@ pub struct TrackItem {
unk6: [u8; 32], unk6: [u8; 32],
} }
impl TrackItem {
pub(crate) fn new(unique_id: u32, size: u32, length: u32, year: u32, bitrate: u32, sample_rate: u32, dbid: u64, sample_count: u64) -> Self {
Self {
number_of_strings: 0,
unique_id,
visible: 1,
filetype: 1297101600,
type1: 0,
type2: 1,
compilation_flag: 0,
stars: 0,
last_modified_time: 3786278955,
size,
length,
track_number: 0,
total_tracks: 0,
year,
bitrate,
sample_rate,
volume: 0,
start_time: 0,
stop_time: 0,
soundcheck: 0,
play_count: 0,
play_count2: 0,
last_played_time: 0,
disc_number: 0,
total_discs: 0,
userid: 0,
date_added: 3815861983,
bookmark_time: 0,
dbid,
checked: 0,
application_rating: 0,
bpm: 0,
artwork_count: 0,
unk9: 65535,
artwork_size: 0,
unk11: 0,
sample_rate2: sample_rate,
date_released: 0,
unk14: 12,
unk15: 0,
unk16: 0,
skip_count: 0,
last_skipped: 0,
has_artwork: 2,
skip_when_shuffling: 0,
remember_playback_position: 0,
flag4: 0,
dbid2: dbid,
lyrics_flag: 0,
movie_file_flag: 0,
played_mark: 0,
unk17: 0,
unk21: 0,
pregap: 528,
sample_count,
unk25: 0,
postgap: 566,
unk27: 33554435,
media_type: 1,
season_number: 0,
episode_number: 0,
unk31: [0; 28],
gapless_data: 8154240,
unk38: 0,
gapless_track_flag: 1,
gapless_album_flag: 0,
unk39_hash: [0; 20],
unk40: [0; 18],
album_id: 36682,
mhii_link: 8161920,
unk: [0; 32],
unk1: [0; 32],
unk2: [0; 32],
unk3: [0; 32],
unk4: [0; 32],
unk5: [0; 32],
unk6: [0; 32],
}
}
}
#[derive(Serialize, Deserialize, PartialEq, Debug)] #[derive(Serialize, Deserialize, PartialEq, Debug)]
pub struct StringEntry { pub struct StringEntry {
// mhod // mhod

View File

@ -106,6 +106,15 @@ impl XPlaylist {
} }
impl XTrackItem { impl XTrackItem {
pub fn new(unique_id: u32, size: u32, length: u32, year: u32, bitrate: u32, sample_rate: u32, dbid: u64, sample_count: u64) -> Self {
Self {
header: ChunkHeader::empty(),
data: TrackItem::new(unique_id, size, length, year, bitrate, sample_rate, dbid, sample_count),
args: vec![],
}
}
pub fn set_location(&mut self, location: String) { pub fn set_location(&mut self, location: String) {
self.update_arg(2, location); self.update_arg(2, location);
} }