diff --git a/controllers/clips.go b/controllers/clips.go index e1fc3bd35..29eec3a8a 100644 --- a/controllers/clips.go +++ b/controllers/clips.go @@ -7,12 +7,18 @@ import ( "net/http" "strings" + "github.com/owncast/owncast/config" "github.com/owncast/owncast/replays" log "github.com/sirupsen/logrus" ) // GetAllClips will return all clips that have been previously created. func GetAllClips(w http.ResponseWriter, r *http.Request) { + if !config.EnableReplayFeatures { + w.WriteHeader(http.StatusNotFound) + return + } + clips, err := replays.GetAllClips() if err != nil { log.Errorln(err) @@ -25,6 +31,11 @@ func GetAllClips(w http.ResponseWriter, r *http.Request) { // AddClip will create a new clip for a given stream and time window. func AddClip(w http.ResponseWriter, r *http.Request) { + if !config.EnableReplayFeatures { + w.WriteHeader(http.StatusNotFound) + return + } + type addClipRequest struct { StreamId string `json:"streamId"` ClipTitle string `json:"clipTitle"` @@ -95,6 +106,11 @@ func AddClip(w http.ResponseWriter, r *http.Request) { // GetClip will return playable content for a given clip Id. func GetClip(w http.ResponseWriter, r *http.Request) { + if !config.EnableReplayFeatures { + w.WriteHeader(http.StatusNotFound) + return + } + pathComponents := strings.Split(r.URL.Path, "/") if len(pathComponents) == 3 { // Return the master playlist for the requested stream diff --git a/controllers/replays.go b/controllers/replays.go index 9bd94cd02..fea79bcb2 100644 --- a/controllers/replays.go +++ b/controllers/replays.go @@ -4,12 +4,18 @@ import ( "net/http" "strings" + "github.com/owncast/owncast/config" "github.com/owncast/owncast/replays" log "github.com/sirupsen/logrus" ) // GetReplays will return a list of all available replays. func GetReplays(w http.ResponseWriter, r *http.Request) { + if !config.EnableReplayFeatures { + w.WriteHeader(http.StatusNotFound) + return + } + streams, err := replays.GetStreams() if err != nil { log.Errorln(err) diff --git a/core/transcoder/hlsHandler.go b/core/transcoder/hlsHandler.go index 8ceee7668..1c55e5675 100644 --- a/core/transcoder/hlsHandler.go +++ b/core/transcoder/hlsHandler.go @@ -23,7 +23,9 @@ func (h *HLSHandler) StreamEnded() { func (h *HLSHandler) SetStreamId(streamId string) { h.Storage.SetStreamId(streamId) - h.Recorder = replays.NewRecording(streamId) + if config.EnableReplayFeatures { + h.Recorder = replays.NewRecording(streamId) + } } // SegmentWritten is fired when a HLS segment is written to disk. diff --git a/replays/hlsRecorder.go b/replays/hlsRecorder.go index c654408ec..764e05f97 100644 --- a/replays/hlsRecorder.go +++ b/replays/hlsRecorder.go @@ -32,6 +32,8 @@ func NewRecording(streamID string) *HLSRecorder { return nil } + log.Infoln("Recording replay of this stream:", streamID) + h := HLSRecorder{ streamID: streamID, startTime: time.Now(),