Capture, decrypt, and restream toolkit with compiled-in app modules (RTE, TG4, BBC), on-device MITM proxy, streamd control plane, and www. BBC module.yaml is published (clear streams); other module values stay local.
47 lines
1.3 KiB
Go
47 lines
1.3 KiB
Go
package api
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"drmdecryption/app"
|
|
"drmdecryption/mpd"
|
|
)
|
|
|
|
// appInfo describes one compiled-in app module to the dashboard, so the UI never
|
|
// has to hardcode a provider or channel name.
|
|
type appInfo struct {
|
|
Name string `json:"name"`
|
|
Channels []channelInfo `json:"channels"`
|
|
Rewriter string `json:"rewriter"`
|
|
HasConfig bool `json:"has_config"`
|
|
}
|
|
|
|
type channelInfo struct {
|
|
ID string `json:"id"`
|
|
Label string `json:"label"`
|
|
}
|
|
|
|
// apps answers GET /api/apps: which providers this binary was built with.
|
|
func (h *Handler) apps(w http.ResponseWriter, r *http.Request) {
|
|
if r.Method != http.MethodGet {
|
|
writeErr(w, http.StatusMethodNotAllowed, "method not allowed")
|
|
return
|
|
}
|
|
out := []appInfo{}
|
|
for _, a := range app.All() {
|
|
info := appInfo{Name: a.Name(), Channels: []channelInfo{}, Rewriter: "none"}
|
|
for _, ch := range a.Channels() {
|
|
info.Channels = append(info.Channels, channelInfo{ID: ch.ID, Label: ch.Label})
|
|
}
|
|
// A module with no local values file has no channels to offer yet.
|
|
info.HasConfig = len(info.Channels) > 0
|
|
if sd, ok := a.(app.StreamDefaults); ok {
|
|
info.Rewriter = sd.RewriterName()
|
|
}
|
|
out = append(out, info)
|
|
}
|
|
writeJSON(w, http.StatusOK, map[string]any{
|
|
"apps": out,
|
|
"rewriters": mpd.Names(),
|
|
})
|
|
}
|