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
62 lines
1.5 KiB
Go
62 lines
1.5 KiB
Go
package tg4
|
|
|
|
import (
|
|
"fmt"
|
|
"path/filepath"
|
|
"strings"
|
|
|
|
"streamd/brightcove"
|
|
"streamd/repo"
|
|
"streamd/session"
|
|
"streamd/wvkey"
|
|
)
|
|
|
|
// EnrichWithKeys fetches the HLS master, extracts the Widevine PSSH and resolves
|
|
// every content key through the local CDM. Brightcove returns multiple CONTENT
|
|
// keys and a downloader needs all of them.
|
|
func (a *App) EnrichWithKeys(info *session.Stream, python, wvd string) error {
|
|
if info == nil || info.MPD == "" {
|
|
return fmt.Errorf("missing manifest URL")
|
|
}
|
|
if info.LicenseURL == "" {
|
|
return fmt.Errorf("missing license_url")
|
|
}
|
|
if strings.TrimSpace(wvd) == "" {
|
|
return fmt.Errorf("key fetch requires --wvd (path to .wvd device file)")
|
|
}
|
|
body, err := brightcove.Get(info.MPD)
|
|
if err != nil {
|
|
return fmt.Errorf("hls master: %w", err)
|
|
}
|
|
pssh := brightcove.ExtractWidevinePSSH(body)
|
|
if pssh == "" {
|
|
return fmt.Errorf("no Widevine PSSH in HLS master")
|
|
}
|
|
info.PSSH = pssh
|
|
info.PrimaryKID = brightcove.PrimaryKID(body)
|
|
|
|
all, err := wvkey.FetchRawAll(wvkey.Options{
|
|
Python: python,
|
|
Script: filepath.Join(repo.Root(), "apps", "wvkey", "wvkey.py"),
|
|
WVD: wvd,
|
|
PSSH: pssh,
|
|
LicenseURL: info.LicenseURL,
|
|
})
|
|
if err != nil {
|
|
return err
|
|
}
|
|
if len(all) == 0 {
|
|
return fmt.Errorf("license returned no content keys")
|
|
}
|
|
info.Keys = all
|
|
info.Key = all[0]
|
|
if info.PrimaryKID != "" {
|
|
for _, k := range all {
|
|
if strings.HasPrefix(strings.ToLower(k), info.PrimaryKID+":") {
|
|
info.Key = k
|
|
break
|
|
}
|
|
}
|
|
}
|
|
return nil
|
|
}
|