Null-DRM-Official/modules/itv/main.go
404errordeveloper 2e43e6c3fa
All checks were successful
release / build-and-upload (push) Successful in 6m21s
Add ITVX module, transparent mitm_hosts, and DM Telegram announces.
Wire module mitm_hosts into StartTransparent for ITVX capture, ship the
itv provider stub with Live-list autoplay, refresh the README, and send
Forgejo release announces to private chat 7314901602.
2026-10-09 17:35:53 +02:00

165 lines
3.5 KiB
Go

// Command itv is the external ITVX provider module (stub).
// Built on demand by the drm host: modules/itv/.bin/itv[.exe]
package main
import (
"encoding/json"
"flag"
"fmt"
"os"
"drmdecryption/adb"
appreg "drmdecryption/app"
"drmdecryption/modcfg"
"drmdecryption/modhost"
"drmdecryption/modules/itv"
)
func main() {
if len(os.Args) < 2 {
usage()
os.Exit(2)
}
cmd, args := os.Args[1], os.Args[2:]
var err error
switch cmd {
case "describe":
err = cmdDescribe()
case "launch":
err = cmdLaunch(args)
case "autoplay":
err = cmdAutoplay(args)
case "catalog":
err = cmdCatalog(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)
}
}
func usage() {
fmt.Fprint(os.Stderr, `itv — Null DRM external module (ITVX, stub)
Usage:
itv describe
itv launch [--serial SERIAL]
itv autoplay --channel ID [--serial SERIAL]
itv catalog --channel ID [--json]
`)
}
func loadApp() (appreg.App, error) {
return itv.New()
}
func cmdDescribe() error {
a, err := loadApp()
if err != nil {
return err
}
d := modhost.Describe{
Protocol: modhost.ProtocolVersion,
Name: a.Name(),
Package: a.Package(),
LicenseURL: a.LicenseURL(),
KeyMode: a.KeyMode(),
ProxyBin: a.ProxyBin(),
CAHash: a.CAHash(),
TransparentMITM: true,
Rewriter: "none",
ValuesPath: modcfg.Path(a.Name()),
}
if mh, ok := a.(appreg.MitmHostList); ok {
d.MitmHosts = mh.MitmHosts()
}
if sd, ok := a.(appreg.StreamDefaults); ok {
d.Rewriter = sd.RewriterName()
}
type loaded interface {
ConfigLoaded() bool
ConfigPath() string
}
if L, ok := a.(loaded); ok {
d.ValuesLoaded = L.ConfigLoaded()
if L.ConfigPath() != "" {
d.ValuesPath = L.ConfigPath()
}
}
if _, ok := a.(appreg.Catalog); ok {
d.HasCatalog = true
}
h := a.CaptureHints()
d.Require = h.Require
d.Score = h.Score
for _, ch := range a.Channels() {
d.Channels = append(d.Channels, modhost.Channel{ID: ch.ID, Label: ch.Label})
}
enc := json.NewEncoder(os.Stdout)
enc.SetIndent("", " ")
return enc.Encode(d)
}
func cmdLaunch(args []string) error {
fs := flag.NewFlagSet("launch", flag.ContinueOnError)
serial := fs.String("serial", "", "adb device serial")
if err := fs.Parse(args); err != nil {
return err
}
a, err := loadApp()
if err != nil {
return err
}
c := adb.New()
if *serial != "" {
c = c.WithSerial(*serial)
}
return a.Launch(c)
}
func cmdAutoplay(args []string) error {
fs := flag.NewFlagSet("autoplay", flag.ContinueOnError)
serial := fs.String("serial", "", "adb device serial")
channel := fs.String("channel", "", "channel id")
if err := fs.Parse(args); err != nil {
return err
}
if *channel == "" {
return fmt.Errorf("--channel is required")
}
a, err := loadApp()
if err != nil {
return err
}
c := adb.New()
if *serial != "" {
c = c.WithSerial(*serial)
}
return a.AutoPlay(c, *channel)
}
func cmdCatalog(args []string) error {
fs := flag.NewFlagSet("catalog", flag.ContinueOnError)
channel := fs.String("channel", "", "channel id")
_ = fs.Bool("json", false, "print JSON")
if err := fs.Parse(args); err != nil {
return err
}
if *channel == "" {
return fmt.Errorf("--channel is required")
}
a, err := loadApp()
if err != nil {
return err
}
if _, ok := a.(appreg.Catalog); !ok {
return fmt.Errorf("itv module has no catalog — use phone capture (UK geo)")
}
return fmt.Errorf("itv module has no catalog — use phone capture (UK geo)")
}