Null-DRM-Official/apps/modules/my5/config.go
404errordeveloper da8e1123ec
All checks were successful
release / build-and-upload (push) Successful in 7m5s
Streamd v0.2.0: rename, modules panel, stable/beta channels
- Rename product/host binary to streamd (drm compat copy still shipped)
- Go module path streamd; STREAMD_* env aliases; agent UA streamd-agent
- Panel Modules store + agent pull sync (modstore / modsync)
- Rolling stable + beta download tags; README/docs channel curl blocks
- Release notes in docs/releases/v0.2.0.md attached by Forgejo Actions
2026-10-10 15:58:26 +02:00

133 lines
3.8 KiB
Go

package my5
import (
"time"
"streamd/modcfg"
"streamd/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
}