All checks were successful
release / build-and-upload (push) Successful in 7m5s
- 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
169 lines
3.7 KiB
Go
169 lines
3.7 KiB
Go
// Command my5 is the external Channel 5 (My5 / "5") provider module.
|
|
// Built on demand by the drm host: modules/my5/.bin/my5[.exe]
|
|
package main
|
|
|
|
import (
|
|
"encoding/json"
|
|
"flag"
|
|
"fmt"
|
|
"os"
|
|
|
|
"streamd/adb"
|
|
appreg "streamd/app"
|
|
"streamd/modcfg"
|
|
"streamd/modhost"
|
|
"streamd/modules/my5"
|
|
)
|
|
|
|
func main() {
|
|
if len(os.Args) < 2 {
|
|
usage()
|
|
os.Exit(2)
|
|
}
|
|
cmd, args := os.Args[1], os.Args[2:]
|
|
var err error
|
|
switch cmd {
|
|
case "describe":
|
|
err = cmdDescribe()
|
|
case "launch":
|
|
err = cmdLaunch(args)
|
|
case "autoplay":
|
|
err = cmdAutoplay(args)
|
|
case "catalog":
|
|
err = cmdCatalog(args)
|
|
case "help", "-h", "--help":
|
|
usage()
|
|
return
|
|
default:
|
|
usage()
|
|
err = fmt.Errorf("unknown command %q", cmd)
|
|
}
|
|
if err != nil {
|
|
fmt.Fprintln(os.Stderr, "[!]", err)
|
|
os.Exit(1)
|
|
}
|
|
}
|
|
|
|
func usage() {
|
|
fmt.Fprint(os.Stderr, `my5 — Streamd external module (Channel 5 / My5 / "5")
|
|
|
|
Usage:
|
|
my5 describe
|
|
my5 launch [--serial SERIAL]
|
|
my5 autoplay --channel ID [--serial SERIAL]
|
|
my5 catalog --channel ID [--json]
|
|
`)
|
|
}
|
|
|
|
func loadApp() (appreg.App, error) {
|
|
return my5.New()
|
|
}
|
|
|
|
func cmdDescribe() error {
|
|
a, err := loadApp()
|
|
if err != nil {
|
|
return err
|
|
}
|
|
d := modhost.Describe{
|
|
Protocol: modhost.ProtocolVersion,
|
|
Name: a.Name(),
|
|
Package: a.Package(),
|
|
LicenseURL: a.LicenseURL(),
|
|
KeyMode: a.KeyMode(),
|
|
ProxyBin: a.ProxyBin(),
|
|
CAHash: a.CAHash(),
|
|
TransparentMITM: true,
|
|
Rewriter: "none",
|
|
ValuesPath: modcfg.Path(a.Name()),
|
|
}
|
|
if mh, ok := a.(appreg.MitmHostList); ok {
|
|
d.MitmHosts = mh.MitmHosts()
|
|
}
|
|
if sd, ok := a.(appreg.StreamDefaults); ok {
|
|
d.Rewriter = sd.RewriterName()
|
|
}
|
|
type loaded interface {
|
|
ConfigLoaded() bool
|
|
ConfigPath() string
|
|
}
|
|
if L, ok := a.(loaded); ok {
|
|
d.ValuesLoaded = L.ConfigLoaded()
|
|
if L.ConfigPath() != "" {
|
|
d.ValuesPath = L.ConfigPath()
|
|
}
|
|
}
|
|
if _, ok := a.(appreg.Catalog); ok {
|
|
d.HasCatalog = true
|
|
}
|
|
h := a.CaptureHints()
|
|
d.Require = h.Require
|
|
d.Score = h.Score
|
|
// Prefer substrings refined after first captures; safe defaults for now.
|
|
d.ChannelMPDPrefer = map[string][]string{
|
|
"channel5": {"channel5"},
|
|
"5usa": {"5usa", "usa"},
|
|
"5star": {"5star"},
|
|
"5action": {"5action"},
|
|
"5select": {"5select"},
|
|
}
|
|
for _, ch := range a.Channels() {
|
|
d.Channels = append(d.Channels, modhost.Channel{ID: ch.ID, Label: ch.Label})
|
|
}
|
|
enc := json.NewEncoder(os.Stdout)
|
|
enc.SetIndent("", " ")
|
|
return enc.Encode(d)
|
|
}
|
|
|
|
func cmdLaunch(args []string) error {
|
|
fs := flag.NewFlagSet("launch", flag.ContinueOnError)
|
|
serial := fs.String("serial", "", "adb device serial")
|
|
if err := fs.Parse(args); err != nil {
|
|
return err
|
|
}
|
|
a, err := loadApp()
|
|
if err != nil {
|
|
return err
|
|
}
|
|
c := adb.New()
|
|
if *serial != "" {
|
|
c = c.WithSerial(*serial)
|
|
}
|
|
return a.Launch(c)
|
|
}
|
|
|
|
func cmdAutoplay(args []string) error {
|
|
fs := flag.NewFlagSet("autoplay", flag.ContinueOnError)
|
|
serial := fs.String("serial", "", "adb device serial")
|
|
channel := fs.String("channel", "", "channel id")
|
|
if err := fs.Parse(args); err != nil {
|
|
return err
|
|
}
|
|
if *channel == "" {
|
|
return fmt.Errorf("--channel is required")
|
|
}
|
|
a, err := loadApp()
|
|
if err != nil {
|
|
return err
|
|
}
|
|
c := adb.New()
|
|
if *serial != "" {
|
|
c = c.WithSerial(*serial)
|
|
}
|
|
return a.AutoPlay(c, *channel)
|
|
}
|
|
|
|
func cmdCatalog(args []string) error {
|
|
fs := flag.NewFlagSet("catalog", flag.ContinueOnError)
|
|
channel := fs.String("channel", "", "channel id")
|
|
_ = fs.Bool("json", false, "print JSON")
|
|
if err := fs.Parse(args); err != nil {
|
|
return err
|
|
}
|
|
if *channel == "" {
|
|
return fmt.Errorf("--channel is required")
|
|
}
|
|
if _, err := loadApp(); err != nil {
|
|
return err
|
|
}
|
|
return fmt.Errorf("my5 module has no catalog — use phone capture (UK geo)")
|
|
}
|