@@ -37,6 +37,7 @@ public class AutoClipperManager : ServiceManager<AutoClipperOptions>
3737 private readonly WorkOrderStatus [ ] _ignoreWorkOrders = new WorkOrderStatus [ ] { WorkOrderStatus . Completed , WorkOrderStatus . Cancelled } ;
3838 private int _retries = 0 ;
3939 private string ? _etag = null ;
40+ private API . Areas . Editor . Models . Tag . TagModel [ ] ? _tags = [ ] ;
4041 #endregion
4142
4243 #region Properties
@@ -317,13 +318,13 @@ private async Task<string> DownloadS3File(string? s3Path)
317318 using ( var fileStream = new FileStream ( tmpFilePath , FileMode . Create , FileAccess . Write ) )
318319 {
319320 s3FileStream . CopyTo ( fileStream ) ;
320- this . Logger . LogDebug ( $ "S3 file { s3Path } is downloaded to: { tmpFilePath } " ) ;
321+ this . Logger . LogDebug ( "S3 file {path } is downloaded to: {file}" , s3Path , tmpFilePath ) ;
321322 return tmpFilePath ;
322323 }
323324 }
324325 else
325326 {
326- this . Logger . LogError ( $ "Cannot download file { s3Path } from S3") ;
327+ this . Logger . LogError ( "Cannot download file {file } from S3" , s3Path ) ;
327328 }
328329 }
329330 else
@@ -450,6 +451,14 @@ private async Task ProcessClipRequestAsync(ClipRequestModel request, ContentMode
450451 await this . Api . UpdateContentAsync ( content ) ;
451452 this . Logger . LogInformation ( "Primary transcript updated. Content ID: {Id}" , requestContentId ) ;
452453
454+ // Fetch tags once for all clips from the API.
455+ var tagsResponse = await this . Api . GetTagsResponseWithEtagAsync ( _etag ?? "" ) ;
456+ if ( tagsResponse != null && tagsResponse . StatusCode == System . Net . HttpStatusCode . OK )
457+ {
458+ _tags = await this . Api . GetResponseDataAsync < API . Areas . Editor . Models . Tag . TagModel [ ] > ( tagsResponse ) ;
459+ _etag = this . Api . GetResponseEtag ( tagsResponse ) ;
460+ }
461+
453462 var clipIndex = 1 ;
454463 foreach ( var definition in clipDefinitions )
455464 {
@@ -573,10 +582,7 @@ private async Task<ContentModel> BuildClipContentModelAsync(ContentModel sourceC
573582 ? $ "Clip covering { FormatTimestamp ( definition . Start ) } to { FormatTimestamp ( definition . End ) } "
574583 : definition . Summary ;
575584
576- var tagsResponse = await this . Api . GetTagsResponseWithEtagAsync ( _etag ?? "" ) ;
577- var allTags = await this . Api . GetResponseDataAsync < API . Areas . Editor . Models . Tag . TagModel [ ] > ( tagsResponse ) ;
578- _etag = this . Api . GetResponseEtag ( tagsResponse ) ;
579- var autoTags = allTags ? . Where ( t => this . Options . ApplyTags . Contains ( t . Code ) ) ;
585+ var autoTags = _tags ? . Where ( t => this . Options . ApplyTags . Contains ( t . Code ) ) ;
580586 var tags = autoTags != null ? sourceContent . Tags . AppendRange ( autoTags . Select ( at => new ContentTagModel ( at . Id , at . Code , at . Name ) ) ) : sourceContent . Tags ;
581587
582588 return new ContentModel
0 commit comments