-
Notifications
You must be signed in to change notification settings - Fork 51
/
Copy pathnowe.go
36 lines (32 loc) · 905 Bytes
/
nowe.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 NowE(c http.Client) Result {
resp, err := PostJson(c, "https://webtvapi.nowe.com/16/1/getVodURL",
`{"contentId":"202105121370235","contentType":"Vod","pin":"","deviceId":"W-60b8d30a-9294-d251-617b-c12f9d0c","deviceType":"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: StatusUnexpected, Err: err}
}
if res.ResponseCode == "PRODUCT_INFORMATION_INCOMPLETE" {
return Result{Status: StatusOK}
} else if res.ResponseCode == "GEO_CHECK_FAIL" {
return Result{Status: StatusNo}
}
return Result{Status: StatusUnexpected}
}
type noweRes struct {
ResponseCode string
}