-
Notifications
You must be signed in to change notification settings - Fork 51
/
viutv.go
32 lines (29 loc) · 873 Bytes
/
viutv.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
package mediaunlocktest
import (
"encoding/json"
"io"
"net/http"
)
func ViuTV(c http.Client) Result {
resp, err := PostJson(c, "https://api.viu.now.com/p8/3/getLiveURL",
`{"callerReferenceNo":"20210726112323","contentId":"099","contentType":"Channel","channelno":"099","mode":"prod","deviceId":"29b3cb117a635d5b56","deviceType":"ANDROID_WEB"}`,
)
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 noweRes
if err := json.Unmarshal(b, &res); err != nil {
return Result{Status: StatusErr, Err: err}
}
if res.ResponseCode == "SUCCESS" {
return Result{Status: StatusOK}
} else if res.ResponseCode == "GEO_CHECK_FAIL" {
return Result{Status: StatusNo}
}
return Result{Status: StatusUnexpected}
}