This repository has been archived by the owner on Oct 24, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
cloud_genshin.py
90 lines (87 loc) · 3.2 KB
/
cloud_genshin.py
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
import time
import httpx
def Next_time() -> int:
now_time = int(time.time())
nextday_time = now_time - now_time % 86400 + time.timezone + 39600
if int(time.time()) > nextday_time:
nextday_time += 14400
if int(time.time()) > nextday_time:
nextday_time += 14400
if int(time.time()) > (nextday_time + 10):
print("今天好像已经没机会了")
exit()
return nextday_time
headers = {
'x-rpc-combo_token': '',
'x-rpc-client_type': '2',
'x-rpc-app_version': '1.0.0',
'x-rpc-sys_version': '',
'x-rpc-channel': 'mihoyo',
'x-rpc-device_id': '',
'x-rpc-device_name': '',
'x-rpc-device_model': '',
'x-rpc-app_id': '',
'Referer': 'https://app.mihoyo.com',
'Content-Length': '0',
'Host': 'api-cloudgame.mihoyo.com',
'Connection': 'Keep-Alive',
'Accept-Encoding': 'gzip',
'User-Agent': 'okhttp/3.14.9'
}
print("Go")
may_start_time = Next_time()
may_end_time = Next_time() + 5
if int(time.time()) < may_start_time:
time.sleep(may_start_time - int(time.time()) - 0.015)
for i in range(0,40):
try:
req = httpx.post(url="https://api-cloudgame.mihoyo.com/hk4e_cg_cn/gamer/api/login",headers=headers,data="")
data = req.json()
except:
continue
if i > 25 and int(time.time()) > may_end_time:
print("已经没机会了,凉凉 r.i.p")
break
elif data["retcode"] == -100005 or data["retcode"] == -100003:
time.sleep(1.9)
continue
elif int(time.time()) > may_end_time:
print("来晚了没机会了,等待明天吧")
break
elif data["retcode"] == 0:
print("抢位 or 登入成功!")
time.sleep(1)
try:
req2 = httpx.post(url="https://api-cloudgame.mihoyo.com/hk4e_cg_cn/gamer/api/onceActiveDone",headers=headers,data="")
data2 = req2.json()
except:
print("尝试领取新人奖励失败")
break
if data2["data"] != "":
msg = str(data2["data"]["sends"][0]["msg"])
msg.replace("赠送%免费","赠送{}分钟免费".format(str(data2["data"]["sends"][0]["num"])))
print(msg)
else:
print("已领取过新人奖励")
try:
req3 = httpx.get(url="https://api-cloudgame.mihoyo.com/hk4e_cg_cn/wallet/wallet/get",headers=headers)
data3 = req3.json()
except:
print("尝试签到失败")
break
if data3["retcode"] == 0:
if int(data3["data"]["free_time"]["send_freetime"]) != 0:
print("签到成功?已经获得{}分钟免费时长(总时长:{}分钟)".format(
data3["data"]["free_time"]["send_freetime"],
data3["data"]["free_time"]["free_time"]
))
else:
print("未获得免费时长,账号已经签到过了?(总时长:{}分钟)".format(
data3["data"]["free_time"]["free_time"]
))
else:
print("尝试签到失败")
break
elif data["retcode"] == -100:
print(data["message"])
break