1
0
mirror of https://github.com/chris124567/hulu synced 2024-11-23 16:47:29 +00:00

allow specifying KEY_FILE and CLIENT_ID_FILE environment variables

This commit is contained in:
Christopher Tarry 2022-09-17 23:29:00 -04:00
parent 77b6b192bc
commit bc3ab4bbcb

13
main.go
View File

@ -67,6 +67,9 @@ download [id] - prints the MPD url the video is available at and returns the mp4
return return
} }
key, _ := os.ReadFile(os.Getenv("KEY_FILE"))
clientID, _ := os.ReadFile(os.Getenv("CLIENT_ID_FILE"))
client := hulu.NewDefaultClient(huluSession, huluGUID) client := hulu.NewDefaultClient(huluSession, huluGUID)
w := tabwriter.NewWriter(os.Stdout, 8, 8, 0, '\t', 0) w := tabwriter.NewWriter(os.Stdout, 8, 8, 0, '\t', 0)
defer w.Flush() defer w.Flush()
@ -138,10 +141,16 @@ download [id] - prints the MPD url the video is available at and returns the mp4
panic(err) panic(err)
} }
cdm, err := widevine.NewDefaultCDM(initData) var cdm widevine.CDM
if err != nil { if len(key) > 0 && len(clientID) > 0 {
if cdm, err = widevine.NewCDM(key, clientID, initData); err != nil {
panic(err) panic(err)
} }
} else {
if cdm, err = widevine.NewDefaultCDM(initData); err != nil {
panic(err)
}
}
licenseRequest, err := cdm.GetLicenseRequest() licenseRequest, err := cdm.GetLicenseRequest()
if err != nil { if err != nil {