Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions Backend/App/MessageService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,10 @@ public static async Task HandleMessage(string message)
root.TryGetProperty("Parameters", out JsonElement aiClipParameterElement);
_ = Task.Run(() => HandleCreateAiClip(aiClipParameterElement));
break;
case "CreateLowlight":
root.TryGetProperty("Parameters", out JsonElement lowlightParameterElement);
_ = Task.Run(() => HandleCreateLowlight(lowlightParameterElement));
break;
case "CompressVideo":
root.TryGetProperty("Parameters", out JsonElement compressParameterElement);
_ = Task.Run(() => HandleCompressVideo(compressParameterElement));
Expand Down Expand Up @@ -342,6 +346,13 @@ private static async Task HandleCreateAiClip(JsonElement message)
await AiService.CreateHighlight(fileNameElement.GetString()!);
}

private static async Task HandleCreateLowlight(JsonElement message)
{
Log.Information($"{message}");
message.TryGetProperty("FileName", out JsonElement fileNameElement);
await AiService.CreateLowlight(fileNameElement.GetString()!);
}

private static async Task HandleCompressVideo(JsonElement message)
{
Log.Information($"CompressVideo: {message}");
Expand Down
15 changes: 14 additions & 1 deletion Backend/Core/Models/Bookmark.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public enum BookmarkType
[IncludeInHighlight] Kill,
[IncludeInHighlight] Goal,
Assist,
Death
[IncludeInLowlight] Death
}

/// <summary>
Expand All @@ -31,6 +31,12 @@ public enum BookmarkType
[AttributeUsage(AttributeTargets.Field)]
public class IncludeInHighlightAttribute : Attribute { }

/// <summary>
/// Marks a BookmarkType as one that should be included in auto-generated lowlights.
/// </summary>
[AttributeUsage(AttributeTargets.Field)]
public class IncludeInLowlightAttribute : Attribute { }

public static class BookmarkTypeExtensions
{
/// <summary>
Expand All @@ -39,6 +45,13 @@ public static class BookmarkTypeExtensions
public static bool IncludeInHighlight(this BookmarkType type) =>
typeof(BookmarkType).GetField(type.ToString())!
.GetCustomAttributes(typeof(IncludeInHighlightAttribute), false).Length > 0;

/// <summary>
/// Returns true if this bookmark type should be included in auto-generated lowlights.
/// </summary>
public static bool IncludeInLowlight(this BookmarkType type) =>
typeof(BookmarkType).GetField(type.ToString())!
.GetCustomAttributes(typeof(IncludeInLowlightAttribute), false).Length > 0;
}

[JsonConverter(typeof(JsonStringEnumConverter))]
Expand Down
60 changes: 59 additions & 1 deletion Backend/Core/Models/Settings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ internal class Settings
"Replay Buffer",
"Clips",
"Highlights",
"Lowlights",
"Settings"
};

Expand Down Expand Up @@ -50,6 +51,10 @@ internal class Settings
private bool _autoGenerateHighlights = true;
private double _highlightPaddingBefore = 4;
private double _highlightPaddingAfter = 4;
private bool _enableLowlights = false;
private bool _autoGenerateLowlights = true;
private double _lowlightPaddingBefore = 4;
private double _lowlightPaddingAfter = 4;
private bool _runOnStartup = false;
private bool _receiveBetaUpdates = false;
private bool _airplaneMode = false;
Expand Down Expand Up @@ -378,6 +383,19 @@ public bool EnableAi
}
}

[JsonPropertyName("enableLowlights")]
public bool EnableLowlights
{
get => _enableLowlights;
set
{
if (_enableLowlights != value)
{
_enableLowlights = value;
}
}
}

[JsonPropertyName("autoGenerateHighlights")]
public bool AutoGenerateHighlights
{
Expand Down Expand Up @@ -417,6 +435,45 @@ public double HighlightPaddingAfter
}
}

[JsonPropertyName("autoGenerateLowlights")]
public bool AutoGenerateLowlights
{
get => _autoGenerateLowlights;
set
{
if (_autoGenerateLowlights != value)
{
_autoGenerateLowlights = value;
}
}
}

[JsonPropertyName("lowlightPaddingBefore")]
public double LowlightPaddingBefore
{
get => _lowlightPaddingBefore;
set
{
if (_lowlightPaddingBefore != value)
{
_lowlightPaddingBefore = value;
}
}
}

[JsonPropertyName("lowlightPaddingAfter")]
public double LowlightPaddingAfter
{
get => _lowlightPaddingAfter;
set
{
if (_lowlightPaddingAfter != value)
{
_lowlightPaddingAfter = value;
}
}
}

[JsonPropertyName("gameIntegrations")]
public GameIntegrations GameIntegrations
{
Expand Down Expand Up @@ -1060,7 +1117,8 @@ public enum ContentType
Session,
Buffer,
Clip,
Highlight
Highlight,
Lowlight
}

public ContentType Type { get; set; } = ContentType.Session;
Expand Down
2 changes: 1 addition & 1 deletion Backend/Media/ContentService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ public static async Task DeleteContent(string filePath, Content.ContentType type
{
// Only delete if the folder is empty and is a game subfolder (not the root video type folder)
string contentRoot = Settings.Instance.ContentFolder;
string[] rootFolders = { FolderNames.Sessions, FolderNames.Buffers, FolderNames.Clips, FolderNames.Highlights };
string[] rootFolders = { FolderNames.Sessions, FolderNames.Buffers, FolderNames.Clips, FolderNames.Highlights, FolderNames.Lowlights };
bool isGameSubfolder = rootFolders.Any(rf =>
videoDirectory.StartsWith(Path.Combine(contentRoot, rf), StringComparison.OrdinalIgnoreCase) &&
!videoDirectory.Equals(Path.Combine(contentRoot, rf), StringComparison.OrdinalIgnoreCase));
Expand Down
2 changes: 0 additions & 2 deletions Backend/Media/HighlightService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@ public static async Task CreateHighlightFromBookmarks(string fileName, Action<in
{
try
{
Log.Information($"Starting highlight creation for: {fileName}");

Content? content = AppState.Instance.Content.FirstOrDefault(x => x.FileName == fileName);
if (content == null)
{
Expand Down
Loading