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

@ -23,9 +23,9 @@ func TestAllModulesRegisterAndConstruct(t *testing.T) {
t.Errorf("%s: Name() = %q", n, a.Name())
}
switch a.KeyMode() {
case "raw", "modulardrm", "none":
case "raw", "modulardrm", "wrap", "none":
default:
t.Errorf("%s: KeyMode() = %q, want raw, modulardrm, or none", n, a.KeyMode())
t.Errorf("%s: KeyMode() = %q, want raw, modulardrm, wrap, or none", n, a.KeyMode())
}
if a.CAHash() == "" {
t.Errorf("%s: CAHash() empty", n)
@ -39,6 +39,12 @@ func TestAllModulesRegisterAndConstruct(t *testing.T) {
if a.CaptureHints().RemoteLog == "" {
t.Errorf("%s: CaptureHints has no remote log", n)
}
if n == "c4" {
rw, ok := a.(appreg.RequireWVD)
if !ok || !rw.RequireWVD() {
t.Errorf("c4 must RequireWVD() so capture refuses MPD-only runs")
}
}
}
}

148
apps/modules/c4/c4.go Normal file
View 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
View 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
}

View 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
View 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] + "…"
}

133
apps/modules/my5/config.go Normal file
View file

@ -0,0 +1,133 @@
package my5
import (
"time"
"drmdecryption/modcfg"
"drmdecryption/modules/provider"
)
// Name is the module id (--app my5).
const Name = "my5"
// Channel is one My5 / Channel 5 Live TV target.
// Logos in the Live TV rail have no accessibility text, so selection uses
// logo_index (0-based order in the left channel-logo recycler).
type Channel struct {
Label string `yaml:"label"`
LogoIndex int `yaml:"logo_index"`
ChipDesc []string `yaml:"chip_desc"` // unused; kept for YAML parity with other modules
PlayDesc []string `yaml:"play_desc"`
}
// Config is modules/my5/module.yaml (preferred) or apps/modules/my5/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"`
// LogoMaxX: ImageViews with X1 below this are treated as channel logos.
LogoMaxX int `yaml:"logo_max_x"`
// LogoMinY / LogoMaxY: vertical band of the logos recycler (excludes player + nav).
LogoMinY int `yaml:"logo_min_y"`
LogoMaxY int `yaml:"logo_max_y"`
}
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", "Search", "More", "Milkshake"}
}
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{"Play", "Watch"}
}
if len(u.PlaybackDescContains) == 0 {
u.PlaybackDescContains = []string{"Pause", "Unmute", "Cast", "Subtitles"}
}
if u.ChannelScrollMax <= 0 {
u.ChannelScrollMax = 20
}
if u.LogoMaxX <= 0 {
u.LogoMaxX = 230
}
if u.LogoMinY <= 0 {
u.LogoMinY = 700
}
if u.LogoMaxY <= 0 {
u.LogoMaxY = 2100
}
if c.Package == "" {
c.Package = "com.mobileiq.demand5"
}
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
}

View file

@ -0,0 +1,118 @@
# Channel 5 (My5 / "5") — published universal values (renamed to module.yaml in release zips).
# Live TV left-rail logos have no accessibility text; selection uses logo_index (0-based).
package: com.mobileiq.demand5
proxy_bin: bin/proxy-android-arm64
# SENSITIVE — set in local module.yaml after capture:
# license_url: "https://cassie.channel5.com/api/v2/licences/widevine/…"
# Transparent mode only MITMs open.live by default. Force My5 playlist / license hosts.
mitm_hosts:
- channel5.com
- corona.channel5.com
- cassie.channel5.com
- cassie-auth.channel5.com
- hwdash.channel5.com
- c5apps.channel5.com
score:
hosts:
- channel5.com
- corona.channel5.com
- cassie.channel5.com
- cassie-auth.channel5.com
- hwdash.channel5.com
- akamaized.net
- akadash
deny:
- google-analytics
- googletagmanager
- doubleclick
- scorecardresearch
- facebook.com
- crashlytics
- appsflyer
- optimizely
- kantarmedia
aliases:
c5: channel5
five: channel5
ch5: channel5
channel: channel5
my5: channel5
usa: 5usa
star: 5star
action: 5action
select: 5select
cops: 5cops
christmas: 5christmas
drama: 5drama
crime: 5crime
interceptors: policeinterceptors
pi: policeinterceptors
channels:
# Linear Freeview/Freely channels (logo rail order observed on moto g56).
channel5:
label: Channel 5
logo_index: 0
5usa:
label: 5USA
logo_index: 1
5star:
label: 5STAR
logo_index: 2
5action:
label: 5ACTION
logo_index: 3
5select:
label: 5SELECT
logo_index: 4
# FAST / box-set live rails (indices from Live TV scroll; may shift with seasons).
policeinterceptors:
label: Police Interceptors
logo_index: 5
5cops:
label: 5 Cops
logo_index: 6
5christmas:
label: 5 Christmas
logo_index: 7
5drama:
label: 5 Drama
logo_index: 8
bargainbrits:
label: Bargain Loving Brits
logo_index: 9
casualty247:
label: Casualty 24/7
logo_index: 10
rogueclaimers:
label: Rogue Claimers
logo_index: 11
5crime:
label: 5 Crime
logo_index: 12
ui:
launch_desc_contains: ["Home", "Live TV", "Search", "More", "Milkshake"]
live_tab: ["Live TV"]
live_tab_desc_re: ["(?i)^Live TV$"]
live_tab_text_re: ["(?i)^Live TV$"]
watch_live: ["Play", "Watch"]
playback_desc_contains: ["Pause", "Unmute", "Cast"]
channel_scroll_max: 20
logo_max_x: 230
logo_min_y: 700
logo_max_y: 2100
timeouts:
launch_wait_ui: 30s
launch_settle: 5s
live_nav: 20s
channel_find: 45s
after_channel: 2s
watch_live: 20s
playback: 45s

