From bc3ab4bbcb1e87b1ec1ab244fba5cac4eb5489b1 Mon Sep 17 00:00:00 2001 From: Christopher Tarry Date: Sat, 17 Sep 2022 23:29:00 -0400 Subject: [PATCH] allow specifying KEY_FILE and CLIENT_ID_FILE environment variables --- main.go | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/main.go b/main.go index 2cfedc0..a6e70cf 100644 --- a/main.go +++ b/main.go @@ -67,6 +67,9 @@ download [id] - prints the MPD url the video is available at and returns the mp4 return } + key, _ := os.ReadFile(os.Getenv("KEY_FILE")) + clientID, _ := os.ReadFile(os.Getenv("CLIENT_ID_FILE")) + client := hulu.NewDefaultClient(huluSession, huluGUID) w := tabwriter.NewWriter(os.Stdout, 8, 8, 0, '\t', 0) defer w.Flush() @@ -138,9 +141,15 @@ download [id] - prints the MPD url the video is available at and returns the mp4 panic(err) } - cdm, err := widevine.NewDefaultCDM(initData) - if err != nil { - panic(err) + var cdm widevine.CDM + if len(key) > 0 && len(clientID) > 0 { + if cdm, err = widevine.NewCDM(key, clientID, initData); err != nil { + panic(err) + } + } else { + if cdm, err = widevine.NewDefaultCDM(initData); err != nil { + panic(err) + } } licenseRequest, err := cdm.GetLicenseRequest()