This repository has been archived by the owner on Aug 7, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
/
token.go
132 lines (106 loc) · 4.02 KB
/
token.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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
package main
import (
"encoding/json"
"errors"
"fmt"
"io/ioutil"
"math/rand"
"net/http"
"time"
)
func randomString(num int) string {
rand.Seed(time.Now().UTC().UnixNano())
const chars = "abcdefghijklmnopqrstuvwxyz0123456789"
result := make([]byte, num)
for i := 0; i < num; i++ {
result[i] = chars[rand.Intn(len(chars))]
}
return string(result)
}
func (h *bahamut) getDeviceId() {
req, err := http.NewRequest("GET", "https://ani.gamer.com.tw/ajax/getdeviceid.php?id="+h.deviceId, nil)
isErr("Create request failed - ", err)
if h.cookie != "" {
req.Header.Add("cookie", h.rawCookie)
}
req.Header.Add("user-agent", "Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/77.0.3865.120 Safari/537.36")
req.Header.Add("referer", "https://ani.gamer.com.tw/animeVideo.php?sn="+h.sn)
req.Header.Add("origin", "https://ani.gamer.com.tw")
resp, err := http.DefaultClient.Do(req)
isErr("Get Device ID failed -", err)
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
isErr("Read response failed -", err)
var bahaData map[string]interface{}
err = json.Unmarshal(body, &bahaData)
isErr("Parse json failed -", err)
h.deviceId = bahaData["deviceid"].(string)
for _, ck := range resp.Cookies() {
if ck.Name == "nologinuser" {
h.rawCookie = "nologinuser=" + ck.Value
}
}
}
func (h *bahamut) gainAccess() {
resp := h.request("gainAccess", "https://ani.gamer.com.tw/ajax/token.php?adID=0&sn="+h.sn+"&device="+h.deviceId+"&hash="+randomString(12))
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
isErr("Read response failed -", err)
var bahaData map[string]interface{}
err = json.Unmarshal(body, &bahaData)
isErr("Parse json failed -", err)
if bahaData["error"] != nil {
isErr("Something happened -", errors.New("Where are you from? "))
} else {
fmt.Println("Gained access.")
}
}
func (h *bahamut) checkPremium() {
resp := h.request("checkPremium", "https://ani.gamer.com.tw/ajax/token.php?sn="+h.sn+"&device="+h.deviceId+"&hash="+randomString(12))
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
isErr("Read response failed -", err)
var bahaData map[string]interface{}
err = json.Unmarshal(body, &bahaData)
isErr("Parse json failed -", err)
if bahaData["vip"] != nil && bahaData["vip"].(bool) == true {
h.isPremium = true
fmt.Println("You're Premium user")
} else {
h.isPremium = false
fmt.Println("You're not Premium user")
}
}
func (h *bahamut) checkNoAd() {
resp := h.request("checkNoAd", "https://ani.gamer.com.tw/ajax/token.php?sn="+h.sn+"&device="+h.deviceId+"&hash="+randomString(12))
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
isErr("Read response failed -", err)
var bahaData map[string]interface{}
err = json.Unmarshal(body, &bahaData)
isErr("Parse json failed -", err)
if bahaData["time"] != nil {
if bahaData["time"].(float64) == 1 {
fmt.Println("Adaway.")
} else {
isErr("Something happened -", errors.New("Ads not away? "))
}
} else {
isErr("Something happened -", errors.New("Where are you from? "))
}
}
func (h *bahamut) startAd() {
h.request("startAd", "https://ani.gamer.com.tw/ajax/videoCastcishu.php?sn="+h.sn+"&s=194699").Body.Close()
}
func (h *bahamut) skipAd() {
h.request("skipAd", "https://ani.gamer.com.tw/ajax/videoCastcishu.php?sn="+h.sn+"&s=194699&ad=end").Body.Close()
}
func (h *bahamut) unlock() {
h.request("unlock", "https://ani.gamer.com.tw/ajax/unlock.php?sn="+h.sn+"&ttl=0").Body.Close()
}
func (h *bahamut) checkLock() {
h.request("checkLock", "https://ani.gamer.com.tw/ajax/checklock.php?device="+h.deviceId+"sn="+h.sn).Body.Close()
}
func (h *bahamut) videoStart() {
h.request("videoStart", "https://ani.gamer.com.tw/ajax/videoStart.php?sn="+h.sn).Body.Close()
}