-
Notifications
You must be signed in to change notification settings - Fork 50
/
Telasa.go
47 lines (43 loc) · 1.09 KB
/
Telasa.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 (
"context"
"encoding/json"
"io"
"net/http"
"time"
)
func Telasa(c http.Client) Result {
ctx, cancel := context.WithTimeout(context.Background(), 30*time.Second)
defer cancel()
req, err := http.NewRequestWithContext(ctx, "GET", "https://api-videopass-anon.kddi-video.com/v1/playback/system_status", nil)
if err != nil {
return Result{Status: StatusNetworkErr, Err: err}
}
req.Header.Set("X-Device-ID", "d36f8e6b-e344-4f5e-9a55-90aeb3403799")
resp, err := cdo(c, req)
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 struct {
Status struct {
Type string
Subtype string
}
}
if err := json.Unmarshal(b, &res); err != nil {
return Result{Status: StatusErr, Err: err}
}
if res.Status.Subtype == "IPLocationNotAllowed" {
return Result{Status: StatusNo}
}
if res.Status.Type != "" {
return Result{Status: StatusOK}
}
return Result{Status: StatusUnexpected}
}