-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathydbs.py
103 lines (87 loc) · 2.93 KB
/
ydbs.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
91
92
93
94
95
96
97
98
99
100
101
102
103
"""
time:2023.5.4
cron: 23 12 * * *
new Env('运动步数');
小米运动(Zepp Life)注册的账号,旧账户不行就新注册,随便邮箱,绑定wx
环境变量 ydbsck = 账号#密码
多账号新建变量或者用 & 分开
"""
import time
import requests
from os import environ, path
import random
# 读取通知
def load_send():
global send
cur_path = path.abspath(path.dirname(__file__))
if path.exists(cur_path + "/SendNotify.py"):
try:
from SendNotify import send
print("加载通知服务成功!")
except:
send = False
print(
'''加载通知服务失败~\n请使用以下拉库地址\nql repo https://github.com/Bidepanlong/ql.git "bd_" "README" "SendNotify"''')
else:
send = False
print(
'''加载通知服务失败~\n请使用以下拉库地址\nql repo https://github.com/Bidepanlong/ql.git "bd_" "README" "SendNotify"''')
load_send()
# 获取环境变量
def get_environ(key, default="", output=True):
def no_read():
if output:
print(f"未填写环境变量 {key} 请添加")
exit(0)
return default
return environ.get(key) if environ.get(key) else no_read()
class Ydbs():
def __init__(self, user, psw):
self.msg = ''
self.user = user
self.psw = psw
def sign(self):
time.sleep(0.5)
step = str(random.randint(40000, 45000))
url = "https://apis.jxcxin.cn/api/mi?user=" + self.user + "&password=" + self.psw + "&step=" + step
r = requests.get(url)
if r.status_code != 200:
xx = f"[登录]:{self.user}\n[步数]:{step}\n[提交]:请求失败,{r.json()['msg']}\n\n"
print(xx)
self.msg += xx
return self.msg
try:
if r.json()['code'] == 200:
xx = f"[登录]:{self.user}\n[步数]:{step}\n[提交]:{r.json()['msg']}\n\n"
print(xx)
self.msg += xx
return self.msg
else:
xx = f"[登录]:{self.user}\n[步数]:{step}\n[提交]:{r.json()['msg']}\n\n"
print(xx)
self.msg += xx
return self.msg
except:
xx = f"[登录]:解析响应失败,请检查网络\n\n"
print(xx)
self.msg += xx
return self.msg
def get_sign_msg(self):
return self.sign()
if __name__ == '__main__':
token = get_environ("ydbsck")
msg = ''
cks = token.split("&")
print("检测到{}个ck记录\n开始刷步数\n".format(len(cks)))
for ck in cks:
c = ck.split('&')
for i in c:
d = i.split('#')
try:
run = Ydbs(d[0], d[1])
msg += run.get_sign_msg()
except KeyError:
print("请检查ck是否正确")
print()
if send:
send("刷步数通知", msg)