-
Notifications
You must be signed in to change notification settings - Fork 51
/
BahamutAnime.go
44 lines (42 loc) · 1.05 KB
/
BahamutAnime.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
package mediaunlocktest
import (
"encoding/json"
"io"
"net/http"
"net/http/cookiejar"
)
func BahamutAnime(c http.Client) Result {
c.Jar, _ = cookiejar.New(nil)
resp, err := GET(c, "https://ani.gamer.com.tw/ajax/getdeviceid.php")
if err != nil {
return Result{Status: StatusNetworkErr}
}
defer resp.Body.Close()
b, err := io.ReadAll(resp.Body)
if err != nil {
return Result{Status: StatusNetworkErr, Err: err}
}
var res struct {
AnimeSn int
Deviceid string
}
if err := json.Unmarshal(b, &res); err != nil {
return Result{Status: StatusErr, Err: err}
}
resp, err = GET(c, "https://ani.gamer.com.tw/ajax/token.php?adID=89422&sn=14667&device="+res.Deviceid)
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}
}
if err := json.Unmarshal(b, &res); err != nil {
return Result{Status: StatusErr, Err: err}
}
if res.AnimeSn != 0 {
return Result{Status: StatusOK}
}
return Result{Status: StatusNo}
}