Skip to content

Commit 9e03f17

Browse files
authored
Add ffmepg support (#186)
1 parent 43e6929 commit 9e03f17

File tree

4 files changed

+111
-0
lines changed

4 files changed

+111
-0
lines changed

pkg/os/apt/ffmpeg.go

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
package apt
2+
3+
import (
4+
"fmt"
5+
"github.com/linuxsuren/http-downloader/pkg/exec"
6+
"runtime"
7+
)
8+
9+
// ffmpegInstallerInUbuntu is the installer of ffmpeg in CentOS
10+
type ffmpegInstallerInUbuntu struct {
11+
count int
12+
}
13+
14+
// Available check if support current platform
15+
func (d *ffmpegInstallerInUbuntu) Available() (ok bool) {
16+
if runtime.GOOS == "linux" {
17+
_, err := exec.LookPath("apt-get")
18+
ok = err == nil
19+
}
20+
return
21+
}
22+
23+
// Install installs the ffmpeg
24+
func (d *ffmpegInstallerInUbuntu) Install() (err error) {
25+
if err = exec.RunCommand("apt-get", "update", "-y"); err != nil {
26+
return
27+
}
28+
if err = exec.RunCommand("apt-get", "install", "-y",
29+
"ffmpeg"); err != nil {
30+
return
31+
}
32+
return
33+
}
34+
35+
// Uninstall uninstalls the ffmpeg
36+
func (d *ffmpegInstallerInUbuntu) Uninstall() (err error) {
37+
err = exec.RunCommand("apt-get", "remove", "-y",
38+
"ffmpeg")
39+
return
40+
}
41+
42+
// WaitForStart waits for the service be started
43+
func (d *ffmpegInstallerInUbuntu) WaitForStart() (ok bool, err error) {
44+
ok = true
45+
return
46+
}
47+
48+
// Start starts the ffmpeg service
49+
func (d *ffmpegInstallerInUbuntu) Start() error {
50+
fmt.Println("not supported yet")
51+
return nil
52+
}
53+
54+
// Stop stops the ffmpeg service
55+
func (d *ffmpegInstallerInUbuntu) Stop() error {
56+
fmt.Println("not supported yet")
57+
return nil
58+
}

pkg/os/apt/init.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,5 @@ func SetInstallerRegistry(registry core.InstallerRegistry) {
1313
registry.Registry("kubectl", &kubectlInstallerInUbuntu{})
1414
registry.Registry("bash-completion", &bashCompletionInstallerInUbuntu{})
1515
registry.Registry("asciinema", &asciinemaInstallerInUbuntu{})
16+
registry.Registry("ffmpge", &ffmpegInstallerInUbuntu{})
1617
}

pkg/os/brew/ffmpeg.go

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
package brew
2+
3+
import (
4+
"fmt"
5+
"github.com/linuxsuren/http-downloader/pkg/exec"
6+
"runtime"
7+
)
8+
9+
// ffmpegInstallerInMacOS is the installer of ffmpeg in CentOS
10+
type ffmpegInstallerInMacOS struct {
11+
count int
12+
}
13+
14+
// Available check if support current platform
15+
func (d *ffmpegInstallerInMacOS) Available() (ok bool) {
16+
if runtime.GOOS == "darwin" {
17+
_, err := exec.LookPath("brew")
18+
ok = err == nil
19+
}
20+
return
21+
}
22+
23+
// Install installs the ffmpeg
24+
func (d *ffmpegInstallerInMacOS) Install() (err error) {
25+
err = exec.RunCommand("brew", "install", "ffmpeg")
26+
return
27+
}
28+
29+
// Uninstall uninstalls the ffmpeg
30+
func (d *ffmpegInstallerInMacOS) Uninstall() (err error) {
31+
err = exec.RunCommand("brew", "remove", "ffmpeg")
32+
return
33+
}
34+
35+
// WaitForStart waits for the service be started
36+
func (d *ffmpegInstallerInMacOS) WaitForStart() (ok bool, err error) {
37+
ok = true
38+
return
39+
}
40+
41+
// Start starts the ffmpeg service
42+
func (d *ffmpegInstallerInMacOS) Start() error {
43+
fmt.Println("not supported yet")
44+
return nil
45+
}
46+
47+
// Stop stops the ffmpeg service
48+
func (d *ffmpegInstallerInMacOS) Stop() error {
49+
fmt.Println("not supported yet")
50+
return nil
51+
}

pkg/os/brew/init.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,5 @@ func SetInstallerRegistry(registry core.InstallerRegistry) {
77
registry.Registry("vim", &vimInstallerInMacOS{})
88
registry.Registry("bash-completion", &vimInstallerInMacOS{})
99
registry.Registry("asciinema", &asciinemaInstallerInMacOS{})
10+
registry.Registry("ffmpge", &ffmpegInstallerInMacOS{})
1011
}

0 commit comments

Comments
 (0)