-
Notifications
You must be signed in to change notification settings - Fork 50
/
u-next.go
41 lines (38 loc) · 1023 Bytes
/
u-next.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
package mediaunlocktest
import (
"encoding/json"
"io"
"net/http"
)
func U_NEXT(c http.Client) Result {
resp, err := GET(c, "https://video-api.unext.jp/api/1/player?entity%5B%5D=playlist_url&episode_code=ED00148814&title_code=SID0028118&keyonly_flg=0&play_mode=caption&bitrate_low=1500")
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 {
Data struct {
EntitiesData struct {
PlaylistUrl struct {
ResultStatus int `json:"result_status"`
} `json:"playlist_url"`
} `json:"entities_data"`
}
}
if err := json.Unmarshal(b, &res); err != nil {
return Result{Status: StatusErr, Err: err}
}
switch res.Data.EntitiesData.PlaylistUrl.ResultStatus {
case 475:
return Result{Status: StatusOK}
case 200:
return Result{Status: StatusOK}
case 467:
return Result{Status: StatusNo}
}
return Result{Status: StatusUnexpected}
}