-
Notifications
You must be signed in to change notification settings - Fork 50
/
encoreTVB.go
36 lines (34 loc) · 1.23 KB
/
encoreTVB.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package mediaunlocktest
import (
"encoding/json"
"io"
"net/http"
)
func EncoreTVB(c http.Client) Result {
resp, err := GET(c, "https://edge.api.brightcove.com/playback/v1/accounts/5324042807001/videos/6005570109001",
H{"Accept", "application/json;pk=BCpkADawqM2Gpjj8SlY2mj4FgJJMfUpxTNtHWXOItY1PvamzxGstJbsgc-zFOHkCVcKeeOhPUd9MNHEGJoVy1By1Hrlh9rOXArC5M5MTcChJGU6maC8qhQ4Y8W-QYtvi8Nq34bUb9IOvoKBLeNF4D9Avskfe9rtMoEjj6ImXu_i4oIhYS0dx7x1AgHvtAaZFFhq3LBGtR-ZcsSqxNzVg-4PRUI9zcytQkk_YJXndNSfhVdmYmnxkgx1XXisGv1FG5GOmEK4jZ_Ih0riX5icFnHrgniADr4bA2G7TYh4OeGBrYLyFN_BDOvq3nFGrXVWrTLhaYyjxOr4rZqJPKK2ybmMsq466Ke1ZtE-wNQ"},
H{"Origin", "https://www.encoretvb.com"},
)
if err != nil {
return Result{Status: StatusNetworkErr, Err: err}
}
defer resp.Body.Close()
b, err := io.ReadAll(resp.Body)
if err != nil {
return Result{Status: StatusNetworkErr, Err: err}
}
var res struct {
ErrorSubcode string `json:"error_subcode"`
AccountId string `json:"account_id"`
}
if err := json.Unmarshal(b, &res); err != nil {
return Result{Status: StatusFailed, Err: err}
}
if res.ErrorSubcode == "CLIENT_GEO" {
return Result{Status: StatusNo}
}
if res.AccountId != "0" {
return Result{Status: StatusOK}
}
return Result{Status: StatusFailed}
}