Skip to content

Commit cf43ffc

Browse files
committed
feat(FunscriptPreviewControl): render additional file metadata if available
1 parent 89b9d99 commit cf43ffc

File tree

3 files changed

+62
-14
lines changed

3 files changed

+62
-14
lines changed

FunscriptPreviewControl.cs

Lines changed: 52 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System;
2+
using System.Collections.Generic;
23
using System.IO;
34
using System.Text;
45
using System.Drawing;
@@ -132,32 +133,69 @@ private string FormatMetadata(Funscript script, int duration, double avgSpeed)
132133
{
133134
var sb = new StringBuilder();
134135

135-
// Title section with proper formatting
136136
if (script.metadata != null && !string.IsNullOrEmpty(script.metadata.title))
137137
{
138138
sb.AppendLine($"Title: {script.metadata.title}");
139139
sb.AppendLine();
140140
}
141141

142-
// Core stats in a more organized layout with clear separation
143142
sb.AppendLine($"Duration: {MetadataFormatter.FormatTime(duration)} | Actions: {script.actions.Count} | Avg Speed: {avgSpeed:F1} movements/sec");
144143

145-
// Additional metadata with better formatting
146144
if (script.metadata != null)
147145
{
148-
// Only add a separator if we have additional metadata
149-
bool hasAdditionalInfo = !string.IsNullOrEmpty(script.metadata.creator) ||
150-
(script.metadata.tags != null && script.metadata.tags.Length > 0);
151-
152-
if (hasAdditionalInfo)
146+
// Metadata: Creator and Type
147+
if (!string.IsNullOrEmpty(script.metadata.creator) || !string.IsNullOrEmpty(script.metadata.type))
153148
{
154-
sb.AppendLine();
155-
149+
var creatorTypeInfo = new List<string>();
156150
if (!string.IsNullOrEmpty(script.metadata.creator))
157-
sb.Append($"Creator: {script.metadata.creator}");
158-
159-
if (script.metadata.tags != null && script.metadata.tags.Length > 0)
160-
sb.AppendLine($"{(string.IsNullOrEmpty(script.metadata.creator) ? "" : " | ")}Tags: {string.Join(", ", script.metadata.tags)}");
151+
creatorTypeInfo.Add($"Creator: {script.metadata.creator}");
152+
if (!string.IsNullOrEmpty(script.metadata.type))
153+
creatorTypeInfo.Add($"Type: {script.metadata.type}");
154+
sb.AppendLine(string.Join(" | ", creatorTypeInfo));
155+
}
156+
157+
// Metadata: Performers and License
158+
if ((script.metadata.performers != null && script.metadata.performers.Length > 0) ||
159+
!string.IsNullOrEmpty(script.metadata.license))
160+
{
161+
var performersLicenseInfo = new List<string>();
162+
if (script.metadata.performers != null && script.metadata.performers.Length > 0)
163+
performersLicenseInfo.Add($"Performers: {string.Join(", ", script.metadata.performers)}");
164+
if (!string.IsNullOrEmpty(script.metadata.license))
165+
performersLicenseInfo.Add($"License: {script.metadata.license}");
166+
167+
sb.AppendLine(string.Join(" | ", performersLicenseInfo));
168+
}
169+
170+
// Metadata: Tags
171+
if (script.metadata.tags != null && script.metadata.tags.Length > 0)
172+
{
173+
sb.AppendLine($"Tags: {string.Join(", ", script.metadata.tags)}");
174+
}
175+
176+
// Metadata: Description
177+
if (!string.IsNullOrEmpty(script.metadata.description))
178+
sb.AppendLine($"Description: {script.metadata.description}");
179+
180+
// Metadata: Notes
181+
if (!string.IsNullOrEmpty(script.metadata.notes))
182+
sb.AppendLine($"Notes: {script.metadata.notes}");
183+
184+
// Metadata: URLs
185+
if (!string.IsNullOrEmpty(script.metadata.script_url))
186+
sb.AppendLine($"Script URL: {script.metadata.script_url}");
187+
188+
if (!string.IsNullOrEmpty(script.metadata.video_url))
189+
sb.AppendLine($"Video URL: {script.metadata.video_url}");
190+
191+
// Metadata: Chapters
192+
if (script.metadata.chapters != null && script.metadata.chapters.Length > 0)
193+
{
194+
sb.AppendLine("Chapters:");
195+
foreach (var chapter in script.metadata.chapters)
196+
{
197+
sb.AppendLine($"- {chapter?.name} ({chapter?.startTime} - {chapter?.endTime})");
198+
}
161199
}
162200
}
163201

Models/Funscript.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,5 +25,6 @@ public class FunscriptMetadata
2525
public string title { get; set; }
2626
public string type { get; set; }
2727
public string video_url { get; set; }
28+
public FunscriptChapter[] chapters { get; set; }
2829
}
2930
}

Models/FunscriptChapter.cs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
namespace FunscriptPreviewHandler.Models
2+
{
3+
public class FunscriptChapter
4+
{
5+
public string name { get; set; }
6+
public string startTime { get; set; }
7+
public string endTime { get; set; }
8+
}
9+
}

0 commit comments

Comments
 (0)