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
133
apps/modules/my5/config.go
Normal file
133
apps/modules/my5/config.go
Normal 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
|
||||
}
|
||||
118
apps/modules/my5/module-publish.yaml
Normal file
118
apps/modules/my5/module-publish.yaml
Normal 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
160
apps/modules/my5/my5.go
Normal 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
265
apps/modules/my5/steps.go
Normal 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
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue