0.1.94 upd

This commit is contained in:
Michael Wain 2025-02-23 19:16:16 +03:00
parent f0cbffe692
commit efb59315e9
3 changed files with 23 additions and 4 deletions

2
Cargo.lock generated
View File

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

View File

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

View File

@ -220,6 +220,17 @@ pub mod serializer {
pub mod aobjects {
use log::info;
use crate::artworkdb::objects::{ChunkHeader, DataSet, Database, ImageFile, ImageItem, ImageName, LocationTag};
fn get_hi_from_cover_hash(v: u64) -> u32 {
let hi32 = (v >> 32) as u32;
hi32
}
fn get_lo_from_cover_hash(v: u64) -> u32 {
let lo32 = v as u32;
lo32
}
#[derive(Debug, serde::Serialize)]
pub struct ADatabase {
@ -232,6 +243,14 @@ pub mod aobjects {
pub(crate) fn find_dataset(&mut self, p0: u32) -> &mut ADataSet {
self.children.iter_mut().find(|d| d.data.data_type == p0).unwrap()
}
pub fn if_cover_present(&mut self, cover_hash: u64) -> bool {
let ds = self.find_dataset(1);
let image_items = &ds.child;
let hi = get_hi_from_cover_hash(cover_hash);
let lo = get_lo_from_cover_hash(cover_hash);
image_items.iter().any(|i| i.data.as_ref().unwrap().original_date == hi && i.data.as_ref().unwrap().digitized_date == lo)
}
pub fn add_images(&mut self, song_dbid: u64, cover_hash: u64) -> (String, String) {
let ds = self.find_dataset(1);
@ -244,8 +263,8 @@ pub mod aobjects {
unknown4: 0,
rating: 0,
unknown6: 0,
original_date: 0,
digitized_date: 0,
original_date: get_hi_from_cover_hash(cover_hash),
digitized_date: get_lo_from_cover_hash(cover_hash),
source_image_size: 0
};