160
apps/modules/my5/my5.go Normal file
View file

@ -0,0 +1,160 @@
// Package my5 is the Channel 5 (My5 / "5") Live TV provider module.
// Live TV uses a left-rail of channel logos (no content-desc); selection is by logo_index.
package my5
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 My5 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: My5 live uses a raw Widevine license response (Cassie).
func (a *App) KeyMode() string { return "raw" }
// CaptureHints: transparent MITM should yield the DASH MPD (+ license_url).
func (a *App) CaptureHints() capture.Hints {
return a.Hints("mpd")
}
// CaptureHintsFor prefers URL substrings for this live channel when known.
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 patterns filled after first successful captures; safe no-ops until then.
prefer := map[string][]string{
"channel5": {"channel5", "c5-", "/c5"},
"5usa": {"5usa", "usa"},
"5star": {"5star", "star"},
"5action": {"5action", "action"},
"5select": {"5select", "select"},
}
if p, ok := prefer[id]; ok {
h.PreferURLContains = 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 My5 and dismisses common first-run prompts.
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()
a.dismissOnboarding(c)
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, taps the channel logo by index, then the Now EPG cell.
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 (logo %d)…\n", a.Label(id), ch.LogoIndex)
c.EnsureAwake()
c.DismissShadeIfFocused()
// Capture host normally Launch()s first; still start the app if we landed on the launcher.
if !a.appFocused(c) {
if err := a.Launch(c); err != nil {
return err
}
}
a.dismissOnboarding(c)
if err := a.openLiveTab(c); err != nil {
return fmt.Errorf("Live TV tab: %w", err)
}
if err := a.tapChannelLogo(c, ch); err != nil {
return fmt.Errorf("channel logo %s: %w", a.Label(id), err)
}
if err := a.tapNowCell(c, ch); err != nil {
fmt.Fprintf(os.Stderr, "[!] Now cell tap: %v — relying on embedded player\n", 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",
},
OrResourceContains: []string{
"c5player",
"video_view",
"video_player",
},
})
}
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 }

265
apps/modules/my5/steps.go Normal file
View file

