40 lines
457 B
Go
40 lines
457 B
Go
|
package ytdl
|
||
|
|
||
|
import (
|
||
|
"bytes"
|
||
|
"os/exec"
|
||
|
"strings"
|
||
|
"sync"
|
||
|
)
|
||
|
|
||
|
var (
|
||
|
version string
|
||
|
versionOnce sync.Once
|
||
|
)
|
||
|
|
||
|
func GetVersion() string {
|
||
|
var err error
|
||
|
versionOnce.Do(func() {
|
||
|
cmd := exec.Command(
|
||
|
"yt-dlp",
|
||
|
"--version",
|
||
|
)
|
||
|
|
||
|
var out bytes.Buffer
|
||
|
cmd.Stdout = &out
|
||
|
|
||
|
err = cmd.Run()
|
||
|
if err != nil {
|
||
|
return
|
||
|
}
|
||
|
|
||
|
version = strings.TrimSpace(out.String())
|
||
|
})
|
||
|
|
||
|
if err != nil {
|
||
|
return "Error getting version"
|
||
|
}
|
||
|
|
||
|
return version
|
||
|
}
|