Skip to content

Commit 034ba8b

Browse files
committed
Check if the first clip has video
1 parent 9b2d344 commit 034ba8b

File tree

1 file changed

+26
-3
lines changed

1 file changed

+26
-3
lines changed

workflows/export/vx_export.go

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ package export
22

33
import (
44
"fmt"
5+
"github.com/bcc-code/bcc-media-flows/activities"
56
"strings"
67

78
"github.com/bcc-code/bcc-media-flows/utils"
@@ -104,6 +105,17 @@ func VXExport(ctx workflow.Context, params VXExportParams) ([]wfutils.ResultOrEr
104105
return nil, err
105106
}
106107

108+
if len(data.Clips) == 0 {
109+
wfutils.SendTelegramText(ctx, telegramChat,
110+
fmt.Sprintf("No clips found for `%s`.\nTitle: `%s`\nDestinations: `%s`\n\nRunID: `%s`",
111+
params.VXID,
112+
data.Title,
113+
strings.Join(params.Destinations, ", "),
114+
workflow.GetInfo(ctx).OriginalRunID,
115+
),
116+
)
117+
}
118+
107119
wfutils.SendTelegramText(ctx,
108120
telegramChat,
109121
fmt.Sprintf(
@@ -134,18 +146,29 @@ func VXExport(ctx workflow.Context, params VXExportParams) ([]wfutils.ResultOrEr
134146
return nil, err
135147
}
136148

149+
firstClip, err := paths.Parse(data.Clips[0].VideoFile)
150+
if err != nil {
151+
return nil, err
152+
}
153+
154+
fileInfo, err := wfutils.Execute(ctx, activities.Audio.AnalyzeFile, activities.AnalyzeFileParams{
155+
FilePath: firstClip,
156+
}).Result(ctx)
157+
158+
if err != nil {
159+
return nil, err
160+
}
161+
137162
ctx = workflow.WithChildOptions(ctx, wfutils.GetVXDefaultWorkflowOptions(params.VXID))
138163

139164
bmmOnly := len(params.Destinations) == 1 && (params.Destinations[0] == AssetExportDestinationBMM.Value || params.Destinations[0] == AssetExportDestinationBMMIntegration.Value)
140165

141-
audioOnly := (len(data.Clips) > 0 && data.Clips[0].VideoFile == "") || bmmOnly
142-
143166
var mergeResult MergeExportDataResult
144167
err = workflow.ExecuteChildWorkflow(ctx, MergeExportData, MergeExportDataParams{
145168
ExportData: data,
146169
TempDir: tempDir,
147170
SubtitlesDir: subtitlesOutputDir,
148-
MakeVideo: !audioOnly,
171+
MakeVideo: !bmmOnly && fileInfo.HasVideo,
149172
MakeAudio: true,
150173
MakeSubtitles: true,
151174
MakeTranscript: true,

0 commit comments

Comments
 (0)