mirror of
https://github.com/owncast/owncast.git
synced 2024-10-10 19:16:02 +00:00
feat(api): put replay APIs behind feature flag
This commit is contained in:
parent
adb67e79b3
commit
8021c66869
@ -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
|
||||
|
||||
@ -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)
|
||||
|
||||
@ -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.
|
||||
|
||||
@ -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(),
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user