forked from nkeonkeo/MediaUnlockTest
-
Notifications
You must be signed in to change notification settings - Fork 8
/
BiliBili.go
59 lines (51 loc) · 1.78 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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
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 || res.Code == 10004001 || res.Code == 10003003 {
return Result{Status: StatusNo}
}
if resp.StatusCode == 412 {
return Result{Status: StatusFailed}
}
if res.Code == 0 {
return Result{Status: StatusOK}
}
return Result{Status: StatusUnexpected}
}
func BilibiliHKMO(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")
}
func BilibiliSEA(c http.Client) Result {
return bilibili(c, "https://api.bilibili.tv/intl/gateway/web/playurl?s_locale=en_US&platform=web&ep_id=347666")
}
func BilibiliTH(c http.Client) Result {
return bilibili(c, "https://api.bilibili.tv/intl/gateway/web/playurl?s_locale=en_US&platform=web&ep_id=10077726")
}
func BilibiliID(c http.Client) Result {
return bilibili(c, "https://api.bilibili.tv/intl/gateway/web/playurl?s_locale=en_US&platform=web&ep_id=11130043")
}
func BilibiliVN(c http.Client) Result {
return bilibili(c, "https://api.bilibili.tv/intl/gateway/web/playurl?s_locale=en_US&platform=web&ep_id=11405745")
}