mirror of
https://github.com/Ernous/TorrServerJellyfin.git
synced 2025-12-19 21:46:11 +05:00
add ffprobe path lookup
This commit is contained in:
@@ -4,14 +4,21 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/gin-gonic/gin"
|
|
||||||
"gopkg.in/vansante/go-ffprobe.v2"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
|
"os/exec"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"server/utils"
|
"server/utils"
|
||||||
|
|
||||||
|
"github.com/gin-gonic/gin"
|
||||||
|
"gopkg.in/vansante/go-ffprobe.v2"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func commandExists(cmd string) bool {
|
||||||
|
_, err := exec.LookPath(cmd)
|
||||||
|
return err == nil
|
||||||
|
}
|
||||||
|
|
||||||
func ffp(c *gin.Context) {
|
func ffp(c *gin.Context) {
|
||||||
hash := c.Param("hash")
|
hash := c.Param("hash")
|
||||||
indexStr := c.Param("id")
|
indexStr := c.Param("id")
|
||||||
@@ -22,13 +29,22 @@ func ffp(c *gin.Context) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
host := utils.GetScheme(c) + "://" + c.Request.Host + "/stream?link=" + hash + "&index=" + indexStr + "&play"
|
host := utils.GetScheme(c) + "://" + c.Request.Host + "/stream?link=" + hash + "&index=" + indexStr + "&play"
|
||||||
fmt.Println(host)
|
// log.Println("ffprobe", host)
|
||||||
|
|
||||||
ctx, cancelFn := context.WithCancel(context.Background())
|
ctx, cancelFn := context.WithCancel(context.Background())
|
||||||
defer cancelFn()
|
defer cancelFn()
|
||||||
|
|
||||||
if _, err := os.Stat("ffprobe"); os.IsNotExist(err) {
|
// path lookup
|
||||||
ffprobe.SetFFProbeBinPath(filepath.Dir(os.Args[0]) + "/ffprobe")
|
path, err := exec.LookPath("ffprobe")
|
||||||
|
if err == nil {
|
||||||
|
// log.Println("ffprobe found in", path)
|
||||||
|
ffprobe.SetFFProbeBinPath(path)
|
||||||
|
} else {
|
||||||
|
// log.Println("ffprobe not found in $PATH")
|
||||||
|
// working dir
|
||||||
|
if _, err := os.Stat("ffprobe"); os.IsNotExist(err) {
|
||||||
|
ffprobe.SetFFProbeBinPath(filepath.Dir(os.Args[0]) + "/ffprobe")
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
data, err := ffprobe.ProbeURL(ctx, host)
|
data, err := ffprobe.ProbeURL(ctx, host)
|
||||||
|
|||||||
Reference in New Issue
Block a user