package itv import ( "time" "drmdecryption/modcfg" "drmdecryption/modules/provider" ) // Name is the module id (--app itv). const Name = "itv" // Channel is one live ITVX target. type Channel struct { Label string `yaml:"label"` ChipDesc []string `yaml:"chip_desc"` PlayDesc []string `yaml:"play_desc"` } // Config is modules/itv/module.yaml (preferred) or apps/modules/itv/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(3 * time.Second)) t.WatchLive = provider.Duration(t.WatchLive.D(20 * time.Second)) t.Playback = provider.Duration(t.Playback.D(60 * time.Second)) u := &c.UI if len(u.LaunchDescContains) == 0 { u.LaunchDescContains = []string{"Home", "Live", "Categories", "My List", "ITVX"} } if len(u.LiveTab) == 0 { u.LiveTab = []string{"Lyve", "Live"} } if len(u.LiveTabDescRE) == 0 { u.LiveTabDescRE = []string{"^Lyve$"} } if len(u.LiveTabTextRE) == 0 { u.LiveTabTextRE = []string{"^Live$"} } if len(u.WatchLive) == 0 { u.WatchLive = []string{"WATCH LIVE", "Watch live", "Watch Live"} } if len(u.PlaybackDescContains) == 0 { u.PlaybackDescContains = []string{"Pause", "pause", "Seek", "Player"} } if u.ChannelScrollMax <= 0 { u.ChannelScrollMax = 12 } if c.Package == "" { c.Package = "air.ITVMobilePlayer" } 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 }