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
This commit is contained in:
parent
b3955bd81e
commit
066e018749
113 changed files with 19002 additions and 1541 deletions
148
apps/modules/c4/c4.go
Normal file
148
apps/modules/c4/c4.go
Normal file
|
|
@ -0,0 +1,148 @@
|
|||
// Package c4 is the Channel 4 (All 4) Live TV provider module.
|
||||
// Live list rows use content-desc "Select to watch Channel Four" / "E Four" / etc.
|
||||
package c4
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"os"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"drmdecryption/adb"
|
||||
appreg "drmdecryption/app"
|
||||
"drmdecryption/capture"
|
||||
"drmdecryption/modules/provider"
|
||||
"drmdecryption/mpd"
|
||||
"drmdecryption/uiflow"
|
||||
)
|
||||
|
||||
func init() {
|
||||
appreg.Register(Name, New)
|
||||
appreg.RegisterFlags(bindFlags)
|
||||
}
|
||||
|
||||
func bindFlags(fs *flag.FlagSet) {
|
||||
fs.StringVar(&flags.packageName, Name+".package", "", "override "+Name+" android package id")
|
||||
fs.StringVar(&flags.caHash, Name+".ca-hash", "", "override "+Name+" MITM CA subject hash")
|
||||
fs.StringVar(&flags.proxyBin, Name+".proxy-bin", "", "override "+Name+" on-device MITM binary")
|
||||
}
|
||||
|
||||
// App is the Channel 4 plugin.
|
||||
type App struct {
|
||||
*provider.Base
|
||||
cfg Config
|
||||
}
|
||||
|
||||
// New constructs the plugin from module.yaml + flags + env.
|
||||
func New() (appreg.App, error) {
|
||||
cfg, res, err := loadConfig()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
labels := make(map[string]string, len(cfg.Channels))
|
||||
for id, ch := range cfg.Channels {
|
||||
labels[id] = ch.Label
|
||||
}
|
||||
return &App{Base: provider.New(Name, cfg.Common, labels, res), cfg: cfg}, nil
|
||||
}
|
||||
|
||||
// KeyMode: Channel 4 / RedBee needs the phone's JSON license POST (token +
|
||||
// challenge). Capture stores that body; wvkey --mode wrap re-issues it.
|
||||
func (a *App) KeyMode() string { return "wrap" }
|
||||
|
||||
// RequireWVD: C4 live is always encrypted — refuse MPD-only captures.
|
||||
func (a *App) RequireWVD() bool { return true }
|
||||
|
||||
// CaptureHints: need the DASH MPD and the phone's RedBee license POST body
|
||||
// (token + challenge). MPD alone is not enough for keys.
|
||||
func (a *App) CaptureHints() capture.Hints {
|
||||
return a.Hints("mpd", "license_body")
|
||||
}
|
||||
|
||||
// CaptureHintsFor prefers the simulcast path for this live channel so a
|
||||
// neighbouring Auto-play / prefetch MPD does not win the Wait score race.
|
||||
func (a *App) CaptureHintsFor(channel string) capture.Hints {
|
||||
h := a.CaptureHints()
|
||||
id, err := a.Resolve(channel)
|
||||
if err != nil {
|
||||
id = strings.ToLower(strings.TrimSpace(channel))
|
||||
}
|
||||
prefer := map[string]string{
|
||||
"channel4": "channel(c4)",
|
||||
"e4": "channel(e4)",
|
||||
"more4": "channel(m4)",
|
||||
"film4": "channel(f4)",
|
||||
"fourseven": "channel(4s)",
|
||||
}
|
||||
if p, ok := prefer[id]; ok {
|
||||
h.PreferURLContains = []string{p}
|
||||
}
|
||||
return h
|
||||
}
|
||||
|
||||
// UseTransparentMITM: UK VPN on-device conflicts with Wi‑Fi http_proxy.
|
||||
func (a *App) UseTransparentMITM() bool { return true }
|
||||
|
||||
func (a *App) MPDRewriter() mpd.Rewriter { return mpd.Passthrough{} }
|
||||
|
||||
func (a *App) Channels() []appreg.Channel {
|
||||
out := make([]appreg.Channel, 0, len(a.cfg.Channels))
|
||||
for _, id := range a.ChannelIDs() {
|
||||
out = append(out, appreg.Channel{ID: id, Label: a.Label(id)})
|
||||
}
|
||||
return out
|
||||
}
|
||||
|
||||
// Launch cold-starts Channel 4.
|
||||
func (a *App) Launch(c *adb.Client) error {
|
||||
c.EnsureAwake()
|
||||
fmt.Printf("[*] Launching %s (%s)…\n", Name, a.Package())
|
||||
c.ForceStop(a.Package())
|
||||
time.Sleep(400 * time.Millisecond)
|
||||
if err := uiflow.MonkeyLaunch(c, a.Package()); err != nil {
|
||||
return err
|
||||
}
|
||||
time.Sleep(time.Duration(a.cfg.Timeouts.LaunchSettle))
|
||||
c.DismissShadeIfFocused()
|
||||
if err := uiflow.WaitUI(c, a.CacheDir(), uiflow.Match{
|
||||
DescContains: a.cfg.UI.LaunchDescContains,
|
||||
TextContains: a.cfg.UI.LaunchDescContains,
|
||||
}, time.Duration(a.cfg.Timeouts.LaunchWaitUI)); err != nil {
|
||||
fmt.Fprintf(os.Stderr, "[!] launch UI wait: %v — continue and play manually\n", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// AutoPlay opens Live TV, scrolls to the channel card, and taps Select to watch.
|
||||
func (a *App) AutoPlay(c *adb.Client, channel string) error {
|
||||
id, err := a.Resolve(channel)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
ch := a.cfg.Channels[id]
|
||||
fmt.Printf("[*] Auto-play %s…\n", a.Label(id))
|
||||
c.DismissShadeIfFocused()
|
||||
|
||||
if err := a.openLiveTab(c); err != nil {
|
||||
return fmt.Errorf("Live TV tab: %w", err)
|
||||
}
|
||||
if err := a.tapChannelCard(c, ch); err != nil {
|
||||
return fmt.Errorf("channel play %s: %w", a.Label(id), err)
|
||||
}
|
||||
return uiflow.WaitPlayback(c, a.CacheDir(), a.Package(), uiflow.PlaybackOpts{
|
||||
Timeout: time.Duration(a.cfg.Timeouts.Playback),
|
||||
SoftFail: true,
|
||||
OrDescContains: []string{
|
||||
"Pause",
|
||||
"Unmute",
|
||||
"Cast",
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
func (a *App) VideoSelect() string { return "for=best" }
|
||||
func (a *App) AudioSelect() string { return "for=best" }
|
||||
func (a *App) RewriterName() string { return "none" }
|
||||
func (a *App) LiveWaitSeconds() int { return 2 }
|
||||
func (a *App) TSReadyBytes() int64 { return 256 << 10 }
|
||||
116
apps/modules/c4/config.go
Normal file
116
apps/modules/c4/config.go
Normal file
|
|
@ -0,0 +1,116 @@
|
|||
package c4
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"drmdecryption/modcfg"
|
||||
"drmdecryption/modules/provider"
|
||||
)
|
||||
|
||||
// Name is the module id (--app c4).
|
||||
const Name = "c4"
|
||||
|
||||
// Channel is one Channel 4 Live TV target.
|
||||
type Channel struct {
|
||||
Label string `yaml:"label"`
|
||||
ChipDesc []string `yaml:"chip_desc"`
|
||||
PlayDesc []string `yaml:"play_desc"`
|
||||
}
|
||||
|
||||
// Config is modules/c4/module.yaml (preferred) or apps/modules/c4/module.yaml.
|
||||
type Config struct {
|
||||
provider.Common `yaml:",inline"`
|
||||
|
||||
Channels map[string]Channel `yaml:"channels"`
|
||||
Timeouts Timeouts `yaml:"timeouts"`
|
||||
UI UI `yaml:"ui"`
|
||||
}
|
||||
|
||||
type Timeouts struct {
|
||||
LaunchWaitUI provider.Duration `yaml:"launch_wait_ui"`
|
||||
LaunchSettle provider.Duration `yaml:"launch_settle"`
|
||||
LiveNav provider.Duration `yaml:"live_nav"`
|
||||
ChannelFind provider.Duration `yaml:"channel_find"`
|
||||
AfterChannel provider.Duration `yaml:"after_channel"`
|
||||
WatchLive provider.Duration `yaml:"watch_live"`
|
||||
Playback provider.Duration `yaml:"playback"`
|
||||
}
|
||||
|
||||
type UI struct {
|
||||
LaunchDescContains []string `yaml:"launch_desc_contains"`
|
||||
LiveTab []string `yaml:"live_tab"`
|
||||
LiveTabDescRE []string `yaml:"live_tab_desc_re"`
|
||||
LiveTabTextRE []string `yaml:"live_tab_text_re"`
|
||||
WatchLive []string `yaml:"watch_live"`
|
||||
PlaybackDescContains []string `yaml:"playback_desc_contains"`
|
||||
ChannelScrollMax int `yaml:"channel_scroll_max"`
|
||||
}
|
||||
|
||||
func (c Config) withDefaults() Config {
|
||||
t := &c.Timeouts
|
||||
t.LaunchWaitUI = provider.Duration(t.LaunchWaitUI.D(30 * time.Second))
|
||||
t.LaunchSettle = provider.Duration(t.LaunchSettle.D(5 * time.Second))
|
||||
t.LiveNav = provider.Duration(t.LiveNav.D(20 * time.Second))
|
||||
t.ChannelFind = provider.Duration(t.ChannelFind.D(45 * time.Second))
|
||||
t.AfterChannel = provider.Duration(t.AfterChannel.D(2 * time.Second))
|
||||
t.WatchLive = provider.Duration(t.WatchLive.D(20 * time.Second))
|
||||
t.Playback = provider.Duration(t.Playback.D(45 * time.Second))
|
||||
|
||||
u := &c.UI
|
||||
if len(u.LaunchDescContains) == 0 {
|
||||
u.LaunchDescContains = []string{"Home", "Live TV", "My Shows", "Downloads", "Search"}
|
||||
}
|
||||
if len(u.LiveTab) == 0 {
|
||||
u.LiveTab = []string{"Live TV"}
|
||||
}
|
||||
if len(u.LiveTabDescRE) == 0 {
|
||||
u.LiveTabDescRE = []string{`(?i)^Live TV$`}
|
||||
}
|
||||
if len(u.LiveTabTextRE) == 0 {
|
||||
u.LiveTabTextRE = []string{`(?i)^Live TV$`}
|
||||
}
|
||||
if len(u.WatchLive) == 0 {
|
||||
u.WatchLive = []string{"Select to watch", "Play Episode", "Restart"}
|
||||
}
|
||||
if len(u.PlaybackDescContains) == 0 {
|
||||
u.PlaybackDescContains = []string{"Pause", "Unmute", "Cast", "Subtitles"}
|
||||
}
|
||||
if u.ChannelScrollMax <= 0 {
|
||||
u.ChannelScrollMax = 10
|
||||
}
|
||||
if c.Package == "" {
|
||||
c.Package = "com.channel4.ondemand"
|
||||
}
|
||||
if c.Channels == nil {
|
||||
c.Channels = map[string]Channel{}
|
||||
}
|
||||
return c
|
||||
}
|
||||
|
||||
func loadConfig() (Config, modcfg.Result, error) {
|
||||
var cfg Config
|
||||
res, err := modcfg.Load(Name, &cfg)
|
||||
if err != nil {
|
||||
return cfg, res, err
|
||||
}
|
||||
cfg = cfg.withDefaults()
|
||||
if v := modcfg.Env(Name, "package"); v != "" {
|
||||
cfg.Package = v
|
||||
}
|
||||
if flags.packageName != "" {
|
||||
cfg.Package = flags.packageName
|
||||
}
|
||||
if flags.caHash != "" {
|
||||
cfg.CAHash = flags.caHash
|
||||
}
|
||||
if flags.proxyBin != "" {
|
||||
cfg.ProxyBin = flags.proxyBin
|
||||
}
|
||||
return cfg, res, nil
|
||||
}
|
||||
|
||||
var flags struct {
|
||||
packageName string
|
||||
caHash string
|
||||
proxyBin string
|
||||
}
|
||||
84
apps/modules/c4/module-publish.yaml
Normal file
84
apps/modules/c4/module-publish.yaml
Normal file
|
|
@ -0,0 +1,84 @@
|
|||
# Channel 4 (All 4) — published universal values (renamed to module.yaml in release zips).
|
||||
# Live cards: content-desc "Select to watch Channel Four" / "E Four" / "More Four" / …
|
||||
|
||||
package: com.channel4.ondemand
|
||||
proxy_bin: bin/proxy-android-arm64
|
||||
|
||||
# SENSITIVE — set in local module.yaml:
|
||||
# license_url: "https://c4.eme.lp.aws.redbeemedia.com/wvlicenceproxy-service/widevine/acquire"
|
||||
|
||||
# Transparent mode only MITMs open.live by default. Force C4 playlist / license hosts.
|
||||
mitm_hosts:
|
||||
- c4assets.com
|
||||
- olsp.live.dash.c4assets.com
|
||||
- stream.c4assets.com
|
||||
- channel4.com
|
||||
- api.channel4.com
|
||||
- c4.eme.lp.aws.redbeemedia.com
|
||||
- redbeemedia.com
|
||||
- all4nav.channel4.com
|
||||
|
||||
score:
|
||||
hosts:
|
||||
- c4assets.com
|
||||
- olsp.live.dash.c4assets.com
|
||||
- stream.c4assets.com
|
||||
- channel4.com
|
||||
- api.channel4.com
|
||||
- redbeemedia.com
|
||||
- akamaized.net
|
||||
deny:
|
||||
- google-analytics
|
||||
- googletagmanager
|
||||
- doubleclick
|
||||
- scorecardresearch
|
||||
- facebook.com
|
||||
- crashlytics
|
||||
- appsflyer
|
||||
- optimizely
|
||||
|
||||
aliases:
|
||||
c4: channel4
|
||||
four: channel4
|
||||
ch4: channel4
|
||||
channel: channel4
|
||||
e: e4
|
||||
more: more4
|
||||
film: film4
|
||||
"4seven": fourseven
|
||||
seven: fourseven
|
||||
|
||||
channels:
|
||||
channel4:
|
||||
label: Channel Four
|
||||
chip_desc: ["(?i)Select to watch\\s+Channel Four"]
|
||||
e4:
|
||||
label: E Four
|
||||
chip_desc: ["(?i)Select to watch\\s+E Four"]
|
||||
more4:
|
||||
label: More Four
|
||||
chip_desc: ["(?i)Select to watch\\s+More Four"]
|
||||
film4:
|
||||
label: Film Four
|
||||
chip_desc: ["(?i)Select to watch\\s+Film Four"]
|
||||
fourseven:
|
||||
label: Four Seven
|
||||
chip_desc: ["(?i)Select to watch\\s+Four Seven"]
|
||||
|
||||
ui:
|
||||
launch_desc_contains: ["Home", "Live TV", "My Shows", "Downloads", "Search"]
|
||||
live_tab: ["Live TV"]
|
||||
live_tab_desc_re: ["(?i)^Live TV$"]
|
||||
live_tab_text_re: ["(?i)^Live TV$"]
|
||||
watch_live: ["Select to watch", "Play Episode"]
|
||||
playback_desc_contains: ["Pause", "Unmute", "Cast"]
|
||||
channel_scroll_max: 16
|
||||
|
||||
timeouts:
|
||||
launch_wait_ui: 30s
|
||||
launch_settle: 5s
|
||||
live_nav: 20s
|
||||
channel_find: 45s
|
||||
after_channel: 2s
|
||||
watch_live: 20s
|
||||
playback: 45s
|
||||
175
apps/modules/c4/steps.go
Normal file
175
apps/modules/c4/steps.go
Normal file
|
|
@ -0,0 +1,175 @@
|
|||
package c4
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"regexp"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"drmdecryption/adb"
|
||||
"drmdecryption/uiflow"
|
||||
)
|
||||
|
||||
func (a *App) openLiveTab(c *adb.Client) error {
|
||||
c.DismissShadeIfFocused()
|
||||
if nodes, err := c.DumpUI(a.CacheDir()); err == nil && a.onLiveTab(nodes) {
|
||||
fmt.Println("[*] already on Live TV")
|
||||
return nil
|
||||
}
|
||||
|
||||
fmt.Println("[*] open Live TV…")
|
||||
descRE := a.cfg.UI.LiveTabDescRE
|
||||
if len(descRE) == 0 {
|
||||
descRE = []string{`(?i)^Live TV$`}
|
||||
}
|
||||
textRE := a.cfg.UI.LiveTabTextRE
|
||||
if len(textRE) == 0 {
|
||||
textRE = []string{`(?i)^Live TV$`}
|
||||
}
|
||||
if err := uiflow.TapUI(c, a.CacheDir(), uiflow.Match{
|
||||
DescRE: descRE,
|
||||
TextRE: textRE,
|
||||
DescContains: a.cfg.UI.LiveTab,
|
||||
TextContains: a.cfg.UI.LiveTab,
|
||||
Pick: uiflow.PickFirst,
|
||||
}, time.Duration(a.cfg.Timeouts.LiveNav)); err != nil {
|
||||
return fmt.Errorf("live tab: %w", err)
|
||||
}
|
||||
time.Sleep(1500 * time.Millisecond)
|
||||
|
||||
deadline := time.Now().Add(time.Duration(a.cfg.Timeouts.LiveNav))
|
||||
for time.Now().Before(deadline) {
|
||||
nodes, err := c.DumpUI(a.CacheDir())
|
||||
if err == nil && a.onLiveTab(nodes) {
|
||||
fmt.Println("[*] Live TV ready")
|
||||
a.disableLiveAutoPlay(c)
|
||||
return nil
|
||||
}
|
||||
time.Sleep(700 * time.Millisecond)
|
||||
}
|
||||
return fmt.Errorf("Live TV did not open")
|
||||
}
|
||||
|
||||
// disableLiveAutoPlay turns off the Live TV "Auto-play" toggle so the app does
|
||||
// not advance to the next channel while we wait for MITM.
|
||||
func (a *App) disableLiveAutoPlay(c *adb.Client) {
|
||||
nodes, err := c.DumpUI(a.CacheDir())
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
for _, n := range nodes {
|
||||
d := strings.ToLower(strings.TrimSpace(n.Desc))
|
||||
t := strings.ToLower(strings.TrimSpace(n.Text))
|
||||
if d != "auto-play" && t != "auto-play" {
|
||||
continue
|
||||
}
|
||||
if n.Selected || n.Checked {
|
||||
fmt.Println("[*] disable Live Auto-play")
|
||||
_ = c.Tap(n.CX(), n.CY())
|
||||
time.Sleep(500 * time.Millisecond)
|
||||
return
|
||||
}
|
||||
// State may not be exposed — leave alone when already off / unknown.
|
||||
fmt.Println("[*] Live Auto-play control present (left as-is)")
|
||||
return
|
||||
}
|
||||
}
|
||||
|
||||
func (a *App) onLiveTab(nodes []adb.Node) bool {
|
||||
for _, n := range nodes {
|
||||
d := strings.ToLower(n.Desc)
|
||||
if strings.Contains(d, "select to watch") {
|
||||
return true
|
||||
}
|
||||
if strings.Contains(d, "now showing on") {
|
||||
return true
|
||||
}
|
||||
if strings.EqualFold(n.Desc, "Live TV, heading") || strings.EqualFold(n.Text, "On now") {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// tapChannelCard scrolls the Live list for "Select to watch {Label}" and taps it.
|
||||
func (a *App) tapChannelCard(c *adb.Client, ch Channel) error {
|
||||
pats := ch.ChipDesc
|
||||
if len(pats) == 0 {
|
||||
pats = []string{`(?i)Select to watch\s+` + regexp.QuoteMeta(ch.Label)}
|
||||
}
|
||||
chipRE := uiflow.CompileRes(pats)
|
||||
fmt.Printf("[*] find Live card for %s…\n", ch.Label)
|
||||
|
||||
row, err := a.findChannelCard(c, chipRE)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
fmt.Printf("[*] tap %q @ %d,%d\n", trimDesc(row.Desc, 60), row.CX(), row.CY())
|
||||
if err := c.Tap(row.CX(), row.CY()); err != nil {
|
||||
return err
|
||||
}
|
||||
time.Sleep(time.Duration(a.cfg.Timeouts.AfterChannel))
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a *App) findChannelCard(c *adb.Client, chipRE []*regexp.Regexp) (*adb.Node, error) {
|
||||
scrollMax := a.cfg.UI.ChannelScrollMax
|
||||
if scrollMax <= 0 {
|
||||
scrollMax = 10
|
||||
}
|
||||
// Prefer starting near the top so Channel Four / E4 are reachable.
|
||||
_ = c.Swipe(540, 1100, 540, 1900, 250)
|
||||
time.Sleep(400 * time.Millisecond)
|
||||
|
||||
for attempt := 0; attempt <= scrollMax; attempt++ {
|
||||
nodes, err := c.DumpUI(a.CacheDir())
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
var best *adb.Node
|
||||
for i := range nodes {
|
||||
n := &nodes[i]
|
||||
hay := n.Desc
|
||||
if hay == "" {
|
||||
hay = n.Text
|
||||
}
|
||||
if hay == "" {
|
||||
continue
|
||||
}
|
||||
// Skip cards clipped into the bottom nav (false taps).
|
||||
if n.Y2 > 2100 || n.CY() > 2050 {
|
||||
continue
|
||||
}
|
||||
for _, p := range chipRE {
|
||||
if !p.MatchString(hay) {
|
||||
continue
|
||||
}
|
||||
// Prefer the explicit "Select to watch" control when present.
|
||||
if strings.Contains(strings.ToLower(hay), "select to watch") {
|
||||
return n, nil
|
||||
}
|
||||
if best == nil {
|
||||
best = n
|
||||
}
|
||||
}
|
||||
}
|
||||
if best != nil {
|
||||
return best, nil
|
||||
}
|
||||
if attempt == scrollMax {
|
||||
break
|
||||
}
|
||||
fmt.Printf("[*] scroll Live list (%d/%d)…\n", attempt+1, scrollMax)
|
||||
_ = c.Swipe(540, 1950, 540, 900, 320)
|
||||
time.Sleep(700 * time.Millisecond)
|
||||
}
|
||||
return nil, fmt.Errorf("channel card not found")
|
||||
}
|
||||
|
||||
func trimDesc(s string, n int) string {
|
||||
s = strings.TrimSpace(s)
|
||||
if len(s) <= n {
|
||||
return s
|
||||
}
|
||||
return s[:n] + "…"
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue