Null-DRM-Official/apps/modules/my5/my5.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

160 lines
4.7 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// 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 }