diff --git a/transcoder/go.mod b/transcoder/go.mod index 1daf251d..f3923aaa 100644 --- a/transcoder/go.mod +++ b/transcoder/go.mod @@ -4,7 +4,7 @@ go 1.20 require ( github.com/golang-jwt/jwt v3.2.2+incompatible // indirect - github.com/labstack/echo/v4 v4.11.4 // indirect + github.com/labstack/echo/v4 v4.11.4 // direct github.com/labstack/gommon v0.4.2 // indirect github.com/mattn/go-colorable v0.1.13 // indirect github.com/mattn/go-isatty v0.0.20 // indirect diff --git a/transcoder/main.go b/transcoder/main.go index 6d983d43..0a47cb33 100644 --- a/transcoder/main.go +++ b/transcoder/main.go @@ -23,7 +23,7 @@ func DirectStream(c echo.Context) error { if err != nil { return err } - return c.File(*path) + return c.File(path) } // Get master playlist @@ -47,7 +47,7 @@ func (h *Handler) GetMaster(c echo.Context) error { return err } - ret, err := h.transcoder.GetMaster(*path, *client) + ret, err := h.transcoder.GetMaster(path, client) if err != nil { return err } diff --git a/transcoder/transcoder/filestream.go b/transcoder/transcoder/filestream.go index b72cb7f7..3599a02d 100644 --- a/transcoder/transcoder/filestream.go +++ b/transcoder/transcoder/filestream.go @@ -95,3 +95,7 @@ func (fs *FileStream) IsDead() bool { } return false } + +func (fs *FileStream) GetMaster() string { + return "" +} diff --git a/transcoder/transcoder/transcoder.go b/transcoder/transcoder/transcoder.go index c6c76bd6..9af4e254 100644 --- a/transcoder/transcoder/transcoder.go +++ b/transcoder/transcoder/transcoder.go @@ -5,14 +5,14 @@ type Transcoder struct { streams map[string]FileStream } -func (t *Transcoder) GetMaster(path string, client string) (*string, error) { +func (t *Transcoder) GetMaster(path string, client string) (string, error) { stream, ok := t.streams[path] if !ok { stream, err := NewFileStream(path) if err != nil { - return nil, err + return "", err } t.streams[path] = *stream } - return &stream.GetMaster() + return stream.GetMaster(), nil } diff --git a/transcoder/utils.go b/transcoder/utils.go index 49288ef1..5691e03e 100644 --- a/transcoder/utils.go +++ b/transcoder/utils.go @@ -18,29 +18,29 @@ type Item struct { Path string `json:"path"` } -func GetPath(resource string, slug string) (*string, error) { +func GetPath(resource string, slug string) (string, error) { url := os.Getenv("API_URL") if url == "" { url = "http://back:5000" } key := os.Getenv("KYOO_APIKEYS") if key == "" { - return nil, errors.New("missing api keys") + return "", errors.New("missing api keys") } key = strings.Split(key, ",")[0] req, err := http.NewRequest("GET", strings.Join([]string{url, resource, slug}, "/"), nil) if err != nil { - return nil, err + return "", err } req.Header.Set("X-API-KEY", key) res, err := client.Do(req) if err != nil { - return nil, err + return "", err } if res.StatusCode != 200 { - return nil, echo.NewHTTPError( + return "", echo.NewHTTPError( http.StatusNotAcceptable, fmt.Sprintf("No %s found with the slug %s.", resource, slug), ) @@ -50,18 +50,18 @@ func GetPath(resource string, slug string) (*string, error) { ret := Item{} err = json.NewDecoder(res.Body).Decode(&ret) if err != nil { - return nil, err + return "", err } - return &ret.Path, nil + return ret.Path, nil } -func GetClientId(c echo.Context) (*string, error) { +func GetClientId(c echo.Context) (string, error) { key := c.Request().Header.Get("X-CLIENT-ID") if key == "" { - return nil, errors.New("Missing client id. Please specify the X-CLIENT-ID header to a guid constant for the lifetime of the player (but unique per instance).") + return "", errors.New("missing client id. Please specify the X-CLIENT-ID header to a guid constant for the lifetime of the player (but unique per instance)") } - return &key, nil + return key, nil } func ErrorHandler(err error, c echo.Context) {