Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better method for detecting clipping requests #1350

Merged
merged 1 commit into from
Jul 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 1 addition & 12 deletions handlers/upload.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,7 @@ func (r UploadVODRequest) IsProfileValid() bool {
}

func (r UploadVODRequest) IsClippingRequest() bool {
return r.hasTargetOutput(func(o UploadVODRequestOutputLocationOutputs) string {
return o.Clip
})
return r.ClipStrategy.PlaybackID != ""
}

func (r UploadVODRequest) ValidateClippingRequest() error {
Expand Down Expand Up @@ -165,15 +163,6 @@ func (r UploadVODRequest) getSourceCopyEnabled() bool {

type getOutput func(UploadVODRequestOutputLocationOutputs) string

func (r UploadVODRequest) hasTargetOutput(getOutput getOutput) bool {
for _, o := range r.OutputLocations {
if getOutput(o.Outputs) == "enabled" {
return true
}
}
return false
}

func (r UploadVODRequest) getTargetOutput(getOutput getOutput) UploadVODRequestOutputLocation {
for _, o := range r.OutputLocations {
if getOutput(o.Outputs) == "enabled" {
Expand Down
24 changes: 3 additions & 21 deletions handlers/upload_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -200,31 +200,13 @@ func TestIsProfileValid(t *testing.T) {

func TestWeCanDetermineIfItsAClippingRequest(t *testing.T) {
u := UploadVODRequest{
OutputLocations: []UploadVODRequestOutputLocation{
{
URL: "some-url",
Type: "clip",
Outputs: UploadVODRequestOutputLocationOutputs{
Clip: "enabled",
},
},
ClipStrategy: video.ClipStrategy{
PlaybackID: "12345",
},
}
require.True(t, u.IsClippingRequest())

u = UploadVODRequest{
OutputLocations: []UploadVODRequestOutputLocation{
{
URL: "some-url",
Type: "vod",
Outputs: UploadVODRequestOutputLocationOutputs{
HLS: "enabled",
MP4: "enabled",
Thumbnails: "enabled",
},
},
},
}
u = UploadVODRequest{}
require.False(t, u.IsClippingRequest())
}

Expand Down
Loading