-
Notifications
You must be signed in to change notification settings - Fork 51
/
Copy pathtvb.go
34 lines (30 loc) · 790 Bytes
/
tvb.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
package mediaunlocktest
import (
"encoding/json"
"io"
"net/http"
"strings"
)
func TVBAnywhere(c http.Client) Result {
resp, err := GET(c, "https://uapisfm.tvbanywhere.com.sg/geoip/check/platform/android")
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 tvbAnywhereRes
if err := json.Unmarshal(b, &res); err != nil {
return Result{Status: StatusErr, Err: err}
}
if res.AllowInThisCountry {
return Result{Status: StatusOK, Region: strings.ToLower(res.Country)}
}
return Result{Status: StatusNo}
}
type tvbAnywhereRes struct {
AllowInThisCountry bool `json:"allow_in_this_country"`
Country string
}