-
Notifications
You must be signed in to change notification settings - Fork 50
/
bilibili.go
40 lines (36 loc) · 1.07 KB
/
bilibili.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
package mediaunlocktest
import (
"encoding/json"
"io"
"net/http"
)
func bilibili(c http.Client, url string) Result {
resp, err := GET(c, url)
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 {
Code int
}
if err := json.Unmarshal(b, &res); err != nil {
return Result{Status: StatusErr, Err: err}
}
if res.Code == -10403 {
return Result{Status: StatusNo}
}
if res.Code == 0 {
return Result{Status: StatusOK}
}
return Result{Status: StatusUnexpected, Info: "unknown"}
}
func BilibiliHKMC(c http.Client) Result {
return bilibili(c, "https://api.bilibili.com/pgc/player/web/playurl?avid=473502608&cid=845838026&qn=0&type=&otype=json&ep_id=678506&fourk=1&fnver=0&fnval=16&module=bangumi")
}
func BilibiliTW(c http.Client) Result {
return bilibili(c, "https://api.bilibili.com/pgc/player/web/playurl?avid=50762638&cid=100279344&qn=0&type=&otype=json&ep_id=268176&fourk=1&fnver=0&fnval=16&module=bangumi")
}