Skip to content

Commit b7cefe6

Browse files
JacobWang-bcFosol
authored andcommitted
Enhance AutoClipperManager to include clip time calculation and update headline format. Adjusted PublishedOn to reflect calculated clip time when available. (#2543)
1 parent ecd2a22 commit b7cefe6

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

services/net/auto-clipper/AutoClipperManager.cs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -581,6 +581,10 @@ private ContentModel BuildClipContentModel(ContentModel sourceContent, ClipDefin
581581
var autoTags = _tags?.Where(t => this.Options.ApplyTags.Contains(t.Code));
582582
var tags = autoTags != null ? sourceContent.Tags.AppendRange(autoTags.Select(at => new ContentTagModel(at.Id, at.Code, at.Name))) : sourceContent.Tags;
583583

584+
// Calculate clip time = parent content publish time + clip start offset
585+
var clipTime = sourceContent.PublishedOn?.Add(definition.Start);
586+
var timePrefix = clipTime?.ToString("HH:mm");
587+
584588
return new ContentModel
585589
{
586590
ContentType = sourceContent.ContentType,
@@ -597,11 +601,11 @@ private ContentModel BuildClipContentModel(ContentModel sourceContent, ClipDefin
597601
Byline = sourceContent.Byline,
598602
Status = ContentStatus.Draft,
599603
Uid = BaseService.GetContentHash(sourceContent.Source?.Code ?? "AutoClipper", $"{sourceContent.Uid}-clip-{clipIndex}", sourceContent.PublishedOn),
600-
Headline = $"{definition.Title}",
604+
Headline = string.IsNullOrEmpty(timePrefix) ? definition.Title : $"{timePrefix} - {definition.Title}",
601605
Summary = $"[AutoClipper:{definition.Category}]\n{clipSummary}",
602606
Body = transcriptBody,
603607
SourceUrl = sourceContent.SourceUrl,
604-
PublishedOn = sourceContent.PublishedOn,
608+
PublishedOn = clipTime ?? sourceContent.PublishedOn,
605609
PostedOn = DateTime.UtcNow,
606610
Tags = tags,
607611
Topics = sourceContent.Topics,

0 commit comments

Comments
 (0)