├── .gitattributes
├── .github
└── workflows
│ └── run.yml
├── LICENSE
├── README.md
├── TG_PUSH.md
└── main.py
/.gitattributes:
--------------------------------------------------------------------------------
1 | # Auto detect text files and perform LF normalization
2 | * text=auto
3 |
--------------------------------------------------------------------------------
/.github/workflows/run.yml:
--------------------------------------------------------------------------------
1 | name: 刷步数
2 |
3 | on:
4 | push:
5 | branches: [ main ]
6 | pull_request:
7 | branches: [ main ]
8 | schedule:
9 | - cron: 0 10 * * *
10 | watch:
11 | types: started
12 |
13 | jobs:
14 | build:
15 | runs-on: ubuntu-latest
16 | if: github.event.repository.owner.id == github.event.sender.id
17 |
18 | steps:
19 | - uses: actions/checkout@v2
20 | - name: 初始化Python
21 | uses: actions/setup-python@v2
22 | with:
23 | python-version: 3.7
24 | - name: 开始
25 | run: |
26 | pip install requests
27 | pmode='${{ secrets.PMODE }}'
28 | pkey='${{ secrets.PKEY }}'
29 | user='${{ secrets.USER }}'
30 | pwd='${{ secrets.PWD }}'
31 | step='${{ secrets.STEP }}'
32 |
33 | python3 main.py ${pmode} ${pkey} ${user} ${pwd} ${step}
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Apache License
2 | Version 2.0, January 2004
3 | http://www.apache.org/licenses/
4 |
5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6 |
7 | 1. Definitions.
8 |
9 | "License" shall mean the terms and conditions for use, reproduction,
10 | and distribution as defined by Sections 1 through 9 of this document.
11 |
12 | "Licensor" shall mean the copyright owner or entity authorized by
13 | the copyright owner that is granting the License.
14 |
15 | "Legal Entity" shall mean the union of the acting entity and all
16 | other entities that control, are controlled by, or are under common
17 | control with that entity. For the purposes of this definition,
18 | "control" means (i) the power, direct or indirect, to cause the
19 | direction or management of such entity, whether by contract or
20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
21 | outstanding shares, or (iii) beneficial ownership of such entity.
22 |
23 | "You" (or "Your") shall mean an individual or Legal Entity
24 | exercising permissions granted by this License.
25 |
26 | "Source" form shall mean the preferred form for making modifications,
27 | including but not limited to software source code, documentation
28 | source, and configuration files.
29 |
30 | "Object" form shall mean any form resulting from mechanical
31 | transformation or translation of a Source form, including but
32 | not limited to compiled object code, generated documentation,
33 | and conversions to other media types.
34 |
35 | "Work" shall mean the work of authorship, whether in Source or
36 | Object form, made available under the License, as indicated by a
37 | copyright notice that is included in or attached to the work
38 | (an example is provided in the Appendix below).
39 |
40 | "Derivative Works" shall mean any work, whether in Source or Object
41 | form, that is based on (or derived from) the Work and for which the
42 | editorial revisions, annotations, elaborations, or other modifications
43 | represent, as a whole, an original work of authorship. For the purposes
44 | of this License, Derivative Works shall not include works that remain
45 | separable from, or merely link (or bind by name) to the interfaces of,
46 | the Work and Derivative Works thereof.
47 |
48 | "Contribution" shall mean any work of authorship, including
49 | the original version of the Work and any modifications or additions
50 | to that Work or Derivative Works thereof, that is intentionally
51 | submitted to Licensor for inclusion in the Work by the copyright owner
52 | or by an individual or Legal Entity authorized to submit on behalf of
53 | the copyright owner. For the purposes of this definition, "submitted"
54 | means any form of electronic, verbal, or written communication sent
55 | to the Licensor or its representatives, including but not limited to
56 | communication on electronic mailing lists, source code control systems,
57 | and issue tracking systems that are managed by, or on behalf of, the
58 | Licensor for the purpose of discussing and improving the Work, but
59 | excluding communication that is conspicuously marked or otherwise
60 | designated in writing by the copyright owner as "Not a Contribution."
61 |
62 | "Contributor" shall mean Licensor and any individual or Legal Entity
63 | on behalf of whom a Contribution has been received by Licensor and
64 | subsequently incorporated within the Work.
65 |
66 | 2. Grant of Copyright License. Subject to the terms and conditions of
67 | this License, each Contributor hereby grants to You a perpetual,
68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69 | copyright license to reproduce, prepare Derivative Works of,
70 | publicly display, publicly perform, sublicense, and distribute the
71 | Work and such Derivative Works in Source or Object form.
72 |
73 | 3. Grant of Patent License. Subject to the terms and conditions of
74 | this License, each Contributor hereby grants to You a perpetual,
75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76 | (except as stated in this section) patent license to make, have made,
77 | use, offer to sell, sell, import, and otherwise transfer the Work,
78 | where such license applies only to those patent claims licensable
79 | by such Contributor that are necessarily infringed by their
80 | Contribution(s) alone or by combination of their Contribution(s)
81 | with the Work to which such Contribution(s) was submitted. If You
82 | institute patent litigation against any entity (including a
83 | cross-claim or counterclaim in a lawsuit) alleging that the Work
84 | or a Contribution incorporated within the Work constitutes direct
85 | or contributory patent infringement, then any patent licenses
86 | granted to You under this License for that Work shall terminate
87 | as of the date such litigation is filed.
88 |
89 | 4. Redistribution. You may reproduce and distribute copies of the
90 | Work or Derivative Works thereof in any medium, with or without
91 | modifications, and in Source or Object form, provided that You
92 | meet the following conditions:
93 |
94 | (a) You must give any other recipients of the Work or
95 | Derivative Works a copy of this License; and
96 |
97 | (b) You must cause any modified files to carry prominent notices
98 | stating that You changed the files; and
99 |
100 | (c) You must retain, in the Source form of any Derivative Works
101 | that You distribute, all copyright, patent, trademark, and
102 | attribution notices from the Source form of the Work,
103 | excluding those notices that do not pertain to any part of
104 | the Derivative Works; and
105 |
106 | (d) If the Work includes a "NOTICE" text file as part of its
107 | distribution, then any Derivative Works that You distribute must
108 | include a readable copy of the attribution notices contained
109 | within such NOTICE file, excluding those notices that do not
110 | pertain to any part of the Derivative Works, in at least one
111 | of the following places: within a NOTICE text file distributed
112 | as part of the Derivative Works; within the Source form or
113 | documentation, if provided along with the Derivative Works; or,
114 | within a display generated by the Derivative Works, if and
115 | wherever such third-party notices normally appear. The contents
116 | of the NOTICE file are for informational purposes only and
117 | do not modify the License. You may add Your own attribution
118 | notices within Derivative Works that You distribute, alongside
119 | or as an addendum to the NOTICE text from the Work, provided
120 | that such additional attribution notices cannot be construed
121 | as modifying the License.
122 |
123 | You may add Your own copyright statement to Your modifications and
124 | may provide additional or different license terms and conditions
125 | for use, reproduction, or distribution of Your modifications, or
126 | for any such Derivative Works as a whole, provided Your use,
127 | reproduction, and distribution of the Work otherwise complies with
128 | the conditions stated in this License.
129 |
130 | 5. Submission of Contributions. Unless You explicitly state otherwise,
131 | any Contribution intentionally submitted for inclusion in the Work
132 | by You to the Licensor shall be under the terms and conditions of
133 | this License, without any additional terms or conditions.
134 | Notwithstanding the above, nothing herein shall supersede or modify
135 | the terms of any separate license agreement you may have executed
136 | with Licensor regarding such Contributions.
137 |
138 | 6. Trademarks. This License does not grant permission to use the trade
139 | names, trademarks, service marks, or product names of the Licensor,
140 | except as required for reasonable and customary use in describing the
141 | origin of the Work and reproducing the content of the NOTICE file.
142 |
143 | 7. Disclaimer of Warranty. Unless required by applicable law or
144 | agreed to in writing, Licensor provides the Work (and each
145 | Contributor provides its Contributions) on an "AS IS" BASIS,
146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147 | implied, including, without limitation, any warranties or conditions
148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149 | PARTICULAR PURPOSE. You are solely responsible for determining the
150 | appropriateness of using or redistributing the Work and assume any
151 | risks associated with Your exercise of permissions under this License.
152 |
153 | 8. Limitation of Liability. In no event and under no legal theory,
154 | whether in tort (including negligence), contract, or otherwise,
155 | unless required by applicable law (such as deliberate and grossly
156 | negligent acts) or agreed to in writing, shall any Contributor be
157 | liable to You for damages, including any direct, indirect, special,
158 | incidental, or consequential damages of any character arising as a
159 | result of this License or out of the use or inability to use the
160 | Work (including but not limited to damages for loss of goodwill,
161 | work stoppage, computer failure or malfunction, or any and all
162 | other commercial damages or losses), even if such Contributor
163 | has been advised of the possibility of such damages.
164 |
165 | 9. Accepting Warranty or Additional Liability. While redistributing
166 | the Work or Derivative Works thereof, You may choose to offer,
167 | and charge a fee for, acceptance of support, warranty, indemnity,
168 | or other liability obligations and/or rights consistent with this
169 | License. However, in accepting such obligations, You may act only
170 | on Your own behalf and on Your sole responsibility, not on behalf
171 | of any other Contributor, and only if You agree to indemnify,
172 | defend, and hold each Contributor harmless for any liability
173 | incurred by, or claims asserted against, such Contributor by reason
174 | of your accepting any such warranty or additional liability.
175 |
176 | END OF TERMS AND CONDITIONS
177 |
178 | APPENDIX: How to apply the Apache License to your work.
179 |
180 | To apply the Apache License to your work, attach the following
181 | boilerplate notice, with the fields enclosed by brackets "[]"
182 | replaced with your own identifying information. (Don't include
183 | the brackets!) The text should be enclosed in the appropriate
184 | comment syntax for the file format. We also recommend that a
185 | file or class name and description of purpose be included on the
186 | same "printed page" as the copyright notice for easier
187 | identification within third-party archives.
188 |
189 | Copyright [yyyy] [name of copyright owner]
190 |
191 | Licensed under the Apache License, Version 2.0 (the "License");
192 | you may not use this file except in compliance with the License.
193 | You may obtain a copy of the License at
194 |
195 | http://www.apache.org/licenses/LICENSE-2.0
196 |
197 | Unless required by applicable law or agreed to in writing, software
198 | distributed under the License is distributed on an "AS IS" BASIS,
199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200 | See the License for the specific language governing permissions and
201 | limitations under the License.
202 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Mimotion
2 | # 请不要点自己项目的 Create pull request 不要提起无意义的pr,否则你将会被我拉黑!
3 | # 请不要点自己项目的 Create pull request 不要提起无意义的pr,否则你将会被我拉黑!
4 | # 请不要点自己项目的 Create pull request 不要提起无意义的pr,否则你将会被我拉黑!
5 | # 小米运动自动刷步数
6 |
7 | > 小米运动自动刷步数
8 |
9 | ## Github Actions 部署指南
10 |
11 | ### 一、Fork 此仓库
12 |
13 | ### 二、设置账号密码
14 | > 前往: Settings-->Secrets-->Actions-->New repository secret
15 |
16 | > 依次添加名为: **PMODE**、**PKEY**、**USER**、**PWD**、**STEP**
17 |
18 | #### 例如
19 |
20 | 
21 |
22 | #### 参数详解
23 |
24 | | Secrets | 格式 |
25 | | -------- | ----- |
26 | | PMODE | 推送模式,server酱推送:`wx` 新server酱推送:`nwx` tg推送:`tg` 企业微信推送:`qwx` PushPlus推送:`pp` 关闭推送:`off`|
27 | | PKEY | 推送key,详见PKEY参数解释|
28 | | USER | 账号,仅支持手机号|
29 | | PWD | 密码|
30 | | STEP | 步数:0则为1w-2w之间随机,自定义随机范围: `18000-25000`|
31 |
32 | | PKEY参数解释 | 格式 |
33 | | -------- | ----- |
34 | | TG推送 | `token@userid`|
35 | | Server酱推送 | `填写server酱的推送key`|
36 | | 企业微信推送 | `推送用户(可@all)-corpid-corpsecret-(agentid 空则为默认1000002)`|
37 | | PushPlus推送 | `token`|
38 | | 关闭推送 | `off`|
39 |
40 | ### 三、多账户(用不上请忽略)
41 |
42 | 多账户请用 **#** 分割 然后保存到变量 **USER** 和 **PWD**
43 |
44 | #### 例如
45 |
46 | **13800138000#13800138001** 变量 **USER**
47 |
48 | **abc123qwe#abcqwe2** 变量 **PWD**
49 |
50 | ### 四、自定义启动时间
51 |
52 | 编辑 **.github/workflows/run.yml**
53 |
54 | 找到 cron: 0 10 * * *
55 |
56 | 修改其中的10为你要的时间
57 |
58 | 需要运行的时间-8就是UTC时间
59 |
60 | ## 注意事项
61 |
62 | 1. 每天运行一次,在下午 6 点
63 |
64 | 2. 多账户的数量和密码请一定要对上 不然无法使用!!!
65 |
66 | 3. 启动时间得是UTC时间!
67 |
68 | 4. server酱注册地址 [点我](https://sct.ftqq.com/)
69 |
70 | 5. 如果支付宝没有更新步数,到小米运动->设置->账号->注销账号->清空数据,然后重新登录,重新绑定第三方
71 |
72 | 6. 小米运动不会更新步数,只有关联的会同步!!!!!
73 |
74 | 7. 请各位在使用时Fork[主分支](https://github.com/577fkj/mimotion/),防止出现不必要的bug.
75 |
76 | 8. TG推送教程 [点我](./TG_PUSH.md)
77 |
78 | 9. 请注意,账号不是 [小米账号],而是 [小米运动] 的账号。
79 |
80 | ## 纪念一下往日的辉煌
81 |
82 | [](https://i.loli.net/2021/11/19/BLi5cpjPSxh7Am2.png)
83 |
84 | ## 历史Star数
85 |
86 | [](https://starchart.cc/577fkj/mimotion)
87 |
--------------------------------------------------------------------------------
/TG_PUSH.md:
--------------------------------------------------------------------------------
1 | **TG_PUSH教程**
2 |
3 | 如何获取token以及UserID
4 |
5 | Ⅰ.首先在Telegram上搜索[BotFather](https://t.me/BotFather)机器人
6 |
7 | 
8 |
9 | Ⅱ.利用[BotFather](https://t.me/BotFather)创建一个属于自己的通知机器人,按照下图中的1、2、3步骤拿到token,格式形如```10xxx4:AAFcqxxxxgER5uw```。
10 |
11 | 
12 |
13 | **新创建的机器人需要跟它发一条消息来开启对话,否则可能会遇到PEKY填对了但是收不到消息的情况**
14 |
15 | Ⅲ.再次在Telegram上搜索[getuserIDbot](https://t.me/getuserIDbot)机器人,获取UserID。
16 |
17 | 
18 |
--------------------------------------------------------------------------------
/main.py:
--------------------------------------------------------------------------------
1 | """
2 | 主程序脚本
3 | """
4 | # -*- coding: utf8 -*-
5 | # python >=3.8
6 |
7 | import json
8 | import random
9 | import re
10 | import json
11 | import sys
12 | import time
13 | from urllib.parse import quote
14 |
15 | import requests
16 |
17 | now = time.strftime("%Y-%m-%d %H:%M:%S", time.localtime())
18 | headers = {
19 | 'User-Agent': 'Dalvik/2.1.0 (Linux; U; Android 9; MI 6 MIUI/20.6.18)'
20 | }
21 |
22 |
23 | def get_code(location):
24 | """
25 | 获取登录code
26 | """
27 | code_pattern = re.compile("(?<=access=).*?(?=&)")
28 | code = code_pattern.findall(location)[0]
29 | return code
30 |
31 |
32 | def login(_user, password):
33 | """
34 | 登录
35 | """
36 | url1 = "https://api-user.huami.com/registrations/+86" + _user + "/tokens"
37 | _headers = {
38 | "Content-Type": "application/x-www-form-urlencoded;charset=UTF-8",
39 | "User-Agent": "MiFit/4.6.0 (iPhone; iOS 14.0.1; Scale/2.00)"
40 | }
41 | data1 = {
42 | "client_id": "HuaMi",
43 | "password": f"{password}",
44 | "redirect_uri": "https://s3-us-west-2.amazonaws.com/hm-registration/successsignin.html",
45 | "token": "access"
46 | }
47 | r1 = requests.post(url1, data=data1, headers=_headers, allow_redirects=False)
48 | try:
49 | location = r1.headers["Location"]
50 | code = get_code(location)
51 | except:
52 | return 0, 0
53 | # print("access_code获取成功!")
54 | # print(code)
55 |
56 | url2 = "https://account.huami.com/v2/client/login"
57 | data2 = {
58 | "app_name": "com.xiaomi.hm.health",
59 | "app_version": "4.6.0",
60 | "code": f"{code}",
61 | "country_code": "CN",
62 | "device_id": "2C8B4939-0CCD-4E94-8CBA-CB8EA6E613A1",
63 | "device_model": "phone",
64 | "grant_type": "access_token",
65 | "third_name": "huami_phone",
66 | }
67 | r2 = requests.post(url2, data=data2, headers=_headers).json()
68 | login_token = r2["token_info"]["login_token"]
69 | # print("login_token获取成功!")
70 | # print(login_token)
71 | userid = r2["token_info"]["user_id"]
72 | # print("userid获取成功!")
73 | # print(userid)
74 |
75 | return login_token, userid
76 |
77 |
78 | def main(_user, _passwd, _step):
79 | """
80 | 主函数
81 | """
82 | _user = str(_user)
83 | password = str(_passwd)
84 | _step = str(_step)
85 | if _user == '' or password == '':
86 | print("用户名或密码不能为空!")
87 | return "user and passwd not empty!"
88 |
89 | if _step == '':
90 | print("已设置为随机步数(10000-19999)")
91 | _step = str(random.randint(10000, 19999))
92 | login_token, userid = login(_user, password)
93 | if login_token == 0:
94 | print("登陆失败!")
95 | return "login fail!"
96 |
97 | t = get_time()
98 |
99 | app_token = get_app_token(login_token)
100 |
101 | today = time.strftime("%F")
102 |
103 | summary = {
104 | "v": 6,
105 | "slp": {
106 | "st": int(time.time()),
107 | "ed": int(time.time()),
108 | "dp": 0,
109 | "lt": 0,
110 | "wk": 0,
111 | "usrSt": -1440,
112 | "usrEd": -1440,
113 | "wc": 0,
114 | "is": 0,
115 | "lb": 0,
116 | "to": 0,
117 | "dt": 0,
118 | "rhr": 0,
119 | "ss": 0
120 | },
121 | "stp": {
122 | "ttl": _step,
123 | "dis": 10627,
124 | "cal": 510,
125 | "wk": 41,
126 | "rn": 50,
127 | "runDist": 7654,
128 | "runCal": 397,
129 | "stage": [
130 | {
131 | "start": 327,
132 | "stop": 341,
133 | "mode": 1,
134 | "dis": 481,
135 | "cal": 13,
136 | "step": 680
137 | },
138 | {
139 | "start": 342,
140 | "stop": 367,
141 | "mode": 3,
142 | "dis": 2295,
143 | "cal": 95,
144 | "step": 2874
145 | },
146 | {
147 | "start": 368,
148 | "stop": 377,
149 | "mode": 4,
150 | "dis": 1592,
151 | "cal": 88,
152 | "step": 1664
153 | },
154 | {
155 | "start": 378,
156 | "stop": 386,
157 | "mode": 3,
158 | "dis": 1072,
159 | "cal": 51,
160 | "step": 1245
161 | },
162 | {
163 | "start": 387,
164 | "stop": 393,
165 | "mode": 4,
166 | "dis": 1036,
167 | "cal": 57,
168 | "step": 1124
169 | },
170 | {
171 | "start": 394,
172 | "stop": 398,
173 | "mode": 3,
174 | "dis": 488,
175 | "cal": 19,
176 | "step": 607
177 | },
178 | {
179 | "start": 399,
180 | "stop": 414,
181 | "mode": 4,
182 | "dis": 2220,
183 | "cal": 120,
184 | "step": 2371
185 | },
186 | {
187 | "start": 415,
188 | "stop": 427,
189 | "mode": 3,
190 | "dis": 1268,
191 | "cal": 59,
192 | "step": 1489
193 | },
194 | {
195 | "start": 428,
196 | "stop": 433,
197 | "mode": 1,
198 | "dis": 152,
199 | "cal": 4,
200 | "step": 238
201 | },
202 | {
203 | "start": 434,
204 | "stop": 444,
205 | "mode": 3,
206 | "dis": 2295,
207 | "cal": 95,
208 | "step": 2874
209 | },
210 | {
211 | "start": 445,
212 | "stop": 455,
213 | "mode": 4,
214 | "dis": 1592,
215 | "cal": 88,
216 | "step": 1664
217 | },
218 | {
219 | "start": 456,
220 | "stop": 466,
221 | "mode": 3,
222 | "dis": 1072,
223 | "cal": 51,
224 | "step": 1245
225 | },
226 | {
227 | "start": 467,
228 | "stop": 477,
229 | "mode": 4,
230 | "dis": 1036,
231 | "cal": 57,
232 | "step": 1124
233 | },
234 | {
235 | "start": 478,
236 | "stop": 488,
237 | "mode": 3,
238 | "dis": 488,
239 | "cal": 19,
240 | "step": 607
241 | },
242 | {
243 | "start": 489,
244 | "stop": 499,
245 | "mode": 4,
246 | "dis": 2220,
247 | "cal": 120,
248 | "step": 2371
249 | },
250 | {
251 | "start": 500,
252 | "stop": 511,
253 | "mode": 3,
254 | "dis": 1268,
255 | "cal": 59,
256 | "step": 1489
257 | },
258 | {
259 | "start": 512,
260 | "stop": 522,
261 | "mode": 1,
262 | "dis": 152,
263 | "cal": 4,
264 | "step": 238
265 | }
266 | ]
267 | },
268 | "goal": 8000,
269 | "tz": "28800"
270 | }
271 |
272 | data_json = [
273 | {
274 | "data_hr": "//////9L////////////Vv///////////0v///////////9e/////0n/a///S////////////0b//////////1FK////////////R/////////////////9PTFFpaf9L////////////R////////////0j///////////9K////////////Ov///////////zf///86/zr/Ov88/zf/Pf///0v/S/8/////////////Sf///////////z3//////0r/Ov//////S/9L/zb/Sf9K/0v/Rf9H/zj/Sf9K/0//N////0D/Sf83/zr/Pf9M/0v/Ov9e////////////S////////////zv//z7/O/83/zv/N/83/zr/N/86/z//Nv83/zn/Xv84/zr/PP84/zj/N/9e/zr/N/89/03/P/89/z3/Q/9N/0v/Tv9C/0H/Of9D/zz/Of88/z//PP9A/zr/N/86/zz/Nv87/0D/Ov84/0v/O/84/zf/MP83/zH/Nv83/zf/N/84/zf/Of82/zf/OP83/zb/Mv81/zX/R/9L/0v/O/9I/0T/S/9A/zn/Pf89/zn/Nf9K/07/N/83/zn/Nv83/zv/O/9A/0H/Of8//zj/PP83/zj/S/87/zj/Nv84/zf/Of83/zf/Of83/zb/Nv9L/zj/Nv82/zb/N/85/zf/N/9J/zf/Nv83/zj/Nv84/0r/Sv83/zf/MP///zb/Mv82/zb/Of85/z7/Nv8//0r/S/85/0H/QP9B/0D/Nf89/zj/Ov83/zv/Nv8//0f/Sv9O/0ZeXv///////////1X///////////9B////////////TP///1b//////0////////////9N/////////v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v7+/v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fgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAA",
281 | "tz": 32,
282 | "did": "DA932FFFFE8816E7",
283 | "src": 24
284 | }
285 | ],
286 | "summary": json.dumps(summary),
287 | "source": 24,
288 | "type": 0
289 | }
290 | ]
291 |
292 | url = f'https://api-mifit-cn.huami.com/v1/data/band_data.json?&t={t}'
293 | head = {
294 | "apptoken": app_token,
295 | "Content-Type": "application/x-www-form-urlencoded"
296 | }
297 |
298 | data = f'userid={userid}&last_sync_data_time=1597306380&device_type=0&last_deviceid=DA932FFFFE8816E7&data_json={quote(json.dumps(data_json))}'
299 |
300 | response = requests.post(url, data=data, headers=head).json()
301 | # print(response)
302 | result = f"{_user[:4]}****{_user[-4:]}: [{now}] 修改步数({_step})" + response['message']
303 | print(result)
304 | return result
305 |
306 |
307 | def get_time():
308 | """
309 | 获取时间戳
310 | """
311 | url = 'http://api.m.taobao.com/rest/api3.do?api=mtop.common.getTimestamp'
312 | response = requests.get(url, headers=headers).json()
313 | t = response['data']['t']
314 | return t
315 |
316 |
317 | def get_app_token(login_token):
318 | """
319 | 获取app_token
320 | """
321 | url = f"https://account-cn.huami.com/v1/client/app_tokens" \
322 | f"?app_name=com.xiaomi.hm.health&dn=api-user.huami.com%2Capi-mifit.huami.com%2Capp-analytics.huami.com" \
323 | f"&login_token={login_token}"
324 | response = requests.get(url, headers=headers).json()
325 | app_token = response['token_info']['app_token']
326 | # print("app_token获取成功!")
327 | # print(app_token)
328 | return app_token
329 |
330 |
331 | def push_wx(_sckey, desp=""):
332 | """
333 | 推送server酱
334 | """
335 | if _sckey == '':
336 | print("[注意] 未提供sckey,不进行推送!")
337 | else:
338 | server_url = f"https://sc.ftqq.com/{_sckey}.send"
339 | params = {
340 | "text": '小米运动 步数修改',
341 | "desp": desp
342 | }
343 |
344 | response = requests.get(server_url, params=params)
345 | json_data = response.json()
346 |
347 | if json_data['errno'] == 0:
348 | print(f"[{now}] 推送成功。")
349 | else:
350 | print(f"[{now}] 推送失败:{json_data['errno']}({json_data['errmsg']})")
351 |
352 |
353 | def push_server(_sckey, desp=""):
354 | """
355 | 推送消息到微信
356 | """
357 | if _sckey == '':
358 | print("[注意] 未提供sckey,不进行微信推送!")
359 | else:
360 | server_url = f"https://sctapi.ftqq.com/{_sckey}.send"
361 | params = {
362 | "title": '小米运动 步数修改',
363 | "desp": desp
364 | }
365 |
366 | response = requests.get(server_url, params=params)
367 | json_data = response.json()
368 |
369 | if json_data['code'] == 0:
370 | print(f"[{now}] 推送成功。")
371 | else:
372 | print(f"[{now}] 推送失败:{json_data['code']}({json_data['message']})")
373 |
374 |
375 | def push_pushplus(token, content=""):
376 | """
377 | 推送消息到pushplus
378 | """
379 | if token == '':
380 | print("[注意] 未提供token,不进行pushplus推送!")
381 | else:
382 | server_url = "http://www.pushplus.plus/send"
383 | params = {
384 | "token": token,
385 | "title": '小米运动 步数修改',
386 | "content": content
387 | }
388 |
389 | response = requests.get(server_url, params=params)
390 | json_data = response.json()
391 |
392 | if json_data['code'] == 200:
393 | print(f"[{now}] 推送成功。")
394 | else:
395 | print(f"[{now}] 推送失败:{json_data['code']}({json_data['message']})")
396 |
397 |
398 | def push_tg(token, chat_id, desp=""):
399 | """
400 | 推送消息到TG
401 | """
402 | if token == '':
403 | print("[注意] 未提供token,不进行tg推送!")
404 | elif chat_id == '':
405 | print("[注意] 未提供chat_id,不进行tg推送!")
406 | else:
407 | server_url = f"https://api.telegram.org/bot{token}/sendmessage"
408 | params = {
409 | "text": '小米运动 步数修改\n\n' + desp,
410 | "chat_id": chat_id
411 | }
412 |
413 | response = requests.get(server_url, params=params)
414 | json_data = response.json()
415 |
416 | if json_data['ok']:
417 | print(f"[{now}] 推送成功。")
418 | else:
419 | print(f"[{now}] 推送失败:{json_data['error_code']}({json_data['description']})")
420 |
421 |
422 | def wxpush(msg, usr, corpid, corpsecret, agentid=1000002):
423 | """
424 | 企业微信推送
425 | """
426 | base_url = 'https://qyapi.weixin.qq.com/cgi-bin/gettoken?'
427 | req_url = 'https://qyapi.weixin.qq.com/cgi-bin/message/send?access_token='
428 | corpid = corpid
429 | corpsecret = corpsecret
430 | agentid = agentid
431 |
432 | if agentid == 0:
433 | agentid = 1000002
434 |
435 | def get_access_token(_base_url, _corpid, _corpsecret):
436 | """
437 | 获取access_token,每次的access_token都不一样,所以需要运行一次请求一次
438 | """
439 | urls = _base_url + 'corpid=' + _corpid + '&corpsecret=' + _corpsecret
440 | resp = requests.get(urls).json()
441 | access_token = resp['access_token']
442 | return access_token
443 |
444 | def send_message(_msg, _usr):
445 | """
446 | 发送消息
447 | """
448 | data = get_message(_msg, _usr)
449 | req_urls = req_url + get_access_token(base_url, corpid, corpsecret)
450 | res = requests.post(url=req_urls, data=data)
451 | ret = res.json()
452 | if ret["errcode"] == 0:
453 | print(f"[{now}] 企业微信推送成功")
454 | else:
455 | print(f"[{now}] 推送失败:{ret['errcode']} 错误信息:{ret['errmsg']}")
456 |
457 | def get_message(_msg, _usr):
458 | """
459 | 获取消息
460 | """
461 | data = {
462 | "touser": _usr,
463 | "toparty": "@all",
464 | "totag": "@all",
465 | "msgtype": "text",
466 | "agentid": agentid,
467 | "text": {
468 | "content": _msg
469 | },
470 | "safe": 0,
471 | "enable_id_trans": 0,
472 | "enable_duplicate_check": 0,
473 | "duplicate_check_interval": 1800
474 | }
475 | data = json.dumps(data)
476 | return data
477 |
478 | msg = msg
479 | usr = usr
480 | if corpid == '':
481 | print("[注意] 未提供corpid,不进行企业微信推送!")
482 | elif corpsecret == '':
483 | print("[注意] 未提供corpsecret,不进行企业微信推送!")
484 | else:
485 | send_message(msg, usr)
486 |
487 |
488 | class ToPush:
489 | """
490 | 推送接口类
491 | 处理pkey并转发推送消息到推送函数
492 | """
493 | push_msg: str
494 |
495 | def __init__(self, _pkey):
496 | self.pkey = _pkey
497 |
498 | def to_push_wx(self):
499 | """
500 | 推送server酱接口
501 | """
502 | if str(self.pkey) == '0':
503 | self.pkey = ''
504 | push_wx(self.pkey, self.push_msg)
505 |
506 | def to_push_server(self):
507 | """
508 | 推送消息到微信接口
509 | """
510 | if str(self.pkey) == '0':
511 | self.pkey = ''
512 | push_server(self.pkey, self.push_msg)
513 |
514 | def to_push_tg(self):
515 | """
516 | 推送消息到TG接口
517 | """
518 | try:
519 | token, chat_id = self.pkey.split('@')
520 | push_tg(token, chat_id, self.push_msg)
521 | except ValueError:
522 | print('tg推送参数有误!')
523 |
524 | def to_wxpush(self):
525 | """
526 | 企业微信推送接口
527 | """
528 | try:
529 | usr, corpid, corpsecret, *agentid = self.pkey.split('-')
530 | if agentid:
531 | wxpush(self.push_msg, usr, corpid, corpsecret, int(agentid[0]))
532 | else:
533 | wxpush(self.push_msg, usr, corpid, corpsecret)
534 | except ValueError:
535 | print('企业微信推送参数有误!')
536 |
537 | def to_push_pushplus(self):
538 | """
539 | 接口
540 | """
541 | if self.pkey == '':
542 | print('pushplus token错误')
543 | else:
544 | push_pushplus(self.pkey, self.push_msg)
545 |
546 | @staticmethod
547 | def no_push():
548 | """
549 | 不推送
550 | """
551 | print('不推送')
552 |
553 |
554 | if __name__ == "__main__":
555 | # Push Mode
556 | # print(sys.argv)
557 | try:
558 | Pm = sys.argv[1]
559 | pkey = sys.argv[2]
560 |
561 | to_push = ToPush(pkey)
562 |
563 | # 用户名(格式为 13800138000)
564 | user = sys.argv[3]
565 | # 登录密码
566 | passwd = sys.argv[4]
567 | # 要修改的步数,直接输入想要修改的步数值,0为随机步数
568 | step = sys.argv[5].replace('[', '').replace(']', '')
569 | except IndexError as e:
570 | print("参数有误: " + str(e))
571 | exit(1)
572 |
573 | user_list = user.split('#')
574 | passwd_list = passwd.split('#')
575 | setp_array = step.split('-')
576 |
577 | if len(user_list) == len(passwd_list):
578 | to_push.push_msg = ''
579 | for user, passwd in zip(user_list, passwd_list):
580 | if len(setp_array) == 2:
581 | step = str(random.randint(int(setp_array[0]), int(setp_array[1])))
582 | print(f"已设置为随机步数({setp_array[0]}-{setp_array[1]})")
583 | elif str(step) == '0':
584 | step = ''
585 | to_push.push_msg += main(user, passwd, step) + '\n'
586 |
587 | push = {
588 | 'wx': to_push.to_push_wx,
589 | 'nwx': to_push.to_push_server,
590 | 'tg': to_push.to_push_tg,
591 | 'qwx': to_push.to_wxpush,
592 | 'pp': to_push.to_push_pushplus,
593 | 'off': to_push.no_push
594 | }
595 | try:
596 | push[Pm]()
597 | except KeyError:
598 | print('推送选项有误!')
599 | exit(0)
600 | else:
601 | print('用户名和密码数量不对')
602 |
--------------------------------------------------------------------------------