Native iCloud apps for Windows and Linux, built in Rust. Notes, Reminders, Calendar, Contacts, Drive and Photos, offline and in sync with your iPhone.
Rust apple-notesapple-reminderscloudkitcrdtdesktop-appicloudicloud-calendaricloud-driveicloud-notesicloud-photosiphonelinuxlinux-desktoplocal-firstoffline-firstprivacyrusttauritauri-appwindows
Photos: a video's length in seconds, not Apple's milliseconds
Yashwanth Kamireddi2e5822907fa4
diff --git a/crates/quince-core/src/schema.rs b/crates/quince-core/src/schema.rsindex fc568e2..4d0483c 100644--- a/crates/quince-core/src/schema.rs+++ b/crates/quince-core/src/schema.rs@@ -502,4 +502,9 @@ pub const MIGRATIONS: &[&str] = &[) STRICT;CREATE INDEX outbox_by_service ON outbox (service, id);"#,+ // A video's length was kept as Apple sends it, in milliseconds, and shown as seconds: a+ // one-minute clip read 1036:24. Every one stored so far is in milliseconds.+ r#"+ UPDATE photos SET duration = duration / 1000.0 WHERE duration IS NOT NULL;+ "#,];diff --git a/crates/quince-icloud/src/photos.rs b/crates/quince-icloud/src/photos.rsindex e5cd022..1123c02 100644--- a/crates/quince-icloud/src/photos.rs+++ b/crates/quince-icloud/src/photos.rs@@ -183,10 +183,13 @@ pub fn photo_of(asset: &Value, master: &Value) -> Option<Photo> {kind,width,height,+ // Apple keeps a video's length in milliseconds (12917 for a 12.917 s clip, checked+ // against the files themselves); the library keeps seconds.duration: asset.pointer("/fields/duration/value").and_then(Value::as_f64)- .filter(|d| *d > 0.0),+ .filter(|d| *d > 0.0)+ .map(|ms| ms / 1000.0),filename: decoded(master, "filenameEnc"),size: size("resOriginalFileSize"),uti,@@ -952,6 +955,17 @@ mod tests {);}+ /// A video's length: Apple's milliseconds, kept as seconds (a 62.18 s clip, not 1036 minutes).+ #[test]+ fn a_video_length_is_seconds() {+ let p = photo_of(&asset(json!({"duration": 62184.0})), &master()).unwrap();+ assert_eq!(p.duration, Some(62.184));+ assert_eq!(+ photo_of(&asset(json!({})), &master()).unwrap().duration,+ None+ );+ }+/// A full pass replaces the library; a later asset-only change (deleted) is laid over the/// photo already known; an expunged asset goes.#[test]