fix: Reolink metadata should not reject media with labels (#1900)

- Related to: #1870
This commit is contained in:
Dermot Duffy
2025-02-17 20:13:21 -08:00
committed by GitHub
parent c66c3ec919
commit bb147a45fd
6 changed files with 128 additions and 33 deletions
+1 -1
View File
@@ -57,7 +57,7 @@ class BrowseMediaEventViewMedia extends ViewMedia implements EventViewMedia {
return this._browseMedia.thumbnail;
}
public getWhat(): string[] | null {
return null;
return this._browseMedia._metadata?.what ?? null;
}
public getScore(): number | null {
return null;
+1
View File
@@ -2,4 +2,5 @@ export interface BrowseMediaMetadata {
cameraID: string;
startDate: Date;
endDate: Date;
what?: string[];
}
+18 -7
View File
@@ -68,20 +68,22 @@ export class ReolinkCameraManagerEngine extends BrowseMediaCameraManagerEngine {
return null;
}
// Title of the form "21:47:03 0:00:44"
// Titles may be of the form:
// - "21:47:03 0:00:44"
// - "21:47:03 0:00:44 Person" (https://github.com/dermotduffy/advanced-camera-card/issues/1870)
// - "21:47:03 0:00:44 Vehicle Person" (https://github.com/dermotduffy/advanced-camera-card/issues/1870)
const parts = media.title.split(/ +/);
if (parts.length !== 2) {
return null;
}
const startDate = parse(parts[0], 'HH:mm:ss', parent._metadata.startDate);
if (!isValidDate(startDate)) {
return null;
}
const durationMatch = parts[1].match(
/(?<hours>\d+):(?<minutes>\d+):(?<seconds>\d+)/,
);
const durationMatch =
parts.length > 1
? parts[1].match(/(?<hours>\d+):(?<minutes>\d+):(?<seconds>\d+)/)
: null;
const duration = durationMatch?.groups
? {
hours: Number(durationMatch.groups.hours),
@@ -90,10 +92,19 @@ export class ReolinkCameraManagerEngine extends BrowseMediaCameraManagerEngine {
}
: null;
const what =
parts.length > 2
? parts
.splice(2)
.map((l) => l.toLowerCase())
.sort()
: null;
return {
cameraID: cameraID,
startDate: startDate,
endDate: duration ? add(startDate, duration) : startDate,
...(what && { what: what }),
};
}