Some checks failed
release / build-and-upload (push) Failing after 3m33s
- WebUI Copy button for absolute m3u8 URLs (no player) - Per-stream variants ladder; HD/SD live-transcoded as sibling HLS - variants_json in DB/API; supervisor spawns scaled ffmpeg packagers
54 lines
1.1 KiB
Go
54 lines
1.1 KiB
Go
package api
|
|
|
|
import (
|
|
"os"
|
|
"path/filepath"
|
|
"strings"
|
|
"time"
|
|
|
|
"drmdecryption/apps/streamd/internal/db"
|
|
)
|
|
|
|
// enrichVariantHealth updates each variant's health from on-disk HLS playlists.
|
|
func (h *Handler) enrichVariantHealth(st *db.Stream) {
|
|
if st == nil {
|
|
return
|
|
}
|
|
if len(st.Variants) == 0 {
|
|
st.Variants = db.AttachVariantStatuses(st.Name, st.VariantsJSON, st.Health, st.PlaylistAgeS)
|
|
}
|
|
www := strings.TrimSpace(h.WWWRoot)
|
|
if www == "" {
|
|
return
|
|
}
|
|
for i := range st.Variants {
|
|
v := &st.Variants[i]
|
|
if !v.Enabled {
|
|
v.Health = "off"
|
|
continue
|
|
}
|
|
if v.Height <= 0 {
|
|
v.Health = st.Health
|
|
v.PlaylistAgeS = st.PlaylistAgeS
|
|
continue
|
|
}
|
|
dirName := st.Name + "-" + v.ID
|
|
index := filepath.Join(www, dirName, "index.m3u8")
|
|
fi, err := os.Stat(index)
|
|
if err != nil {
|
|
if st.Health == "ok" || st.Health == "starting" {
|
|
v.Health = "starting"
|
|
} else {
|
|
v.Health = st.Health
|
|
}
|
|
continue
|
|
}
|
|
age := time.Since(fi.ModTime()).Seconds()
|
|
v.PlaylistAgeS = age
|
|
if age > 45 {
|
|
v.Health = "down"
|
|
} else {
|
|
v.Health = "ok"
|
|
}
|
|
}
|
|
}
|