-
Notifications
You must be signed in to change notification settings - Fork 51
/
dazn.go
47 lines (43 loc) · 1.04 KB
/
dazn.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
37
38
39
40
41
42
43
44
45
46
47
package mediaunlocktest
import (
"encoding/json"
"io"
"net/http"
)
func Dazn(c http.Client) Result {
resp, err := PostJson(c, "https://startup.core.indazn.com/misl/v5/Startup",
`{"LandingPageKey":"generic","Languages":"zh-CN,zh,en","Platform":"web","PlatformAttributes":{},"Manufacturer":"","PromoCode":"","Version":"2"}`,
)
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}
}
// log.Println(string(b))
var res daznRes
if err := json.Unmarshal(b, &res); err != nil {
return Result{Status: StatusErr, Err: err}
}
if res.Region.IsAllowed {
return Result{
Status: StatusOK,
Region: res.Region.GeolocatedCountry,
}
}
return Result{
Status: StatusNo,
Info: res.Region.DisallowedReason,
}
}
type daznRegion struct {
IsAllowed bool
DisallowedReason string
GeolocatedCountry string
GeolocatedCountryName string
}
type daznRes struct {
Region daznRegion
}