streamd: preview quality picker, dashboard polish, C4 wrap keys
All checks were successful
release / build-and-upload (push) Successful in 6m18s
modules-release / build-and-upload (push) Successful in 5m18s

- Preview player can select FHD/HD/SD (or ABR master) from publish links
- Embed dashboard screenshots in README; Linux streamd+agent setup guide
- C4 Widevine wrap license mode + require --wvd; prefer Widevine PSSH
- Channel 4 and My5 modules; streamd auth, variants, schedules, HLS gate
This commit is contained in:
404errordeveloper 2026-10-09 20:57:43 +02:00
parent b3955bd81e
commit 066e018749
113 changed files with 19002 additions and 1541 deletions

View file

@ -3,8 +3,11 @@
package capturecmd
import (
"encoding/json"
"flag"
"fmt"
"os"
"path/filepath"
"strings"
"time"
"unicode"
@ -32,16 +35,17 @@ func Run(args []string) error {
fs := flag.NewFlagSet("capture", flag.ContinueOnError)
appName := fs.String("app", "", "app module under modules/<name>/. Empty = passive MITM, no launch/auto-play")
channel := fs.String("channel", "", "channel id for --auto-play")
autoPlay := fs.Bool("auto-play", false, "auto-navigate to --channel (implied when --channel is set)")
waitSec := fs.Int("wait", 180, "seconds to wait for license/mpd capture")
allChannels := fs.Bool("all", false, "capture every channel declared by the module (grab-all)")
autoPlay := fs.Bool("auto-play", false, "auto-navigate to --channel (implied when --channel / --all is set)")
waitSec := fs.Int("wait", 180, "seconds to wait for license/mpd capture (per channel with --all)")
python := fs.String("python", "", "python for wvkey.py (default: .venv)")
wvd := fs.String("wvd", "", "path to .wvd device file (required for key fetch)")
wvd := fs.String("wvd", "", "path to .wvd device file (required by some apps e.g. c4; MPD-only if omitted)")
userAgent := fs.String("user-agent", "", "optional User-Agent for license requests")
serial := fs.String("serial", "", "adb device serial (default: sole/USB selected device)")
closeApp := fs.Bool("close", true, "force-stop --app when capture finishes (ignored in passive mode)")
keyMode := fs.String("key-mode", "", "override the app's key mode: modulardrm | raw | none")
keyMode := fs.String("key-mode", "", "override the app's key mode: modulardrm | raw | wrap | none")
fs.Usage = func() {
fmt.Fprintf(fs.Output(), "capture — one-shot phone MITM capture\n\nUsage:\n capture --app <%s> [--channel ID] [--auto-play] [--wvd PATH]\n capture (passive: play anything on the phone)\n\nExample (BBC + NordVPN UK):\n capture --app bbc --channel bbcone --wait 120\n\nFlags:\n", appChoices)
fmt.Fprintf(fs.Output(), "capture — one-shot phone MITM capture\n\nUsage:\n capture --app <%s> [--channel ID | --all] [--auto-play] [--wvd PATH]\n capture (passive: play anything on the phone)\n\nExamples:\n capture --app bbc --channel bbcone --wait 120\n capture --app c4 --channel film4 --wvd data/device.wvd\n capture --app c4 --all --wvd data/device.wvd --wait 90\n\nFlags:\n", appChoices)
fs.PrintDefaults()
}
@ -60,6 +64,9 @@ func Run(args []string) error {
// No --app: passive MITM — the operator plays whatever they want and we dump
// whatever DRM traffic appears.
if strings.TrimSpace(*appName) == "" {
if *allChannels {
return fmt.Errorf("--all requires --app")
}
_, err := phonecap.RunPassive(phonecap.Options{
Client: c,
Python: *python,
@ -76,7 +83,26 @@ func Run(args []string) error {
if err != nil {
return modhost.FormatUnknown(root, *appName)
}
if needsWVD(a) && strings.TrimSpace(*wvd) == "" {
return fmt.Errorf("%s requires --wvd PATH (Widevine device file) — encrypted capture cannot be MPD-only", a.Name())
}
channelID := strings.TrimSpace(*channel)
if *allChannels && channelID != "" {
return fmt.Errorf("use either --channel or --all, not both")
}
if *allChannels {
return runAll(root, a, c, phonecap.Options{
App: a,
Client: c,
Python: *python,
WVD: *wvd,
UserAgent: *userAgent,
Wait: time.Duration(*waitSec) * time.Second,
CloseApp: *closeApp,
KeyMode: *keyMode,
ClearProxy: true,
})
}
// --channel implies interactive auto-play (Explore → channel → Watch live).
doAutoPlay := *autoPlay || channelID != ""
if *autoPlay && channelID == "" {
@ -102,6 +128,106 @@ func Run(args []string) error {
return err
}
type channelResult struct {
Channel string `json:"channel"`
Label string `json:"label"`
OK bool `json:"ok"`
MPD string `json:"mpd,omitempty"`
LicenseURL string `json:"license_url,omitempty"`
Key string `json:"key,omitempty"`
Path string `json:"path,omitempty"`
Error string `json:"error,omitempty"`
}
func runAll(root string, a app.App, c *adb.Client, base phonecap.Options) error {
chs := a.Channels()
if len(chs) == 0 {
return fmt.Errorf("no channels configured for %s (%s)", a.Name(), knownChannels(a))
}
fmt.Printf("[*] Grab-all %s — %d channel(s)\n", a.Name(), len(chs))
results := make([]channelResult, 0, len(chs))
okN := 0
for i, ch := range chs {
fmt.Printf("\n======== [%d/%d] %s (%s) ========\n", i+1, len(chs), ch.Label, ch.ID)
opt := base
opt.Channel = ch.ID
opt.NoAutoPlay = false
opt.App = a
opt.Client = c
res, err := phonecap.Run(opt)
row := channelResult{
Channel: ch.ID,
Label: ch.Label,
}
if err != nil {
row.Error = err.Error()
fmt.Fprintf(os.Stderr, "[!] %s: %v\n", ch.ID, err)
} else {
row.OK = res.MPD != ""
row.MPD = res.MPD
row.LicenseURL = res.Session.LicenseURL
row.Key = res.Key
row.Path = res.Path
if row.OK {
okN++
} else {
row.Error = "no mpd"
}
}
results = append(results, row)
if i+1 < len(chs) {
// Let iptables / appproxy fully release before the next transparent start.
time.Sleep(4 * time.Second)
}
}
stamp := time.Now().Format("20060102-150405")
batchDir := filepath.Join(root, "outputs", a.Name(), "all-"+stamp)
_ = os.MkdirAll(batchDir, 0o755)
summaryPath := filepath.Join(batchDir, "SUMMARY.json")
if b, err := json.MarshalIndent(results, "", " "); err == nil {
_ = os.WriteFile(summaryPath, b, 0o644)
}
printAllSummary(a.Name(), results, okN, summaryPath)
if okN == 0 {
return fmt.Errorf("grab-all %s: 0/%d channels captured", a.Name(), len(chs))
}
if okN < len(chs) {
return fmt.Errorf("grab-all %s: %d/%d channels captured (see %s)", a.Name(), okN, len(chs), summaryPath)
}
return nil
}
func printAllSummary(appName string, results []channelResult, okN int, summaryPath string) {
fmt.Println()
fmt.Println("========== GRAB-ALL SUMMARY ==========")
fmt.Printf("app: %s ok: %d/%d\n", appName, okN, len(results))
fmt.Println("--------------------------------------")
fmt.Printf("%-12s %-14s %-6s %s\n", "ID", "LABEL", "OK", "MPD / ERROR")
for _, r := range results {
status := "no"
if r.OK {
status = "yes"
}
detail := r.Error
if r.OK {
detail = trimURL(r.MPD, 72)
}
fmt.Printf("%-12s %-14s %-6s %s\n", r.Channel, r.Label, status, detail)
}
fmt.Println("--------------------------------------")
fmt.Println("summary:", summaryPath)
fmt.Println("======================================")
}
func trimURL(s string, n int) string {
s = strings.TrimSpace(s)
if len(s) <= n {
return s
}
return s[:n] + "…"
}
// normalizeArgs rewrites Unicode dashes Word/Terminal often insert (— – −)
// into ASCII - so `--app` is not silently dropped as a positional token.
func normalizeArgs(args []string) []string {
@ -130,6 +256,13 @@ func normalizeArgs(args []string) []string {
return out
}
func needsWVD(a app.App) bool {
if rw, ok := a.(app.RequireWVD); ok {
return rw.RequireWVD()
}
return false
}
// knownChannels describes what the operator can pick, or where to declare it when
// the module has no local values file yet.
func knownChannels(a app.App) string {