├── .gitattributes ├── .github └── workflows │ ├── cron.yml │ ├── run.yml │ └── sync2gitee.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/cron.yml: -------------------------------------------------------------------------------- 1 | name: 随机定时运行 2 | on: 3 | workflow_run: 4 | workflows: ["刷步数"] 5 | types: 6 | - completed 7 | jobs: 8 | repo-sync: 9 | runs-on: ubuntu-latest 10 | timeout-minutes: 3 11 | if: github.event.workflow_run.conclusion == 'success' 12 | steps: 13 | - uses: actions/checkout@v4 14 | with: 15 | token: ${{ secrets.PAT }} #此处PAT需要申请,教程详见:https://www.jianshu.com/p/bb82b3ad1d11,需要repo和workflow权限 16 | - name: random cron 17 | run: | 18 | sed -i -E "s/(- cron: ')[0-9]+( [^[:space:]]+ \* \* \*')/\1$(($RANDOM % 10))\2/g" .github/workflows/run.yml 19 | git config user.name github-actions 20 | git config user.email github-actions@github.com 21 | git add . 22 | git commit -m "random cron." 23 | git push origin master 24 | -------------------------------------------------------------------------------- /.github/workflows/run.yml: -------------------------------------------------------------------------------- 1 | name: 刷步数 2 | 3 | on: 4 | #push: 5 | # branches: [ master ] 6 | #pull_request: 7 | # branches: [ master ] 8 | schedule: 9 | - cron: '1 0,2,5,7,9,11,12 * * *' 10 | watch: 11 | types: started 12 | workflow_dispatch: 13 | 14 | jobs: 15 | build: 16 | runs-on: ubuntu-latest 17 | steps: 18 | - name: Checkout codes 19 | uses: actions/checkout@v4 20 | - name: Update system and install zsh 21 | run: | 22 | sudo -E apt-get -qq update 23 | sudo -E apt-get install zsh -y 24 | 25 | - name: 初始化Python 26 | uses: actions/setup-python@v5 27 | with: 28 | python-version: 3.8 29 | - name: 开始 30 | env: 31 | CONFIG: ${{ secrets.CONFIG }} 32 | run: | 33 | pip install --upgrade pip 34 | pip3 install requests 35 | python3 main.py 36 | -------------------------------------------------------------------------------- /.github/workflows/sync2gitee.yml: -------------------------------------------------------------------------------- 1 | # 通过 Github actions, 在 Github 仓库的每一次 commit 后自动同步到 Gitee 上 2 | name: sync2gitee 3 | on: 4 | workflow_run: 5 | workflows: ["随机定时运行"] 6 | types: 7 | - completed 8 | 9 | jobs: 10 | repo-sync: 11 | env: 12 | dst_key: ${{ secrets.GITEE_PRIVATE_KEY }} 13 | dst_token: ${{ secrets.GITEE_TOKEN }} 14 | gitee_user: ${{ secrets.GITEE_USER }} 15 | runs-on: ubuntu-latest 16 | steps: 17 | - uses: actions/checkout@v4 18 | with: 19 | persist-credentials: false 20 | - name: sync github -> gitee 21 | uses: Yikun/hub-mirror-action@master 22 | if: env.dst_key && env.dst_token && env.gitee_user 23 | with: 24 | # 必选,需要同步的 Github 用户(源) 25 | src: 'github/${{ github.repository_owner }}' 26 | # 必选,需要同步到的 Gitee 用户(目的) 27 | dst: 'gitee/${{ secrets.GITEE_USER }}' 28 | # 必选,Gitee公钥对应的私钥,https://gitee.com/profile/sshkeys 29 | dst_key: ${{ secrets.GITEE_PRIVATE_KEY }} 30 | # 必选,Gitee对应的用于创建仓库的token,https://gitee.com/profile/personal_access_tokens 31 | dst_token: ${{ secrets.GITEE_TOKEN }} 32 | # 如果是组织,指定组织即可,默认为用户 user 33 | # account_type: org 34 | # 直接取当前项目的仓库名 35 | static_list: ${{ github.event.repository.name }} 36 | # 还有黑、白名单,静态名单机制,可以用于更新某些指定库 37 | # static_list: 'repo_name,repo_name2' 38 | # black_list: 'repo_name,repo_name2' 39 | # white_list: 'repo_name,repo_name2' 40 | -------------------------------------------------------------------------------- /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 | ![ 刷步数](https://github.com/xunichanghuan/mimotion-run/actions/workflows/run.yml/badge.svg) 3 | [![GitHub forks](https://img.shields.io/github/forks/xunichanghuan/mimotion-run?style=flat-square)](https://github.com/xunichanghuan/mimotion-run/network) 4 | [![GitHub stars](https://img.shields.io/github/stars/xunichanghuan/mimotion-run?style=flat-square)](https://github.com/xunichanghuan/mimotion-run/stargazers) 5 | [![GitHub issues](https://img.shields.io/github/issues/xunichanghuan/mimotion-run?style=flat-square)](https://github.com/xunichanghuan/mimotion-run/issues) 6 | 7 | # 小米运动自动刷步数 8 | 9 | > 小米运动自动刷步数 10 | 11 | ## Github Actions 部署指南 12 | 13 | ### 一、Fork 此仓库 14 | 15 | ### 二、设置账号密码 16 | # 20230224新增 17 | 添加名为 **CONFIG**的变量: Settings-->Secrets-->New secret ,使用下面json模板配置多账户,支持邮箱,手机号 18 | ``` 19 | { 20 | "TG_BOT_TOKEN": "telegram TG_BOT_TOKEN,如果没有,请留空", 21 | "TG_USER_ID": "telegram TG_USER_ID,如果没有,请留空", 22 | "SKEY": "酷推skey,如果没有,请留空", 23 | "SCKEY": "server酱sckey,如果没有,请留空", 24 | "POSITION": "是否开启企业微信推送,如果没有,请留空", 25 | "CORPID": "企业ID, 登陆企业微信,在我的企业-->企业信息里查看,如果没有,请留空", 26 | "CORPSECRET": "企业微信自建自建应用,每个自建应用里都有单独的secret,如果没有,请留空", 27 | "AGENTID": "填写你的企业微信自建应用ID,不加引号,是个整型常数,就是AgentId,如果没有,请留空", 28 | "TOUSER": "指定接收消息的成员,成员ID列表(多个接收者用”¦”分隔,最多支持1000个)。特殊情况:指定为”@all”,则向该企业应用的全部成员发送如果没有,请留空", 29 | "TOPARTY": "指定接收消息的部门,部门ID列表,多个接收者用”¦”分隔,最多支持100个。当touser为”@all”时填写”@all”,如果没有,请留空", 30 | "TOTAG": "指定接收消息的标签,标签ID列表,多个接收者用”¦”分隔,最多支持100个。当touser为”@all”时填写”@all”,如果没有,请留空", 31 | "OPEN_GET_WEATHER": "开启根据地区天气情况降低步数,如果没有,请留空", 32 | "AREA": "设置获取天气的地区(上面开启后必填)如 北京 ,如果没有,请留空", 33 | "QWEATHER": "此处填写和风天气 Private KEY,申请地址https://console.qweather.com/#/apps,如果没有,请留空", 34 | "MIMOTION": [ 35 | { 36 | "max_step": "20000", 37 | "min_step": "10000", 38 | "password": "Sitoi", 39 | "user": "18888xxxxxx" 40 | }, 41 | { 42 | "max_step": "多账号 最大步数填写,请参考上面", 43 | "min_step": "多账号 最小步数填写,请参考上面", 44 | "password": "多账号 密码填写,请参考上面", 45 | "user": "多账号 手机号填写,请参考上面" 46 | } 47 | ] 48 | } 49 | ``` 50 | > 添加名为 **PAT** 的变量: Settings-->Secrets-->New secret 51 | 52 | | Secrets | 格式 | 53 | | -------- | ----- | 54 | | PAT | 此处**PAT**需要申请,值为github token,教程详见:https://www.jianshu.com/p/bb82b3ad1d11 ,需要repo和workflow权限,此项必填,避免git push的权限错误。 | 55 | 56 | **CONFIG**示例 57 | ``` 58 | { 59 | "TG_BOT_TOKEN": "", 60 | "TG_USER_ID": "", 61 | "SKEY": "", 62 | "SCKEY": "", 63 | "POSITION": "", 64 | "CORPID": "", 65 | "CORPSECRET": "", 66 | "AGENTID": "", 67 | "TOUSER": "", 68 | "TOPARTY": "", 69 | "TOTAG": "", 70 | "OPEN_GET_WEATHER": "", 71 | "AREA": "", 72 | "QWEATHER": "", 73 | "MIMOTION": [ 74 | { 75 | "max_step": "20000", 76 | "min_step": "10000", 77 | "password": "Sitoi", 78 | "user": "18888xxxxxx" 79 | }, 80 | { 81 | "max_step": "多账号 最大步数填写,请参考上面", 82 | "min_step": "多账号 最小步数填写,请参考上面", 83 | "password": "多账号 密码填写,请参考上面", 84 | "user": "多账号 手机号填写,请参考上面" 85 | } 86 | ] 87 | } 88 | ``` 89 | 90 | ### 三、自定义启动时间 91 | 92 | 编辑 **random_cron.sh** 93 | 修改其中**if**语句的判断时间为UTC时间,即**北京时间-8**,如北京时间8点为UTC时间0点,需要运行的时间-8就是UTC时间 94 | 95 | 96 | 97 | ## 注意事项 98 | 99 | 1. 每天运行七次,由random_cron.sh控制,分钟为随机值 100 | 101 | 2. 多账户的数量和密码请一定要对上 不然无法使用!!! 102 | 103 | 3. 启动时间得是UTC时间! 104 | 105 | 4. server酱注册地址 [点我](https://sct.ftqq.com/) 106 | 107 | 5. 如果支付宝没有更新步数,到小米运动->设置->账号->注销账号->清空数据,然后重新登录,重新绑定第三方 108 | 109 | 6. 小米运动不会更新步数,只有关联的会同步!!!!! 110 | 111 | 7. 请各位在使用时Fork[主分支](https://github.com/xunichanghuan/mimotion-run/),防止出现不必要的bug. 112 | 113 | 8. 请注意,账号不是 [小米账号],而是 [小米运动] 的账号。 114 | 115 | ## 历史Star数 116 | 117 | [![Stargazers over time](https://starchart.cc/xunichanghuan/mimotion-run.svg)](https://starchart.cc/xunichanghuan/mimotion-run) 118 | -------------------------------------------------------------------------------- /TG_PUSH.md: -------------------------------------------------------------------------------- 1 | **TG_PUSH教程** 2 | 3 | 如何获取token以及UserID 4 | 5 | Ⅰ.首先在Telegram上搜索[BotFather](https://t.me/BotFather)机器人
6 | 7 | ![TG_PUSH1](https://gitee.com/lxk0301/jd_docker/raw/master/icon/TG_PUSH1.png) 8 | 9 | Ⅱ.利用[BotFather](https://t.me/BotFather)创建一个属于自己的通知机器人,按照下图中的1、2、3步骤拿到token,格式形如```10xxx4:AAFcqxxxxgER5uw```。
10 | 11 | ![TG_PUSH2](https://gitee.com/lxk0301/jd_docker/raw/master/icon/TG_PUSH2.png)
12 | 13 | **新创建的机器人需要跟它发一条消息来开启对话,否则可能会遇到PEKY填对了但是收不到消息的情况**
14 | 15 | Ⅲ.再次在Telegram上搜索[getuserIDbot](https://t.me/getuserIDbot)机器人,获取UserID。
16 | 17 | ![TG_PUSH3](https://gitee.com/lxk0301/jd_docker/raw/master/icon/TG_PUSH3.png) 18 | -------------------------------------------------------------------------------- /main.py: -------------------------------------------------------------------------------- 1 | # -*- coding: utf8 -*- 2 | import requests, time, datetime, re, sys, os, json, random, math, traceback 3 | global skey,sckey,base_url,req_url,corpid,corpsecret,agentid,touser,toparty,totag,open_get_weather,area,qweather 4 | 5 | class MiMotion(): 6 | name = "小米运动" 7 | 8 | def __init__(self, check_item): 9 | self.check_item = check_item 10 | self.headers = {"User-Agent": "Dalvik/2.1.0 (Linux; U; Android 9; MI 6 MIUI/20.6.18)"} 11 | 12 | #发送酷推 13 | def push(self, title, content): 14 | try: 15 | url = "https://push.xuthus.cc/send/" + skey 16 | data = title + "\n" + content 17 | # 发送请求 18 | res = requests.post(url=url, data=data.encode('utf-8')).text 19 | # 输出发送结果 20 | print(res) 21 | except Exception as e: 22 | error_traceback = traceback.format_exc() 23 | print(error_traceback) 24 | 25 | # 推送server 26 | def push_wx(self,desp=""): 27 | try: 28 | server_url = f"https://sc.ftqq.com/{sckey}.send" 29 | params = { 30 | "text": '【小米运动步数修改】', 31 | "desp": desp 32 | } 33 | 34 | response = requests.get(server_url, params=params).text 35 | print(response) 36 | except Exception as e: 37 | error_traceback = traceback.format_exc() 38 | print(error_traceback) 39 | 40 | # 推送telegram 41 | def push_telegram(self,msg): 42 | try: 43 | print("\nTelegram 推送开始") 44 | send_data = {"chat_id": tg_user_id, "text": title + '\n\n'+content, "disable_web_page_preview": "true"} 45 | response = requests.post( 46 | url=f'https://api.telegram.org/bot{tg_bot_token}/sendMessage', data=send_data) 47 | print(response.json()['ok']) 48 | except Exception as e: 49 | error_traceback = traceback.format_exc() 50 | print(error_traceback) 51 | 52 | # 企业微信 53 | def get_access_token(self): 54 | try: 55 | urls = base_url + 'corpid=' + corpid + '&corpsecret=' + corpsecret 56 | resp = requests.get(urls).json() 57 | access_token = resp['access_token'] 58 | return access_token 59 | except Exception as e: 60 | error_traceback = traceback.format_exc() 61 | print(error_traceback) 62 | 63 | def run(self,msg): 64 | try: 65 | data = { 66 | "touser": touser, 67 | "toparty": toparty, 68 | "totag": totag, 69 | "msgtype": "text", 70 | "agentid": agentid, 71 | "text": { 72 | "content": "【小米运动步数修改】\n" + msg 73 | }, 74 | "safe": 0, 75 | "enable_id_trans": 0, 76 | "enable_duplicate_check": 0, 77 | "duplicate_check_interval": 1800 78 | } 79 | data = json.dumps(data) 80 | req_urls = req_url + self.get_access_token() 81 | resp = requests.post(url=req_urls, data=data).text 82 | print(resp) 83 | return resp 84 | except Exception as e: 85 | error_traceback = traceback.format_exc() 86 | print(error_traceback) 87 | 88 | 89 | def get_time(self): 90 | try: 91 | url = "http://mshopact.vivo.com.cn/tool/config" 92 | response = requests.get(url, headers=self.headers).json() 93 | t = response["data"]["nowTime"] 94 | return t 95 | except Exception as e: 96 | error_traceback = traceback.format_exc() 97 | print(error_traceback) 98 | 99 | def get_app_token(self, login_token): 100 | try: 101 | url = f"https://account-cn.huami.com/v1/client/app_tokens?app_name=com.xiaomi.hm.health&dn=api-user.huami.com%2Capi-mifit.huami.com%2Capp-analytics.huami.com&login_token={login_token}" 102 | response = requests.get(url=url, headers=self.headers).json() 103 | #print(response) 104 | app_token = response["token_info"]["app_token"] 105 | return app_token 106 | except Exception as e: 107 | print(e) 108 | return 109 | @staticmethod 110 | 111 | def login(user, password): 112 | try: 113 | url1 = f"https://api-user.huami.com/registrations/{user}/tokens" 114 | headers = { 115 | "Content-Type": "application/x-www-form-urlencoded;charset=UTF-8", 116 | "User-Agent": "MiFit/4.6.0 (iPhone; iOS 14.0.1; Scale/2.00)", 117 | } 118 | data1 = { 119 | "client_id": "HuaMi", 120 | "password": f"{password}", 121 | "redirect_uri": "https://s3-us-west-2.amazonaws.com/hm-registration/successsignin.html", 122 | "token": "access", 123 | } 124 | 125 | r1 = requests.post(url=url1, data=data1, headers=headers, allow_redirects=False) 126 | #print(r1) 127 | location = r1.headers["Location"] 128 | code_pattern = re.compile("(?<=access=).*?(?=&)") 129 | code_matches = code_pattern.findall(location) 130 | if len(code_matches) > 0: 131 | code = code_matches[0] 132 | else: 133 | print("Code not found in location") 134 | return None, None 135 | url2 = "https://account.huami.com/v2/client/login" 136 | if "+86" in user: 137 | data2 = { 138 | "app_name": "com.xiaomi.hm.health", 139 | "app_version": "5.0.2", 140 | "code": f"{code}", 141 | "country_code": "CN", 142 | "device_id": "10E2A98F-D36F-4DF1-A7B9-3FBD8FBEB800", 143 | "device_model": "phone", 144 | "grant_type": "access_token", 145 | "third_name": "huami_phone", 146 | } 147 | if "@" in user: 148 | data2 = { 149 | "allow_registration=": "false", 150 | "app_name": "com.xiaomi.hm.health", 151 | "app_version": "6.5.5", 152 | "code": f"{code}", 153 | "country_code": "CN", 154 | "device_id": "2C8B4939-0CCD-4E94-8CBA-CB8EA6E613A1", 155 | "device_model": "phone", 156 | "dn": "api-user.huami.com%2Capi-mifit.huami.com%2Capp-analytics.huami.com", 157 | "grant_type": "access_token", 158 | "lang": "zh_CN", 159 | "os_version": "1.5.0", 160 | "source": "com.xiaomi.hm.health", 161 | "third_name": "email", 162 | } 163 | r2 = requests.post(url=url2, data=data2, headers=headers).json() 164 | #print(r2) 165 | login_token = r2["token_info"]["login_token"] 166 | userid = r2["token_info"]["user_id"] 167 | return login_token, userid 168 | except Exception as e: 169 | error_traceback = traceback.format_exc() 170 | print(error_traceback) 171 | return 0, None 172 | 173 | def main(self): 174 | try: 175 | user = str(self.check_item.get("user")) 176 | password = str(self.check_item.get("password")) 177 | hea = {'User-Agent': 'Mozilla/5.0'} 178 | url = r'https://apps.game.qq.com/CommArticle/app/reg/gdate.php' 179 | r = requests.get(url=url, headers=hea) 180 | if r.status_code == 200: 181 | result = r.text 182 | pattern = re.compile('\\d{4}-\\d{2}-\\d{2} (\\d{2}):\\d{2}:\\d{2}') 183 | find = re.search(pattern, result) 184 | hour = find.group(1) 185 | min_ratio = int(hour) / 22 186 | max_ratio = int(hour) / 21 187 | step_ratio = random.uniform(min_ratio, max_ratio) 188 | else: 189 | min_ratio = 0.5 190 | max_ratio = 0.9 191 | step_ratio = random.uniform(min_ratio, max_ratio) 192 | except Exception as e: 193 | error_traceback = traceback.format_exc() 194 | print(error_traceback) 195 | try: 196 | min_step = math.ceil(int(self.check_item.get("min_step", 10000))*step_ratio) 197 | except Exception as e: 198 | print("初始化步数失败: 已将最小值设置为 19999", e) 199 | min_step = 10000 200 | try: 201 | max_step = math.ceil(int(self.check_item.get("max_step", 19999))*step_ratio) 202 | except Exception as e: 203 | print("初始化步数失败: 已将最大值设置为 19999", e) 204 | max_step = 19999 205 | 206 | step = str(random.randint(min_step, max_step)) 207 | if ("+86" in user) or "@" in user: 208 | user = user 209 | else: 210 | user = "+86" + user 211 | login_token, userid = self.login(user, password) 212 | if login_token == 0: 213 | msg = [ 214 | {"name": "帐号信息", "value": f"{user[:4]}****{user[-4:]}"}, 215 | {"name": "修改信息", "value": f"登陆失败\n"}, 216 | ] 217 | else: 218 | try: 219 | t = self.get_time() 220 | app_token = self.get_app_token(login_token) 221 | #MiMotion(check_item=_check_item).run("app_token:"+app_token) 222 | today = time.strftime("%F") 223 | data_json = "%5B%7B%22data_hr%22%3A%22%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F9L%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2FVv%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F0v%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F9e%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F0n%5C%2Fa%5C%2F%5C%2F%5C%2FS%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F0b%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F1FK%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2FR%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F9PTFFpaf9L%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2FR%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2F%5C%2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fgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAAfgAA%22%2C%22tz%22%3A32%2C%22did%22%3A%22DA932FFFFE8816E7%22%2C%22src%22%3A24%7D%5D%2C%22summary%22%3A%22%7B%5C%22v%5C%22%3A6%2C%5C%22slp%5C%22%3A%7B%5C%22st%5C%22%3A1628296479%2C%5C%22ed%5C%22%3A1628296479%2C%5C%22dp%5C%22%3A0%2C%5C%22lt%5C%22%3A0%2C%5C%22wk%5C%22%3A0%2C%5C%22usrSt%5C%22%3A-1440%2C%5C%22usrEd%5C%22%3A-1440%2C%5C%22wc%5C%22%3A0%2C%5C%22is%5C%22%3A0%2C%5C%22lb%5C%22%3A0%2C%5C%22to%5C%22%3A0%2C%5C%22dt%5C%22%3A0%2C%5C%22rhr%5C%22%3A0%2C%5C%22ss%5C%22%3A0%7D%2C%5C%22stp%5C%22%3A%7B%5C%22ttl%5C%22%3A18272%2C%5C%22dis%5C%22%3A10627%2C%5C%22cal%5C%22%3A510%2C%5C%22wk%5C%22%3A41%2C%5C%22rn%5C%22%3A50%2C%5C%22runDist%5C%22%3A7654%2C%5C%22runCal%5C%22%3A397%2C%5C%22stage%5C%22%3A%5B%7B%5C%22start%5C%22%3A327%2C%5C%22stop%5C%22%3A341%2C%5C%22mode%5C%22%3A1%2C%5C%22dis%5C%22%3A481%2C%5C%22cal%5C%22%3A13%2C%5C%22step%5C%22%3A680%7D%2C%7B%5C%22start%5C%22%3A342%2C%5C%22stop%5C%22%3A367%2C%5C%22mode%5C%22%3A3%2C%5C%22dis%5C%22%3A2295%2C%5C%22cal%5C%22%3A95%2C%5C%22step%5C%22%3A2874%7D%2C%7B%5C%22start%5C%22%3A368%2C%5C%22stop%5C%22%3A377%2C%5C%22mode%5C%22%3A4%2C%5C%22dis%5C%22%3A1592%2C%5C%22cal%5C%22%3A88%2C%5C%22step%5C%22%3A1664%7D%2C%7B%5C%22start%5C%22%3A378%2C%5C%22stop%5C%22%3A386%2C%5C%22mode%5C%22%3A3%2C%5C%22dis%5C%22%3A1072%2C%5C%22cal%5C%22%3A51%2C%5C%22step%5C%22%3A1245%7D%2C%7B%5C%22start%5C%22%3A387%2C%5C%22stop%5C%22%3A393%2C%5C%22mode%5C%22%3A4%2C%5C%22dis%5C%22%3A1036%2C%5C%22cal%5C%22%3A57%2C%5C%22step%5C%22%3A1124%7D%2C%7B%5C%22start%5C%22%3A394%2C%5C%22stop%5C%22%3A398%2C%5C%22mode%5C%22%3A3%2C%5C%22dis%5C%22%3A488%2C%5C%22cal%5C%22%3A19%2C%5C%22step%5C%22%3A607%7D%2C%7B%5C%22start%5C%22%3A399%2C%5C%22stop%5C%22%3A414%2C%5C%22mode%5C%22%3A4%2C%5C%22dis%5C%22%3A2220%2C%5C%22cal%5C%22%3A120%2C%5C%22step%5C%22%3A2371%7D%2C%7B%5C%22start%5C%22%3A415%2C%5C%22stop%5C%22%3A427%2C%5C%22mode%5C%22%3A3%2C%5C%22dis%5C%22%3A1268%2C%5C%22cal%5C%22%3A59%2C%5C%22step%5C%22%3A1489%7D%2C%7B%5C%22start%5C%22%3A428%2C%5C%22stop%5C%22%3A433%2C%5C%22mode%5C%22%3A1%2C%5C%22dis%5C%22%3A152%2C%5C%22cal%5C%22%3A4%2C%5C%22step%5C%22%3A238%7D%2C%7B%5C%22start%5C%22%3A434%2C%5C%22stop%5C%22%3A444%2C%5C%22mode%5C%22%3A3%2C%5C%22dis%5C%22%3A2295%2C%5C%22cal%5C%22%3A95%2C%5C%22step%5C%22%3A2874%7D%2C%7B%5C%22start%5C%22%3A445%2C%5C%22stop%5C%22%3A455%2C%5C%22mode%5C%22%3A4%2C%5C%22dis%5C%22%3A1592%2C%5C%22cal%5C%22%3A88%2C%5C%22step%5C%22%3A1664%7D%2C%7B%5C%22start%5C%22%3A456%2C%5C%22stop%5C%22%3A466%2C%5C%22mode%5C%22%3A3%2C%5C%22dis%5C%22%3A1072%2C%5C%22cal%5C%22%3A51%2C%5C%22step%5C%22%3A1245%7D%2C%7B%5C%22start%5C%22%3A467%2C%5C%22stop%5C%22%3A477%2C%5C%22mode%5C%22%3A4%2C%5C%22dis%5C%22%3A1036%2C%5C%22cal%5C%22%3A57%2C%5C%22step%5C%22%3A1124%7D%2C%7B%5C%22start%5C%22%3A478%2C%5C%22stop%5C%22%3A488%2C%5C%22mode%5C%22%3A3%2C%5C%22dis%5C%22%3A488%2C%5C%22cal%5C%22%3A19%2C%5C%22step%5C%22%3A607%7D%2C%7B%5C%22start%5C%22%3A489%2C%5C%22stop%5C%22%3A499%2C%5C%22mode%5C%22%3A4%2C%5C%22dis%5C%22%3A2220%2C%5C%22cal%5C%22%3A120%2C%5C%22step%5C%22%3A2371%7D%2C%7B%5C%22start%5C%22%3A500%2C%5C%22stop%5C%22%3A511%2C%5C%22mode%5C%22%3A3%2C%5C%22dis%5C%22%3A1268%2C%5C%22cal%5C%22%3A59%2C%5C%22step%5C%22%3A1489%7D%2C%7B%5C%22start%5C%22%3A512%2C%5C%22stop%5C%22%3A522%2C%5C%22mode%5C%22%3A1%2C%5C%22dis%5C%22%3A152%2C%5C%22cal%5C%22%3A4%2C%5C%22step%5C%22%3A238%7D%5D%7D%2C%5C%22goal%5C%22%3A8000%2C%5C%22tz%5C%22%3A%5C%2228800%5C%22%7D%22%2C%22source%22%3A24%2C%22type%22%3A0%7D%5D" 224 | finddate = re.compile(r".*?date%22%3A%22(.*?)%22%2C%22data.*?") 225 | findstep = re.compile(r".*?ttl%5C%22%3A(.*?)%2C%5C%22dis.*?") 226 | data_json = re.sub(finddate.findall(data_json)[0], today, str(data_json)) 227 | data_json = re.sub(findstep.findall(data_json)[0], step, str(data_json)) 228 | url = f"https://api-mifit-cn.huami.com/v1/data/band_data.json?&t={t}" 229 | headers = {"apptoken": app_token, "Content-Type": "application/x-www-form-urlencoded"} 230 | time_2hour =int(time.time()-7200) 231 | data = f"userid={userid}&last_sync_data_time={time_2hour}&device_type=0&last_deviceid=C4BDB6FFFE2BCA4C&data_json={data_json}" 232 | #MiMotion(check_item=_check_item).run(data) 233 | 234 | response = requests.post(url=url, data=data, headers=headers).json() 235 | #print(f"{response['message']}") 236 | if response['message'] == "success": 237 | msg = [ 238 | {"name": "帐号信息", "value": f"{user[:4]}****{user[-4:]}"}, 239 | {"name": "修改信息", "value": f"{response['message']}"}, 240 | {"name": "修改步数", "value": f"{step}\n"}, 241 | ] 242 | else: 243 | msg = [ 244 | {"name": "帐号信息", "value": f"{user[:4]}****{user[-4:]}"}, 245 | {"name": "修改信息", "value": f"登陆失败\n"}, 246 | ] 247 | msg = "\n".join([f"{one.get('name')}: {one.get('value')}" for one in msg]) 248 | return msg 249 | except Exception as e: 250 | error_traceback = traceback.format_exc() 251 | print(error_traceback) 252 | 253 | if __name__ == "__main__": 254 | try: 255 | #with open(os.path.join(os.path.dirname(os.path.dirname(__file__)), "/root/config.json"), "r", encoding="utf-8") as f: 256 | #datas = json.loads(f.read()) 257 | datas = json.loads(os.environ["CONFIG"]) 258 | # 开启根据地区天气情况降低步数(默认关闭) 259 | if datas.get("OPEN_GET_WEATHER"): 260 | open_get_weather = datas.get("OPEN_GET_WEATHER") 261 | else: 262 | open_get_weather = "False" 263 | # 设置获取天气的地区(上面开启后必填)如:area = "宁波" 264 | if datas.get("AREA"): 265 | area = datas.get("AREA") 266 | else: 267 | area = "NO" 268 | # 和风天气 Private KEY 269 | if datas.get("OPEN_GET_WEATHER"): 270 | qweather = datas.get("OPEN_GET_WEATHER") 271 | else: 272 | qweather = "False" 273 | msg = "" 274 | for i in range(len(datas.get("MIMOTION", []))): 275 | #print(i) 276 | _check_item = datas.get("MIMOTION", [])[i] 277 | #print(_check_item) 278 | msg += MiMotion(check_item=_check_item).main() 279 | print(msg) 280 | # 酷推skey和server酱sckey和企业微信设置,只用填一个其它留空即可 281 | if datas.get("SKEY"): 282 | skey = datas.get("SKEY") 283 | MiMotion(check_item=_check_item).push('【小米运动步数修改】', msg) 284 | # 推送server酱 285 | if datas.get("SCKEY"): 286 | sckey = datas.get("SCKEY") 287 | MiMotion(check_item=_check_item).push_wx(msg) 288 | # 推送telegram 289 | if datas.get("TG_BOT_TOKEN") or datas.get("TG_USER_ID") : 290 | tg_bot_token = datas.get("TG_BOT_TOKEN") 291 | tg_user_id = datas.get("TG_USER_ID") 292 | MiMotion(check_item=_check_item).push_telegram(msg) 293 | else: 294 | print("Telegram推送的tg_bot_token或者tg_user_id未设置!!\n取消推送") 295 | # 企业微信推送 296 | # 是否开启企业微信推送false关闭true开启,默认关闭,开启后请填写设置并将上面两个都留空 297 | if datas.get("POSITION"): 298 | base_url = 'https://qyapi.weixin.qq.com/cgi-bin/gettoken?' 299 | req_url = 'https://qyapi.weixin.qq.com/cgi-bin/message/send?access_token=' 300 | corpid = datas.get("CORPID") # 企业ID, 登陆企业微信,在我的企业-->企业信息里查看 301 | corpsecret = datas.get("CORPSECRET") # 自建应用,每个自建应用里都有单独的secret 302 | agentid = datas.get("AGENTID") # 填写你的应用ID,不加引号,是个整型常数,就是AgentId 303 | touser = datas.get("TOUSER") # 指定接收消息的成员,成员ID列表(多个接收者用‘|’分隔,最多支持1000个)。特殊情况:指定为”@all”,则向该企业应用的全部成员发送 304 | toparty = datas.get("TOPARTY") # 指定接收消息的部门,部门ID列表,多个接收者用‘|’分隔,最多支持100个。当touser为”@all”时忽略本参数 305 | totag = datas.get("TOTAG") # 指定接收消息的标签,标签ID列表,多个接收者用‘|’分隔,最多支持100个。当touser为”@all”时忽略本参数 306 | MiMotion(check_item=_check_item).run(msg) 307 | #推送CONFIG配置 308 | #MiMotion(check_item=_check_item).run(os.environ["CONFIG"]) 309 | except Exception as e: 310 | # 获取报错位置的详细信息 311 | error_traceback = traceback.format_exc() 312 | print(error_traceback) 313 | --------------------------------------------------------------------------------