diff --git a/examples/ffmpeg/scyllaridae.yml b/examples/ffmpeg/scyllaridae.yml index e9e4e57..ed48b96 100644 --- a/examples/ffmpeg/scyllaridae.yml +++ b/examples/ffmpeg/scyllaridae.yml @@ -8,22 +8,34 @@ cmdByMimeType: "image/jpeg": cmd: ffmpeg args: + - "-f" + - "%source-mime-ext" - "-i" - "-" - "%args" - "-f" - "image2pipe" + - "-vcodec" + - "mjpeg" + - "-" "image/png": cmd: ffmpeg args: + - "-f" + - "%source-mime-ext" - "-i" - "-" - "%args" - "-f" - "image2pipe" + - "-vcodec" + - "png" + - "-" "video/mp4": cmd: ffmpeg args: + - "-f" + - "%source-mime-ext" - "-i" - "-" - "%args" @@ -45,7 +57,7 @@ cmdByMimeType: - "faststart" - "-y" - "-f" - - "mp4" + - "%destination-mime-ext" - "-" default: cmd: ffmpeg diff --git a/go.mod b/go.mod index ddff56d..ae234c3 100644 --- a/go.mod +++ b/go.mod @@ -4,6 +4,7 @@ go 1.22.2 require ( github.com/go-stomp/stomp/v3 v3.1.0 + github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 github.com/stretchr/testify v1.9.0 gopkg.in/yaml.v3 v3.0.1 ) diff --git a/go.sum b/go.sum index 2d7907b..8911a53 100644 --- a/go.sum +++ b/go.sum @@ -5,6 +5,8 @@ github.com/go-stomp/stomp/v3 v3.1.0 h1:JnvRJuua/fX2Lq5Ie5DXzrOL18dnzIUenCZXM6rr8 github.com/go-stomp/stomp/v3 v3.1.0/go.mod h1:ztzZej6T2W4Y6FlD+Tb5n7HQP3/O5UNQiuC169pIp10= github.com/golang/mock v1.6.0 h1:ErTB+efbowRARo13NNdxyJji2egdxLGQhRaY+DUumQc= github.com/golang/mock v1.6.0/go.mod h1:p6yTPP+5HYm5mzsMV8JkE6ZKdX+/wYM6Hr+LicevLPs= +github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510 h1:El6M4kTTCOh6aBiKaUGG7oYTSPP8MxqL4YI3kZKwcP4= +github.com/google/shlex v0.0.0-20191202100458-e7afc7fbc510/go.mod h1:pupxD2MaaD3pAXIBCelhxNneeOaAeabZDe5s4K6zSpQ= github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= diff --git a/internal/config/server.go b/internal/config/server.go index f37d865..635b941 100644 --- a/internal/config/server.go +++ b/internal/config/server.go @@ -7,6 +7,7 @@ import ( "os/exec" "strings" + "github.com/google/shlex" "github.com/lehigh-university-libraries/scyllaridae/pkg/api" "gopkg.in/yaml.v3" ) @@ -141,7 +142,11 @@ func BuildExecCommand(message api.Payload, c *ServerConfig) (*exec.Cmd, error) { // replace it with the args passed by the event if a == "%args" { if message.Attachment.Content.Args != "" { - args = append(args, message.Attachment.Content.Args) + passedArgs, err := shlex.Split(message.Attachment.Content.Args) + if err != nil { + return nil, fmt.Errorf("Error parsing args %s: %v", message.Attachment.Content.Args, err) + } + args = append(args, passedArgs...) } // if we have the special value of %source-mime-ext // replace it with the source mimetype extension