Skip to content

Commit df1b6bb

Browse files
committed
Update auto clipper
1 parent fbc1d4b commit df1b6bb

File tree

64 files changed

+1209
-206
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

64 files changed

+1209
-206
lines changed

.vscode/launch.json

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
{
22
"version": "0.2.0",
33
"configurations": [
4-
5-
64
{
75
// Use IntelliSense to find out which attributes exist for C# debugging
86
// Use hover for the description of the existing attributes
@@ -105,6 +103,23 @@
105103
"stopAtEntry": false,
106104
"envFile": "${workspaceFolder}/services/net/transcription/.env"
107105
},
106+
{
107+
// Use IntelliSense to find out which attributes exist for C# debugging
108+
// Use hover for the description of the existing attributes
109+
// For further information visit https://github.com/OmniSharp/omnisharp-vscode/blob/master/debugger-launchjson.md
110+
"name": "Run Auto Clipper Service",
111+
"type": "coreclr",
112+
"request": "launch",
113+
"preLaunchTask": "build-auto-clipper",
114+
// If you have changed target frameworks, make sure to update the program path.
115+
"program": "${workspaceFolder}/services/net/auto-clipper/bin/Debug/net9.0/TNO.Services.AutoClipper.dll",
116+
"args": [],
117+
"cwd": "${workspaceFolder}/services/net/auto-clipper",
118+
// For more information about the 'console' field, see https://aka.ms/VSCode-CS-LaunchJson-Console
119+
"console": "internalConsole",
120+
"stopAtEntry": false,
121+
"envFile": "${workspaceFolder}/services/net/auto-clipper/.env"
122+
},
108123
{
109124
// Use IntelliSense to find out which attributes exist for C# debugging
110125
// Use hover for the description of the existing attributes

.vscode/settings.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
"CHES",
1313
"datalabels",
1414
"formik",
15+
"healthcheck",
1516
"Idir",
1617
"insertable",
1718
"Keycloak",

.vscode/tasks.json

Lines changed: 49 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -29,12 +29,7 @@
2929
"label": "watch",
3030
"command": "dotnet",
3131
"type": "process",
32-
"args": [
33-
"watch",
34-
"run",
35-
"--project",
36-
"${workspaceFolder}/api/net/TNO.API.csproj"
37-
],
32+
"args": ["watch", "run", "--project", "${workspaceFolder}/api/net/TNO.API.csproj"],
3833
"problemMatcher": "$msCompile"
3934
},
4035
{
@@ -213,7 +208,43 @@
213208
"watch",
214209
"run",
215210
"--project",
216-
"${workspaceFolder}/services/net/transcription/TNO.Services.Transcription.csproj"
211+
"${workspaceFolder}/services/net/atranscription/TNO.Services.Transcription.csproj"
212+
],
213+
"problemMatcher": "$msCompile"
214+
},
215+
{
216+
"label": "build-auto-clipper",
217+
"command": "dotnet",
218+
"type": "process",
219+
"args": [
220+
"build",
221+
"${workspaceFolder}/services/net/auto-clipper/TNO.Services.AutoClipper.csproj",
222+
"/property:GenerateFullPaths=true",
223+
"/consoleloggerparameters:NoSummary"
224+
],
225+
"problemMatcher": "$msCompile"
226+
},
227+
{
228+
"label": "publish-auto-clipper",
229+
"command": "dotnet",
230+
"type": "process",
231+
"args": [
232+
"publish",
233+
"${workspaceFolder}/services/net/auto-clipper/TNO.Services.AutoClipper.csproj",
234+
"/property:GenerateFullPaths=true",
235+
"/consoleloggerparameters:NoSummary"
236+
],
237+
"problemMatcher": "$msCompile"
238+
},
239+
{
240+
"label": "watch-auto-clipper",
241+
"command": "dotnet",
242+
"type": "process",
243+
"args": [
244+
"watch",
245+
"run",
246+
"--project",
247+
"${workspaceFolder}/services/net/auto-clipper/TNO.Services.TranAutoClipperscription.csproj"
217248
],
218249
"problemMatcher": "$msCompile"
219250
},
@@ -357,7 +388,7 @@
357388
"watch",
358389
"run",
359390
"--project",
360-
"${workspaceFolder}/tools/elastic/migration/TNO.Elastic.Migration.csproj",
391+
"${workspaceFolder}/tools/elastic/migration/TNO.Elastic.Migration.csproj"
361392
],
362393
"problemMatcher": "$msCompile"
363394
},
@@ -393,7 +424,7 @@
393424
"watch",
394425
"run",
395426
"--project",
396-
"${workspaceFolder}/services/net/notification/TNO.Services.Notification.csproj",
427+
"${workspaceFolder}/services/net/notification/TNO.Services.Notification.csproj"
397428
],
398429
"problemMatcher": "$msCompile"
399430
},
@@ -429,7 +460,7 @@
429460
"watch",
430461
"run",
431462
"--project",
432-
"${workspaceFolder}/services/net/reporting/TNO.Services.Reporting.csproj",
463+
"${workspaceFolder}/services/net/reporting/TNO.Services.Reporting.csproj"
433464
],
434465
"problemMatcher": "$msCompile"
435466
},
@@ -465,7 +496,7 @@
465496
"watch",
466497
"run",
467498
"--project",
468-
"${workspaceFolder}/services/net/scheduler/TNO.Services.Scheduler.csproj",
499+
"${workspaceFolder}/services/net/scheduler/TNO.Services.Scheduler.csproj"
469500
],
470501
"problemMatcher": "$msCompile"
471502
},
@@ -501,7 +532,7 @@
501532
"watch",
502533
"run",
503534
"--project",
504-
"${workspaceFolder}/services/net/folder-collection/TNO.Services.FolderCollection.csproj",
535+
"${workspaceFolder}/services/net/folder-collection/TNO.Services.FolderCollection.csproj"
505536
],
506537
"problemMatcher": "$msCompile"
507538
},
@@ -537,7 +568,7 @@
537568
"watch",
538569
"run",
539570
"--project",
540-
"${workspaceFolder}/services/net/ffmpeg/TNO.Services.FFmpeg.csproj",
571+
"${workspaceFolder}/services/net/ffmpeg/TNO.Services.FFmpeg.csproj"
541572
],
542573
"problemMatcher": "$msCompile"
543574
},
@@ -573,7 +604,7 @@
573604
"watch",
574605
"run",
575606
"--project",
576-
"${workspaceFolder}/services/net/extract-quotes/TNO.Services.ExtractQuotes.csproj",
607+
"${workspaceFolder}/services/net/extract-quotes/TNO.Services.ExtractQuotes.csproj"
577608
],
578609
"problemMatcher": "$msCompile"
579610
},
@@ -609,7 +640,7 @@
609640
"watch",
610641
"run",
611642
"--project",
612-
"${workspaceFolder}/services/net/event-handler/TNO.Services.EventHandler.csproj",
643+
"${workspaceFolder}/services/net/event-handler/TNO.Services.EventHandler.csproj"
613644
],
614645
"problemMatcher": "$msCompile"
615646
},
@@ -645,11 +676,10 @@
645676
"watch",
646677
"run",
647678
"--project",
648-
"${workspaceFolder}/services/net/ches-retry/TNO.Services.ChesRetry.csproj",
679+
"${workspaceFolder}/services/net/ches-retry/TNO.Services.ChesRetry.csproj"
649680
],
650681
"problemMatcher": "$msCompile"
651-
}
652-
,
682+
},
653683
{
654684
"label": "build-elastic-indexer",
655685
"command": "dotnet",
@@ -682,7 +712,7 @@
682712
"watch",
683713
"run",
684714
"--project",
685-
"${workspaceFolder}/tools/indexer/TNO.Tools.ElasticIndexer.csproj",
715+
"${workspaceFolder}/tools/indexer/TNO.Tools.ElasticIndexer.csproj"
686716
],
687717
"problemMatcher": "$msCompile"
688718
}