@ -0,0 +1,265 @@
package my5
import (
"fmt"
"sort"
"strings"
"time"
"drmdecryption/adb"
"drmdecryption/uiflow"
)
func (a *App) appFocused(c *adb.Client) bool {
out, err := c.Shell("dumpsys", "window")
if err != nil {
return false
}
pkg := a.Package()
for _, line := range strings.Split(out, "\n") {
if strings.Contains(line, "mCurrentFocus") && strings.Contains(line, pkg) {
return true
}
}
return false
}
func (a *App) dismissOnboarding(c *adb.Client) {
deadline := time.Now().Add(8 * time.Second)
for time.Now().Before(deadline) {
nodes, err := c.DumpUI(a.CacheDir())
if err != nil {
return
}
for _, n := range nodes {
t := strings.TrimSpace(n.Text)
switch {
case strings.EqualFold(t, "Not now"),
strings.EqualFold(t, "Just browse"),
strings.EqualFold(t, "Skip register"):
fmt.Printf("[*] dismiss %q\n", t)
_ = c.Tap(n.CX(), n.CY())
time.Sleep(800 * time.Millisecond)
goto next
}
}
return
next:
}
}
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")
return nil
}
time.Sleep(700 * time.Millisecond)
}
return fmt.Errorf("Live TV did not open")
}
func (a *App) onLiveTab(nodes []adb.Node) bool {
for _, n := range nodes {
id := strings.ToLower(n.ResourceID)
if strings.Contains(id, "tv_guide_channel_logos") ||
strings.Contains(id, "tv_guide_epg") ||
strings.Contains(id, "tv_guide_player") ||
strings.Contains(id, "tv_guide_navigation") && n.Selected {
return true
}
if strings.EqualFold(n.Text, "Now") && strings.Contains(id, "tv_guide_header_now") {
return true
}
}
return false
}
func (a *App) logoNodes(nodes []adb.Node) []adb.Node {
maxX := a.cfg.UI.LogoMaxX
minY := a.cfg.UI.LogoMinY
maxY := a.cfg.UI.LogoMaxY
var out []adb.Node
for _, n := range nodes {
if !strings.Contains(n.Class, "ImageView") {
continue
}
// Channel logos in the Live rail have empty resource-id; EPG thumbs do not.
if strings.TrimSpace(n.ResourceID) != "" {
continue
}
if n.X1 >= maxX || n.Y1 < minY || n.Y1 >= maxY {
continue
}
// Skip tiny icons / nav glyphs.
if (n.Y2-n.Y1) < 120 || (n.X2-n.X1) < 120 {
continue
}
if !n.Clickable {
continue
}
out = append(out, n)
}
sort.Slice(out, func(i, j int) bool {
if out[i].Y1 == out[j].Y1 {
return out[i].X1 < out[j].X1
}
return out[i].Y1 < out[j].Y1
})
return out
}
// tapChannelLogo scrolls the left logo rail from the top by logo_index rows, then taps.
func (a *App) tapChannelLogo(c *adb.Client, ch Channel) error {
want := ch.LogoIndex
if want < 0 {
return fmt.Errorf("logo_index must be >= 0")
}
fmt.Printf("[*] find logo index %d (%s)…\n", want, ch.Label)
// Scroll to the top of the logo rail.
for i := 0; i < 8; i++ {
_ = c.Swipe(118, 1000, 118, 1950, 250)
time.Sleep(280 * time.Millisecond)
}
time.Sleep(400 * time.Millisecond)
nodes, err := c.DumpUI(a.CacheDir())
if err != nil {
return err
}
logos := a.logoNodes(nodes)
if len(logos) == 0 {
return fmt.Errorf("no channel logos visible")
}
rowH := logos[0].Y2 - logos[0].Y1
if rowH < 120 {
rowH = 205
}
// Gap between rows is small; step ≈ row height + ~10px from observed layout.
step := rowH + 10
// Bring target near the top by single-row swipes, then tap it in-view.
for i := 0; i < want; i++ {
_ = c.Swipe(118, 1200, 118, 1200-step, 220)
time.Sleep(350 * time.Millisecond)
}
time.Sleep(400 * time.Millisecond)
nodes, err = c.DumpUI(a.CacheDir())
if err != nil {
return err
}
logos = a.logoNodes(nodes)
if len(logos) == 0 {
return fmt.Errorf("no channel logos after scroll to index %d", want)
}
var n adb.Node
if want == 0 {
n = logos[0]
} else {
// After want single-row swipes from top, the target is the first fully
// visible logo (previous rows scrolled off). Prefer logos[0] when fully
// on-screen; otherwise logos[1] if the top one is clipped.
n = logos[0]
if n.Y1 < a.cfg.UI.LogoMinY+5 && len(logos) > 1 {
n = logos[1]
}
}
if n.CY() >= 2050 || n.Y2 > a.cfg.UI.LogoMaxY {
return fmt.Errorf("logo index %d clipped into nav", want)
}
fmt.Printf("[*] tap logo %d @ %d,%d\n", want, n.CX(), n.CY())
if err := c.Tap(n.CX(), n.CY()); err != nil {
return err
}
time.Sleep(time.Duration(a.cfg.Timeouts.AfterChannel))
return nil
}
func abs(v int) int {
if v < 0 {
return -v
}
return v
}
// tapNowCell taps the "Now" EPG cell aligned with the selected logo row.
// After tapChannelLogo scrolls the target to the top of the rail, align to logos[0].
func (a *App) tapNowCell(c *adb.Client, ch Channel) error {
_ = ch
nodes, err := c.DumpUI(a.CacheDir())
if err != nil {
return err
}
logos := a.logoNodes(nodes)
if len(logos) == 0 {
return fmt.Errorf("no logos after select")
}
logo := &logos[0]
if logo.Y1 < a.cfg.UI.LogoMinY+5 && len(logos) > 1 {
logo = &logos[1]
}
var best *adb.Node
bestDist := 1 << 30
for i := range nodes {
n := &nodes[i]
id := strings.ToLower(n.ResourceID)
if !strings.Contains(id, "epg_now_view") {
continue
}
d := abs(n.CY() - logo.CY())
if d < bestDist {
bestDist = d
best = n
}
}
if best == nil {
// Fallback: tap embedded player surface.
for i := range nodes {
n := &nodes[i]
id := strings.ToLower(n.ResourceID)
if strings.Contains(id, "video_view") || strings.Contains(id, "c5player") {
fmt.Printf("[*] tap player @ %d,%d\n", n.CX(), n.CY())
return c.Tap(n.CX(), n.CY())
}
}
return fmt.Errorf("Now cell not found")
}
fmt.Printf("[*] tap Now cell @ %d,%d\n", best.CX(), best.CY())
if err := c.Tap(best.CX(), best.CY()); err != nil {
return err
}
time.Sleep(time.Duration(a.cfg.Timeouts.AfterChannel))
return nil
}