added metadata loading to scanner

This commit is contained in:
2026-01-25 19:13:58 -05:00
parent 5042cc7ff5
commit 7c9ea505b0
5 changed files with 137 additions and 19 deletions

View File

@@ -10,15 +10,18 @@ namespace AZKiServer.Models;
public partial class MediaEntry
{
public const int CUR_VERSION = 1;
[BsonId]
public ObjectId Id { get; set; }
public int Version { get; set; }
public MediaType Type { get; set; }
public required string Filepath { get; set; }
public DateTime Date { get; set; }
public DateTime EndDate { get; set; }
public int CameraId { get; set; }
public required MediaMetadata Metadata { get; set; }
public static Maybe<MediaEntry> Parse(string relativePath)
public static Maybe<MediaEntry> Parse(string relativePath, MediaMetadata metadata)
{
var filename = Path.GetFileName(relativePath);
@@ -32,13 +35,15 @@ public partial class MediaEntry
var cam = match.Groups["cam"];
var date = match.Groups["date"];
var ext = match.Groups["ext"];
var startDate = ParseDate(date.Value);
return new MediaEntry
{
Version = 0,
Version = CUR_VERSION,
CameraId = int.Parse(cam.Value),
Filepath = relativePath,
Date = ParseDate(date.Value),
Date = startDate,
EndDate = startDate.AddSeconds(metadata.Duration),
Metadata = metadata,
Type = ext.Value switch
{
"mp4" => MediaType.Video,
@@ -68,6 +73,7 @@ public partial class MediaEntry
private static partial Regex FileParser();
}
public record MediaMetadata(int Duration, int Height, int Width);
[Flags]
public enum MediaType