TNO.sln

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -85,14 +85,12 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TNO.Services.EventHandler",
8585
EndProject
8686
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TNO.Services.ChesRetry", "services\net\ches-retry\TNO.Services.ChesRetry.csproj", "{067EA7C3-A816-406B-B36A-09FC05A427A1}"
8787
EndProject
88+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "TNO.Services.AutoClipper", "services\net\auto-clipper\TNO.Services.AutoClipper.csproj", "{7B8BF924-36BA-422E-85FD-1C590B092F7B}"
89+
EndProject
8890
Global
8991
GlobalSection(SolutionConfigurationPlatforms) = preSolution
9092
Debug|Any CPU = Debug|Any CPU
9193
Release|Any CPU = Release|Any CPU
92-
{27ED3E2D-4868-4A23-B85B-59BBB15A662E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
93-
{27ED3E2D-4868-4A23-B85B-59BBB15A662E}.Debug|Any CPU.Build.0 = Debug|Any CPU
94-
{27ED3E2D-4868-4A23-B85B-59BBB15A662E}.Release|Any CPU.ActiveCfg = Release|Any CPU
95-
{27ED3E2D-4868-4A23-B85B-59BBB15A662E}.Release|Any CPU.Build.0 = Release|Any CPU
9694
EndGlobalSection
9795
GlobalSection(SolutionProperties) = preSolution
9896
HideSolutionNode = FALSE
@@ -230,6 +228,10 @@ Global
230228
{067EA7C3-A816-406B-B36A-09FC05A427A1}.Debug|Any CPU.Build.0 = Debug|Any CPU
231229
{067EA7C3-A816-406B-B36A-09FC05A427A1}.Release|Any CPU.ActiveCfg = Release|Any CPU
232230
{067EA7C3-A816-406B-B36A-09FC05A427A1}.Release|Any CPU.Build.0 = Release|Any CPU
231+
{7B8BF924-36BA-422E-85FD-1C590B092F7B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
232+
{7B8BF924-36BA-422E-85FD-1C590B092F7B}.Debug|Any CPU.Build.0 = Debug|Any CPU
233+
{7B8BF924-36BA-422E-85FD-1C590B092F7B}.Release|Any CPU.ActiveCfg = Release|Any CPU
234+
{7B8BF924-36BA-422E-85FD-1C590B092F7B}.Release|Any CPU.Build.0 = Release|Any CPU
233235
EndGlobalSection
234236
GlobalSection(NestedProjects) = preSolution
235237
{16EA028B-B4C8-416D-BE54-D73D75483668} = {F627B24A-217D-4BF1-BC77-E1A92DBCD07F}
@@ -269,5 +271,6 @@ Global
269271
{2D455400-0E86-476E-8C42-532D32C10107} = {448D6DE6-6887-48EC-A202-18C7EB428ACD}
270272
{6F1F9B85-B155-4A5A-BB36-10F734F96A12} = {448D6DE6-6887-48EC-A202-18C7EB428ACD}
271273
{067EA7C3-A816-406B-B36A-09FC05A427A1} = {448D6DE6-6887-48EC-A202-18C7EB428ACD}
274+
{7B8BF924-36BA-422E-85FD-1C590B092F7B} = {448D6DE6-6887-48EC-A202-18C7EB428ACD}
272275
EndGlobalSection
273276
EndGlobal

api/net/Areas/Editor/Controllers/WorkOrderController.cs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,29 @@ public async Task<IActionResult> RequestTranscriptionAsync(long contentId)
147147
return new JsonResult(new WorkOrderMessageModel(workOrder, _serializerOptions));
148148
}
149149

150+
/// <summary>
151+
/// Request an auto clip for the content for the specified 'contentId'.
152+
/// Publish message to kafka to request an auto clip.
153+
/// </summary>
154+
/// <param name="contentId"></param>
155+
/// <returns></returns>
156+
[HttpPost("auto-clip/{contentId}")]
157+
[Produces(MediaTypeNames.Application.Json)]
158+
[ProducesResponseType(typeof(WorkOrderMessageModel), (int)HttpStatusCode.OK)]
159+
[ProducesResponseType(typeof(ErrorResponseModel), (int)HttpStatusCode.BadRequest)]
160+
[SwaggerOperation(Tags = new[] { "WorkOrder" })]
161+
public async Task<IActionResult> RequestAutoClipAsync(long contentId)
162+
{
163+
var workOrder = await _workOrderHelper.RequestAutoClipAsync(contentId, true);
164+
if (workOrder.Status != WorkOrderStatus.Submitted)
165+
return new JsonResult(new WorkOrderMessageModel(workOrder, _serializerOptions))
166+
{
167+
StatusCode = (int)HttpStatusCode.AlreadyReported
168+
};
169+
170+
return new JsonResult(new WorkOrderMessageModel(workOrder, _serializerOptions));
171+
}
172+
150173
/// <summary>
151174
/// Request a Natural Language Processing for the content for the specified 'contentId'.
152175
/// Publish message to kafka to request a NLP.

api/net/Areas/Helpers/IWorkOrderHelper.cs

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,18 @@ public interface IWorkOrderHelper
3434
/// <exception cref="NotAuthorizedException"></exception>
3535
Task<Entities.WorkOrder> RequestTranscriptionAsync(long contentId, bool force = false);
3636

37+
/// <summary>
38+
/// Request a auto clip for the specified 'contentId'.
39+
/// Only allow one active auto clip request.
40+
/// </summary>
41+
/// <param name="contentId"></param>
42+
/// <param name="force">Whether to force a request regardless of the prior requests state</param>
43+
/// <returns></returns>
44+
/// <exception cref="NoContentException"></exception>
45+
/// <exception cref="ConfigurationException"></exception>
46+
/// <exception cref="NotAuthorizedException"></exception>
47+
Task<Entities.WorkOrder> RequestAutoClipAsync(long contentId, bool force = false);
48+
3749
/// <summary>
3850
/// Request a transcript for the specified 'contentId'.
3951
/// Only allow one active transcript request.
@@ -47,6 +59,19 @@ public interface IWorkOrderHelper
4759
/// <exception cref="NotAuthorizedException"></exception>
4860
Task<Entities.WorkOrder> RequestTranscriptionAsync(long contentId, Entities.User requestor, bool force = false);
4961

62+
/// <summary>
63+
/// Request a auto clip for the specified 'contentId'.
64+
/// Only allow one active auto clip request.
65+
/// </summary>
66+
/// <param name="contentId"></param>
67+
/// <param name="requestor"></param>
68+
/// <param name="force">Whether to force a request regardless of the prior requests state</param>
69+
/// <returns></returns>
70+
/// <exception cref="NoContentException"></exception>
71+
/// <exception cref="ConfigurationException"></exception>
72+
/// <exception cref="NotAuthorizedException"></exception>
73+
Task<Entities.WorkOrder> RequestAutoClipAsync(long contentId, Entities.User requestor, bool force = false);
74+
5075
/// <summary>
5176
/// Request a natural language processing for the specified 'contentId'.
5277
/// Only allow one active nlp request.

api/net/Areas/Helpers/WorkOrderHelper.cs

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,24 @@ public bool ShouldAutoTranscribe(long contentId)
136136
return await RequestTranscriptionAsync(contentId, user, force);
137137
}
138138

