From 6db3472ca6a97ba571a63be3eb89af16aed39d94 Mon Sep 17 00:00:00 2001 From: Graham Alderson Date: Thu, 23 Nov 2023 11:02:46 +1200 Subject: [PATCH 1/2] Added ratings to xmp sidecar support Added ratings to xmp sidecar support, also added rating to bunny.mp4.xmp and a different rating in IMG_5910.jpg.xmp vs what is in the photo file to test if sidecar is functioning as primary. --- demo/images/IMG_5910.jpg.xmp | 2 +- demo/images/bunny.mp4.xmp | 1 + src/backend/model/fileaccess/MetadataLoader.ts | 2 ++ src/common/entities/ConentWrapper.ts | 1 - src/common/entities/PhotoDTO.ts | 4 +++- src/common/entities/VideoDTO.ts | 2 ++ 6 files changed, 9 insertions(+), 3 deletions(-) diff --git a/demo/images/IMG_5910.jpg.xmp b/demo/images/IMG_5910.jpg.xmp index 8ca2fac0..0043a4b1 100644 --- a/demo/images/IMG_5910.jpg.xmp +++ b/demo/images/IMG_5910.jpg.xmp @@ -356,7 +356,7 @@ Adobe Photoshop Lightroom 6.1 (Windows) 2023-09-02T16:18:48+02:00 2015-07-24T22:45:50 - 3 + 4 2018-11-17T20:27:31+01:00 2018-11-17T20:27:31+01:00 2018-11-17T20:27:31+01:00 + 4 { metadata.keywords = [(response as any).dc.subject].flat(); + metadata.rating = (response as any).xmp.Rating; }); } } @@ -199,6 +200,7 @@ export class MetadataLoader { const sidecarData = exifr.sidecar(sidecarPath); sidecarData.then((response) => { metadata.keywords = [(response as any).dc.subject].flat(); + metadata.rating = (response as any).xmp.Rating; }); } } diff --git a/src/common/entities/ConentWrapper.ts b/src/common/entities/ConentWrapper.ts index 5bd6e3e2..f0321575 100644 --- a/src/common/entities/ConentWrapper.ts +++ b/src/common/entities/ConentWrapper.ts @@ -238,7 +238,6 @@ export class ContentWrapper { } ContentWrapper.mapify(cw, m, isSearchResult); } else if (MediaDTOUtils.isVideo(m)) { - delete (m as PhotoDTO).metadata.rating; delete (m as PhotoDTO).metadata.caption; delete (m as PhotoDTO).metadata.cameraData; delete (m as PhotoDTO).metadata.faces; diff --git a/src/common/entities/PhotoDTO.ts b/src/common/entities/PhotoDTO.ts index f95a10e8..0fb626b2 100644 --- a/src/common/entities/PhotoDTO.ts +++ b/src/common/entities/PhotoDTO.ts @@ -26,8 +26,10 @@ export interface FaceRegion { box?: FaceRegionBox; // some faces don t have region ass they are coming from keywords } +export type RatingTypes = 0 | 1 | 2 | 3 | 4 | 5; + export interface PhotoMetadata extends MediaMetadata { - rating?: 0 | 1 | 2 | 3 | 4 | 5; + rating?: RatingTypes; caption?: string; keywords?: string[]; cameraData?: CameraMetadata; diff --git a/src/common/entities/VideoDTO.ts b/src/common/entities/VideoDTO.ts index e726c625..97abddd1 100644 --- a/src/common/entities/VideoDTO.ts +++ b/src/common/entities/VideoDTO.ts @@ -1,5 +1,6 @@ import {DirectoryPathDTO} from './DirectoryDTO'; import {MediaDimension, MediaDTO, MediaMetadata} from './MediaDTO'; +import {PositionMetaData, CameraMetadata, RatingTypes} from './PhotoDTO'; export interface VideoDTO extends MediaDTO { id: number; @@ -16,4 +17,5 @@ export interface VideoMetadata extends MediaMetadata { fileSize: number; fps: number; keywords?: string[]; + rating?: RatingTypes; } From 702b55c912ce7d0b6facb711549caeb9c87a6fc9 Mon Sep 17 00:00:00 2001 From: Graham Alderson Date: Sun, 26 Nov 2023 10:53:08 +1200 Subject: [PATCH 2/2] Move some metadata to mediametadata interface Some metadata is now relevant to all supported media types due to xmp sidecar support. --- src/common/entities/MediaDTO.ts | 4 ++++ src/common/entities/PhotoDTO.ts | 4 ---- src/common/entities/VideoDTO.ts | 3 --- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/src/common/entities/MediaDTO.ts b/src/common/entities/MediaDTO.ts index 0a1a3e79..b56136ca 100644 --- a/src/common/entities/MediaDTO.ts +++ b/src/common/entities/MediaDTO.ts @@ -11,10 +11,14 @@ export interface MediaDTO extends FileDTO { missingThumbnails?: number; } +export type RatingTypes = 0 | 1 | 2 | 3 | 4 | 5; + export interface MediaMetadata { size: MediaDimension; creationDate: number; fileSize: number; + keywords?: string[]; + rating?: RatingTypes; } export interface MediaDimension { diff --git a/src/common/entities/PhotoDTO.ts b/src/common/entities/PhotoDTO.ts index 0fb626b2..1bd6b090 100644 --- a/src/common/entities/PhotoDTO.ts +++ b/src/common/entities/PhotoDTO.ts @@ -26,12 +26,8 @@ export interface FaceRegion { box?: FaceRegionBox; // some faces don t have region ass they are coming from keywords } -export type RatingTypes = 0 | 1 | 2 | 3 | 4 | 5; - export interface PhotoMetadata extends MediaMetadata { - rating?: RatingTypes; caption?: string; - keywords?: string[]; cameraData?: CameraMetadata; positionData?: PositionMetaData; size: MediaDimension; diff --git a/src/common/entities/VideoDTO.ts b/src/common/entities/VideoDTO.ts index 97abddd1..d9cefefc 100644 --- a/src/common/entities/VideoDTO.ts +++ b/src/common/entities/VideoDTO.ts @@ -1,6 +1,5 @@ import {DirectoryPathDTO} from './DirectoryDTO'; import {MediaDimension, MediaDTO, MediaMetadata} from './MediaDTO'; -import {PositionMetaData, CameraMetadata, RatingTypes} from './PhotoDTO'; export interface VideoDTO extends MediaDTO { id: number; @@ -16,6 +15,4 @@ export interface VideoMetadata extends MediaMetadata { duration: number; // in milliseconds fileSize: number; fps: number; - keywords?: string[]; - rating?: RatingTypes; }