0.1.18 upd
This commit is contained in:
parent
1d40207b7b
commit
bdc06ca565
2
Cargo.lock
generated
2
Cargo.lock
generated
@ -90,7 +90,7 @@ checksum = "d75a2a4b1b190afb6f5425f10f6a8f959d2ea0b9c2b1d79553551850539e4674"
|
||||
|
||||
[[package]]
|
||||
name = "itunesdb"
|
||||
version = "0.1.16"
|
||||
version = "0.1.18"
|
||||
dependencies = [
|
||||
"bincode",
|
||||
"env_logger",
|
||||
|
@ -1,6 +1,6 @@
|
||||
[package]
|
||||
name = "itunesdb"
|
||||
version = "0.1.17"
|
||||
version = "0.1.18"
|
||||
edition = "2021"
|
||||
authors = ["alterwain"]
|
||||
|
||||
|
@ -307,23 +307,78 @@ pub struct JumpTable {
|
||||
|
||||
#[derive(Serialize, Deserialize, PartialEq, Debug, Clone)]
|
||||
pub struct Playlist {
|
||||
data_object_child_count: u32,
|
||||
pub data_object_child_count: u32,
|
||||
pub playlist_item_count: u32,
|
||||
pub is_master_playlist_flag: u8,
|
||||
unk: [u8; 3],
|
||||
pub timestamp: u32,
|
||||
pub persistent_playlist_id: u64,
|
||||
unk3: u32,
|
||||
string_mhod_count: u16,
|
||||
pub string_mhod_count: u16,
|
||||
podcast_flag: u16,
|
||||
list_sort_order: u32,
|
||||
unk1: [u8; 22],
|
||||
unk2: [u8; 22],
|
||||
}
|
||||
|
||||
impl Playlist {
|
||||
pub fn new(persistent_playlist_id: u64, sort_order: ListSortOrder) -> Self {
|
||||
Self {
|
||||
data_object_child_count: 0,
|
||||
playlist_item_count: 0,
|
||||
is_master_playlist_flag: 0,
|
||||
unk: [0; 3],
|
||||
timestamp: 0,
|
||||
persistent_playlist_id,
|
||||
unk3: 0,
|
||||
string_mhod_count: 0,
|
||||
podcast_flag: 0,
|
||||
list_sort_order: sort_order.into(),
|
||||
unk1: [0; 22],
|
||||
unk2: [0; 22],
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub enum ListSortOrder {
|
||||
Manual,
|
||||
SongTitle,
|
||||
Album,
|
||||
Artist,
|
||||
Bitrate,
|
||||
Genre,
|
||||
Size,
|
||||
Year,
|
||||
SampleRate,
|
||||
PlayCount,
|
||||
LastPlayed,
|
||||
MyRating,
|
||||
BPM
|
||||
}
|
||||
|
||||
impl From<ListSortOrder> for u32 {
|
||||
fn from(value: ListSortOrder) -> Self {
|
||||
match value {
|
||||
ListSortOrder::Manual => 1,
|
||||
ListSortOrder::SongTitle => 3,
|
||||
ListSortOrder::Album => 4,
|
||||
ListSortOrder::Artist => 5,
|
||||
ListSortOrder::Bitrate => 6,
|
||||
ListSortOrder::Genre => 7,
|
||||
ListSortOrder::Size => 11,
|
||||
ListSortOrder::Year => 13,
|
||||
ListSortOrder::SampleRate => 14,
|
||||
ListSortOrder::PlayCount => 20,
|
||||
ListSortOrder::LastPlayed => 21,
|
||||
ListSortOrder::MyRating => 23,
|
||||
ListSortOrder::BPM => 25
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, PartialEq, Debug, Clone)]
|
||||
pub struct PlaylistItem {
|
||||
data_object_child_count: u32,
|
||||
pub data_object_child_count: u32,
|
||||
podcast_grouping_flag: u16,
|
||||
unk4: u16,
|
||||
pub group_id: u32,
|
||||
@ -333,3 +388,19 @@ pub struct PlaylistItem {
|
||||
unk: [u8; 30],
|
||||
unk1: [u8; 10],
|
||||
}
|
||||
|
||||
impl PlaylistItem {
|
||||
pub fn new(track_id: u32, group_id: u32) -> Self {
|
||||
Self {
|
||||
data_object_child_count: 0,
|
||||
podcast_grouping_flag: 0,
|
||||
unk4: 0,
|
||||
group_id,
|
||||
track_id,
|
||||
timestamp: 0,
|
||||
podcast_grouping_reference: 0,
|
||||
unk: [0; 30],
|
||||
unk1: [0; 10],
|
||||
}
|
||||
}
|
||||
}
|
@ -1,6 +1,6 @@
|
||||
use rand::Rng;
|
||||
|
||||
use crate::objects::{AlbumItem, ChunkHeader, DataSet, Database, JumpTable, LetterJumpEntry, Playlist, PlaylistIndexEntry, PlaylistItem, TrackItem};
|
||||
use crate::objects::{AlbumItem, ChunkHeader, DataSet, Database, JumpTable, LetterJumpEntry, ListSortOrder, Playlist, PlaylistIndexEntry, PlaylistItem, TrackItem};
|
||||
|
||||
|
||||
#[derive(Debug, serde::Serialize)]
|
||||
@ -102,6 +102,23 @@ impl XPlaylist {
|
||||
true
|
||||
});
|
||||
self.args.push(XPlArgument::String(XArgument { arg_type: id, val }));
|
||||
self.data.string_mhod_count = self.args.len() as u16;
|
||||
self.data.data_object_child_count = self.args.len() as u32;
|
||||
}
|
||||
|
||||
pub fn new(persistent_playlist_id: u64, sort_order: ListSortOrder) -> Self {
|
||||
Self {
|
||||
header: ChunkHeader::empty(),
|
||||
data: Playlist::new(persistent_playlist_id, sort_order),
|
||||
args: vec![],
|
||||
elems: vec![],
|
||||
}
|
||||
}
|
||||
|
||||
pub fn add_elem(&mut self, track_id: u32) {
|
||||
let group_id: u32 = rand::random();
|
||||
self.elems.push((PlaylistItem::new(track_id, group_id), Vec::new()));
|
||||
self.data.playlist_item_count += 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user