Files
tytdcompanion/Models/TYTDEvent.cs
T
2026-03-15 22:15:34 -05:00

45 lines
1.1 KiB
C#

using System.Diagnostics.CodeAnalysis;
using Newtonsoft.Json;
public enum LogEntryType {
VideoStarted,
VideoFinished,
Bell,
Started,
Unknown
}
public class LogEntry {
public long Time {get;set;}
[JsonIgnore]
public DateTimeOffset DateTime => DateTimeOffset.FromUnixTimeSeconds(Time);
public string Type {get;set;}="";
[JsonIgnore]
public LogEntryType EventType {
get {
if(Enum.TryParse<LogEntryType>(Type,out var type))
{
return type;
}
return LogEntryType.Unknown;
}
set => Type = value.ToString();
}
public string? VideoTitle {get;set;}
public string? VideoId {get;set;}
public string? ChannelTitle {get;set;}
public string? ChannelId {get;set;}
[JsonIgnore]
[MemberNotNullWhen(true,nameof(VideoTitle),nameof(VideoId),nameof(ChannelTitle),nameof(ChannelId))]
public bool HasStrings => !string.IsNullOrEmpty(VideoTitle) && !string.IsNullOrEmpty(VideoId) && !string.IsNullOrEmpty(ChannelTitle) && !string.IsNullOrEmpty(ChannelId);
}