-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathisilon_export.go
116 lines (95 loc) · 3.13 KB
/
isilon_export.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
package main
import (
"net/http"
"os"
"github.com/bcc-code/bcc-media-flows/services/vidispine"
"github.com/bcc-code/bcc-media-flows/services/vidispine/vsapi"
"github.com/bcc-code/bcc-media-flows/services/vidispine/vscommon"
"github.com/bcc-code/bcc-media-flows/utils"
"github.com/bcc-code/bcc-media-flows/workflows/export"
bccmUtils "github.com/bcc-code/bcc-media-platform/backend/utils"
"github.com/davecgh/go-spew/spew"
"github.com/gin-gonic/gin"
"github.com/teris-io/shortid"
"go.temporal.io/sdk/client"
)
func (s *TriggerServer) isilonExportGET(ctx *gin.Context) {
vxID := ctx.Query("id")
meta, err := s.vidispine.GetMetadata(vxID)
if err != nil {
renderErrorPage(ctx, http.StatusInternalServerError, err)
return
}
resolutions, err := s.vidispine.GetResolutions(vxID)
if err != nil {
renderErrorPage(ctx, http.StatusInternalServerError, err)
return
}
clips := meta.SplitByClips()
title := clips[vsapi.OriginalClip].Get(vscommon.FieldTitle, "")
selectedAudioSource := meta.Get(vscommon.FieldExportAudioSource, "")
filenames, err := getFilenames(overlaysDir)
if err != nil {
renderErrorPage(ctx, http.StatusInternalServerError, err)
return
}
var ratioString string
if len(resolutions) > 0 {
ratioString = ratio(resolutions[0].Width, resolutions[0].Height)
}
ctx.HTML(http.StatusOK, "isilon-export.gohtml", TriggerGETParams{
ID: vxID,
Title: title,
Filenames: filenames,
Languages: s.languages,
SelectedAudioSource: selectedAudioSource,
AudioSources: vidispine.ExportAudioSources.Values(),
Resolutions: resolutions,
Ratio: ratioString,
})
}
func (s *TriggerServer) isilonExportPOST(ctx *gin.Context) {
vxID := ctx.Query("id")
queue := getQueue()
workflowOptions := client.StartWorkflowOptions{
TaskQueue: queue,
}
if os.Getenv("DEBUG") == "" {
workflowOptions.SearchAttributes = map[string]any{
"CustomStringField": vxID,
}
}
resolutionIndex := bccmUtils.AsInt(ctx.PostForm("resolutions"))
vsResolutions, err := s.vidispine.GetResolutions(vxID)
if err != nil {
renderErrorPage(ctx, http.StatusInternalServerError, err)
return
}
selectedResolution := vsResolutions[resolutionIndex]
spew.Dump(ctx.PostForm("exportFormat"))
params := export.IsilonExportParams{
VXID: vxID,
WatermarkPath: ctx.PostForm("watermarkPath"),
AudioSource: ctx.PostForm("audioSource"),
Language: ctx.PostForm("language"),
Resolution: utils.Resolution{Width: selectedResolution.Width, Height: selectedResolution.Height},
ExportFormat: ctx.PostForm("exportFormat"),
}
var wfID string
workflowOptions.ID = params.VXID + "-" + shortid.MustGenerate()
res, err := s.wfClient.ExecuteWorkflow(ctx, workflowOptions, export.IsilonExport, params)
if err != nil {
renderErrorPage(ctx, http.StatusInternalServerError, err)
return
}
wfID = res.GetID()
meta, err := s.vidispine.GetMetadata(vxID)
if err != nil {
renderErrorPage(ctx, http.StatusInternalServerError, err)
return
}
ctx.HTML(http.StatusOK, "success.gohtml", gin.H{
"WorkflowID": wfID,
"Title": meta.Get(vscommon.FieldTitle, ""),
})
}