Null-DRM-Official/apps/cli/main.go
404errordeveloper 066e018749
All checks were successful
release / build-and-upload (push) Successful in 6m18s
modules-release / build-and-upload (push) Successful in 5m18s
streamd: preview quality picker, dashboard polish, C4 wrap keys
- 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
2026-10-09 20:57:43 +02:00

124 lines
3.5 KiB
Go

// Command drm is the single entry point for the toolchain: phone capture,
// catalog lookups, the always-on agent, the streamd control plane and the
// on-device MITM. Providers live under modules/<name>/ and are discovered,
// built, and executed by the host — they are not linked into this binary.
package main
import (
// The scheduler resolves IANA zone names so a weekly event stays at its
// local wall-clock time. Windows ships no zone database, so embed one.
_ "time/tzdata"
"fmt"
"os"
"strings"
"drmdecryption/apps/agent/agentcmd"
"drmdecryption/apps/capture/capturecmd"
"drmdecryption/apps/cli/catalogcmd"
"drmdecryption/apps/cli/modulescmd"
"drmdecryption/apps/proxy/proxyctlcmd"
"drmdecryption/apps/streamd/servecmd"
"drmdecryption/bootstrap"
"drmdecryption/modhost"
)
func main() {
args := os.Args[1:]
modulesDir, args := peelGlobalFlags(args)
if len(args) < 1 {
usage()
os.Exit(2)
}
cmd, args := args[0], args[1:]
if modulesDir != "" {
if err := modhost.SetModulesDir(modulesDir); err != nil {
fmt.Fprintln(os.Stderr, "[!] --modules-dir:", err)
os.Exit(1)
}
} else if err := modhost.ApplyEnvModulesDir(); err != nil {
fmt.Fprintln(os.Stderr, "[!] DRM_MODULES_DIR:", err)
os.Exit(1)
}
// Materialise apps/, bin/, modules/, outputs/, … next to this exe when
// missing so a lone downloaded drm.exe becomes a GitHub-like install tree.
if cmd != "help" && cmd != "-h" && cmd != "--help" {
if err := bootstrap.EnsureAndLogFor(cmd); err != nil {
fmt.Fprintln(os.Stderr, "[!] bootstrap:", err)
os.Exit(1)
}
}
var err error
switch cmd {
case "capture":
err = capturecmd.Run(args)
case "catalog":
err = catalogcmd.Run(args)
case "modules":
err = modulescmd.Run(args)
case "agent":
err = agentcmd.Run(args)
case "serve":
err = servecmd.Run(append([]string{"serve"}, args...))
case "proxy":
err = proxyctlcmd.Run(args)
case "help", "-h", "--help":
usage()
return
default:
usage()
err = fmt.Errorf("unknown command %q", cmd)
}
if err != nil {
fmt.Fprintln(os.Stderr, "[!]", err)
os.Exit(1)
}
}
// peelGlobalFlags extracts host-level flags that may appear before the subcommand.
func peelGlobalFlags(args []string) (modulesDir string, rest []string) {
rest = make([]string, 0, len(args))
for i := 0; i < len(args); i++ {
a := args[i]
switch {
case a == "--modules-dir" || a == "-modules-dir":
if i+1 >= len(args) {
fmt.Fprintln(os.Stderr, "[!] --modules-dir requires a path")
os.Exit(2)
}
modulesDir = args[i+1]
i++
case strings.HasPrefix(a, "--modules-dir="):
modulesDir = strings.TrimPrefix(a, "--modules-dir=")
default:
rest = append(rest, a)
}
}
return modulesDir, rest
}
func usage() {
fmt.Fprint(os.Stderr, `drm — DRM capture / restream toolchain
Usage:
drm [--modules-dir DIR] modules
drm [--modules-dir DIR] capture --app NAME [--channel ID | --all] [--wvd PATH]
drm [--modules-dir DIR] catalog --app NAME --channel ID [--keys] [--json]
drm agent run|status|devices|enqueue|cancel [--config …]
drm serve [--bind …] [--data …] [--token …]
drm proxy build|push|install-ca|start|stop|reset|discover|pull|clear-proxy|transparent
Global flags:
--modules-dir DIR provider folder (default: <install>/modules, or $DRM_MODULES_DIR)
Providers live under modules/<name>/ (Go source + module-publish.yaml).
Local module.yaml holds secrets and is never published; release zips ship
module-publish.yaml renamed to module.yaml. The host builds modules on demand.
Run any subcommand with --help for its own flags.
`)
}