139+
/// <summary>
140+
/// Request a auto clip for the specified 'contentId'.
141+
/// Only allow one active auto clip request.
142+
/// </summary>
143+
/// <param name="contentId"></param>
144+
/// <param name="force">Whether to force a request regardless of the prior requests state</param>
145+
/// <returns></returns>
146+
/// <exception cref="NoContentException"></exception>
147+
/// <exception cref="ConfigurationException"></exception>
148+
/// <exception cref="NotAuthorizedException"></exception>
149+
public async Task<Entities.WorkOrder> RequestAutoClipAsync(long contentId, bool force = false)
150+
{
151+
string username = _principal.GetUsername() ?? throw new NotAuthorizedException("Username is missing");
152+
var user = _userService.FindByUsername(username) ?? throw new NotAuthorizedException("User is missing");
153+
154+
return await RequestAutoClipAsync(contentId, user, force);
155+
}
156+
139157
/// <summary>
140158
/// Determine if the content has an existing transcript.
141159
/// </summary>
@@ -195,6 +213,51 @@ public bool HasExistingTranscript(long contentId)
195213
return workOrders.OrderByDescending(w => w.CreatedOn).First();
196214
}
197215

216+
/// <summary>
217+
/// Request a auto clip for the specified 'contentId'.
218+
/// Only allow one active auto clip request.
219+
/// </summary>
220+
/// <param name="contentId"></param>
221+
/// <param name="requestor"></param>
222+
/// <param name="force">Whether to force a request regardless of the prior requests state</param>
223+
/// <returns></returns>
224+
/// <exception cref="NoContentException"></exception>
225+
/// <exception cref="ConfigurationException"></exception>
226+
/// <exception cref="NotAuthorizedException"></exception>
227+
/// <exception cref="InvalidOperationException"></exception>
228+
public async Task<Entities.WorkOrder> RequestAutoClipAsync(long contentId, Entities.User requestor, bool force = false)
229+
{
230+
if (this.Content == null || this.Content.Id != contentId)
231+
this.Content = _contentService.FindById(contentId) ?? throw new NoContentException("Content does not exist");
232+
if (String.IsNullOrWhiteSpace(_kafkaOptions.AutoClipTopic)) throw new ConfigurationException("Kafka auto clip topic not configured.");
233+
234+
if (this.Content.IsApproved && force == false) throw new InvalidOperationException("Content is already approved");
235+
// Only allow one work order auto clip request at a time.
236+
// TODO: Handle blocked work orders stuck in progress.
237+
var workOrders = _workOrderService.FindByContentId(contentId);
238+
239+
// Add the user to the content notification.
240+
_notificationService.SubscriberUserToContent(requestor.Id, contentId);
241+
242+
if (force || !workOrders.Any(o => o.WorkType == Entities.WorkOrderType.AutoClip || !WorkLimiterStatus.Contains(o.Status)))
243+
{
244+
var headlineString = $"{{ \"headline\": \"{this.Content.Headline.Replace("\n", "")}\" }}";
245+
var configuration = JsonDocument.Parse(headlineString);
246+
var workOrder = _workOrderService.AddAndSave(
247+
new Entities.WorkOrder(
248+
Entities.WorkOrderType.AutoClip,
249+
requestor,
250+
"",
251+
this.Content,
252+
configuration
253+
));
254+
255+
await _kafkaMessenger.SendMessageAsync(_kafkaOptions.AutoClipTopic, new TNO.Kafka.Models.ClipRequestModel(workOrder));
256+
return workOrder;
257+
}
258+
return workOrders.OrderByDescending(w => w.CreatedOn).First();
259+
}
260+
198261
/// <summary>
199262
/// Request a natural language processing for the specified 'contentId'.
200263
/// Only allow one active nlp request.

api/net/Config/KafkaOptions.cs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,11 @@ public class KafkaOptions
1616
/// </summary>
1717
public string TranscriptionTopic { get; set; } = "";
1818

19+
/// <summary>
20+
/// get/set - The Kafka topic name to request auto clips.
21+
/// </summary>
22+
public string AutoClipTopic { get; set; } = "";
23+
1924
/// <summary>
2025
/// get/set - The Kafka topic name to request NLP.
2126
/// </summary>

api/net/appsettings.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@
6262
"Kafka": {
6363
"IndexingTopic": "index",
6464
"TranscriptionTopic": "transcribe",
65+
"AutoClipTopic": "request-clips",
6566
"NLPTopic": "nlp",
6667
"FileRequestTopic": "file-request",
6768
"NotificationTopic": "notify",

app/editor/.yarn/cache/tno-core-npm-1.0.29-b0ccc3fe82-277dacbb50.zip renamed to app/editor/.yarn/cache/tno-core-file-314ca1fd79-6095421787.zip

2.03 MB
Binary file not shown.

0 commit comments

Comments
 (0)