Null-DRM-Official/apps/modules/bbc/config.go
404errordeveloper f9c28be3f1
All checks were successful
release / build-and-upload (push) Successful in 6m8s
modules-release / build-and-upload (push) Successful in 4m47s
v0.1.1: external modules, publish YAML, proxy reset, binary-first README
- Host discovers/builds modules under modules/ (bbc, rte, tg4)
- module-publish.yaml tracked; local module.yaml gitignored
- drm --modules-dir / DRM_MODULES_DIR
- drm proxy reset; Magisk reinject reliability
- modules-v* Forgejo release workflow + build scripts
- BBC full Explore channel map including S4C
- README quickstart based on release binaries
2026-10-08 23:16:14 +02:00

125 lines
4 KiB
Go

package bbc
import (
"regexp"
"time"
"drmdecryption/modcfg"
"drmdecryption/modules/provider"
)
// Name is the module id (--app bbc).
const Name = "bbc"
// Channel is one live target. Label doubles as the Explore-rail content-desc
// (e.g. "BBC One") unless ChipDesc overrides it.
type Channel struct {
Label string `yaml:"label"`
// VPID is the mediaselector version/service id (e.g. bbc_one_london).
VPID string `yaml:"vpid"`
// ChipDesc matches the channel logo on Explore (content-desc). Default: Label.
ChipDesc []string `yaml:"chip_desc"`
// PlayDesc matches the Watch-live control on the channel page. Default: Watch live.
PlayDesc []string `yaml:"play_desc"`
}
// Config is modules/bbc/module.yaml (preferred) or apps/modules/bbc/module.yaml.
type Config struct {
provider.Common `yaml:",inline"`
Channels map[string]Channel `yaml:"channels"`
Timeouts Timeouts `yaml:"timeouts"`
UI UI `yaml:"ui"`
}
// Timeouts for launch / autoplay. Written as "25s" in module.yaml.
type Timeouts struct {
LaunchWaitUI provider.Duration `yaml:"launch_wait_ui"`
LaunchSettle provider.Duration `yaml:"launch_settle"`
ExploreNav provider.Duration `yaml:"explore_nav"`
ChannelFind provider.Duration `yaml:"channel_find"`
AfterChannel provider.Duration `yaml:"after_channel"`
WatchLive provider.Duration `yaml:"watch_live"`
AfterWatch provider.Duration `yaml:"after_watch"`
Playback provider.Duration `yaml:"playback"`
}
// UI markers for launch readiness and interactive navigation.
type UI struct {
LaunchDescContains []string `yaml:"launch_desc_contains"`
LaunchResourceContains []string `yaml:"launch_resource_contains"`
// ExploreTab is bottom-nav text/desc for the Explore page.
ExploreTab []string `yaml:"explore_tab"`
// WatchLive is the channel-page play control.
WatchLive []string `yaml:"watch_live"`
// PlaybackDescContains are soft player-up signals.
PlaybackDescContains []string `yaml:"playback_desc_contains"`
// ChannelScrollMax limits horizontal swipes while hunting a channel logo.
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(4 * time.Second))
t.ExploreNav = provider.Duration(t.ExploreNav.D(20 * time.Second))
t.ChannelFind = provider.Duration(t.ChannelFind.D(45 * time.Second))
t.AfterChannel = provider.Duration(t.AfterChannel.D(3 * time.Second))
t.WatchLive = provider.Duration(t.WatchLive.D(20 * time.Second))
t.AfterWatch = provider.Duration(t.AfterWatch.D(2 * time.Second))
t.Playback = provider.Duration(t.Playback.D(60 * time.Second))
u := &c.UI
if len(u.LaunchDescContains) == 0 {
u.LaunchDescContains = []string{"Home", "Explore", "Watchlist", "Watch now", "iPlayer"}
}
if len(u.ExploreTab) == 0 {
u.ExploreTab = []string{"Explore"}
}
if len(u.WatchLive) == 0 {
u.WatchLive = []string{"Watch live", "Watch Live", "Watch now"}
}
if len(u.PlaybackDescContains) == 0 {
u.PlaybackDescContains = []string{"Pause", "pause", "Player", "Seek", "scrubber"}
}
if u.ChannelScrollMax <= 0 {
u.ChannelScrollMax = 10
}
return c
}
func (ch Channel) chipPatterns() []string {
if len(ch.ChipDesc) > 0 {
return ch.ChipDesc
}
if ch.Label != "" {
return []string{"^" + regexp.QuoteMeta(ch.Label) + "$", ch.Label}
}
return nil
}
func (ch Channel) playPatterns(ui UI) []string {
if len(ch.PlayDesc) > 0 {
return ch.PlayDesc
}
return ui.WatchLive
}
var flags struct {
packageName string
caHash string
proxyBin string
}
func loadConfig() (Config, modcfg.Result, error) {
var cfg Config
res, err := modcfg.Load(Name, &cfg)
if err != nil {
return cfg, res, err
}
cfg.Package = modcfg.Override(Name, "package", flags.packageName, cfg.Package)
cfg.CAHash = modcfg.Override(Name, "ca_hash", flags.caHash, cfg.CAHash)
cfg.ProxyBin = modcfg.Override(Name, "proxy_bin", flags.proxyBin, cfg.ProxyBin)
return cfg.withDefaults(), res, nil
}