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

116 lines
3.2 KiB
Go

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
}