-
Notifications
You must be signed in to change notification settings - Fork 51
/
Paravi.go
37 lines (34 loc) · 816 Bytes
/
Paravi.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
package mediaunlocktest
import (
"encoding/json"
"io"
"net/http"
)
func Paravi(c http.Client) Result {
resp, err := PostJson(c, "https://api.paravi.jp/api/v1/playback/auth",
`{"meta_id":17414,"vuid":"3b64a775a4e38d90cc43ea4c7214702b","device_code":1,"app_id":1}`,
)
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 struct {
Error struct {
Type string
}
}
if err := json.Unmarshal(b, &res); err != nil {
return Result{Status: StatusErr, Err: err}
}
if res.Error.Type == "Forbidden" {
return Result{Status: StatusNo}
}
if res.Error.Type == "Unauthorized" {
return Result{Status: StatusOK}
}
return Result{Status: StatusOK}
}