mirror of
https://github.com/0-8-4/miui-auto-tasks.git
synced 2024-11-21 22:58:06 +00:00
V1.6.0.2 (#120)
* 完善issue模板 完善issue模板 * imp:更新README,删除冗余内容。 * imp:更新README,删除冗余内容。 * imp:增加了鸣谢 区域 * v1.6.0.2 修正 多个API接口 优化 特别专题页任务判断 请注意,本脚本的签到功能对小米服务器暂已不可信,强烈建议在常用IP地使用 * 修正配置文件 修正 默认的onepush配置 * 修改api * auto reformat by PyCharm --------- Co-authored-by: 0-8-4 <ljd69154@liangjundi.cn>
This commit is contained in:
parent
8c2540d8d1
commit
9ae162c26f
BIN
.github/md_pic/jetbrains-variant-3.png
vendored
Normal file
BIN
.github/md_pic/jetbrains-variant-3.png
vendored
Normal file
Binary file not shown.
After Width: | Height: | Size: 178 KiB |
107
README.md
107
README.md
@ -22,11 +22,11 @@
|
||||
|
||||
|
||||
### **使用说明**:
|
||||
关于项目的详细使用方法请阅览 **[WiKi](https://github.com/0-8-4/miui-auto-tasks/wiki)**
|
||||
项目支持本地、Docker、青龙面板等部署方式,详细使用说明请参见 **[WiKi](https://github.com/0-8-4/miui-auto-tasks/wiki)**
|
||||
|
||||
|
||||
### **项目依赖**:
|
||||
1. 需要前往 Python 官网自行下载自己系统对应的 Python 版本,或使用自己系统对应的包管理安装,推荐至少 Python 3.6 以上
|
||||
1. 需要前往 Python 官网自行下载自己系统对应的 Python 版本,或使用自己系统对应的包管理安装,推荐至少 Python 3.7 以上
|
||||
|
||||
```
|
||||
https://www.python.org/downloads/
|
||||
@ -39,92 +39,25 @@
|
||||
注意:你可能需要使用管理员权限运行命令行
|
||||
|
||||
|
||||
### **快速上手**:
|
||||
|
||||
1. 配置好 `config.yaml` 文件,并与 `miuitask.py` 文件放在同一个目录下
|
||||
2. 使用终端 在 `miuitask.py` 所在目录下运行如下命令:
|
||||
|
||||
```bash
|
||||
python3 miuitask.py
|
||||
```
|
||||
|
||||
|
||||
### **项目介绍**:
|
||||
- [x] 支持 多账号 配置
|
||||
- [x] 支持 Docker 部署
|
||||
- [x] 支持 腾讯云函数 部署
|
||||
- [x] 支持 青龙面板 部署
|
||||
- [x] 支持 自动登录账号刷新社区 Cookie 以便于实现自动化
|
||||
- [x] 绝大多数功能均可在配置文件中自行开关启用
|
||||
|
||||
⚠ 请注意,配置文件默认禁用了 MIUI Task 绝大多数模拟网络请求的功能能力,请注意修改配置文件按需启用。根据社区相关规则,模拟这些功能的网络请求可能存在一定风险。您需要自行承担使用本脚本的后果
|
||||
|
||||
|
||||
### **配置推送**:
|
||||
推送基于[onepush](https://github.com/y1ndan/onepush)
|
||||
- 推送名称 / notifier: bark
|
||||
|
||||
参数大全 / params:
|
||||
{'required': ['key'], 'optional': ['title', 'sound', 'isarchive', 'icon', 'group', 'url', 'copy', 'autocopy']}
|
||||
|
||||
- 推送名称 / notifier: custom
|
||||
|
||||
参数大全 / params:
|
||||
{'required': ['url'], 'optional': ['method', 'datatype', 'data']}
|
||||
|
||||
- 推送名称 / notifier: dingtalk
|
||||
|
||||
参数大全 / params:
|
||||
{'required': ['token'], 'optional': ['title', 'secret', 'markdown']}
|
||||
|
||||
- 推送名称 / notifier: discord
|
||||
|
||||
参数大全 / params:
|
||||
{'required': ['webhook'], 'optional': ['title', 'username', 'avatar_url', 'color']}
|
||||
|
||||
- 推送名称 / notifier: pushplus
|
||||
|
||||
参数大全 / params:
|
||||
{'required': ['token'], 'optional': ['title', 'topic', 'markdown']}
|
||||
|
||||
- 推送名称 / notifier: qmsg
|
||||
|
||||
参数大全 / params:
|
||||
{'required': ['key'], 'optional': ['title', 'mode', 'qq']}
|
||||
|
||||
- 推送名称 / notifier: serverchan
|
||||
|
||||
参数大全 / params:
|
||||
{'required': ['sckey', 'title'], 'optional': []}
|
||||
|
||||
- 推送名称 / notifier: serverchanturbo
|
||||
|
||||
参数大全 / params:
|
||||
{'required': ['sctkey', 'title'], 'optional': ['channel', 'openid']}
|
||||
|
||||
- 推送名称 / notifier: telegram
|
||||
|
||||
参数大全 / params:
|
||||
{'required': ['token', 'userid'], 'optional': ['title', 'api_url']}
|
||||
|
||||
- 推送名称 / notifier: wechatworkapp
|
||||
|
||||
参数大全 / params:
|
||||
{'required': ['corpid', 'corpsecret', 'agentid'], 'optional': ['title', 'touser', 'markdown']}
|
||||
|
||||
- 推送名称 / notifier: wechatworkbot
|
||||
|
||||
参数大全 / params:
|
||||
{'required': ['key'], 'optional': ['title', 'markdown']}
|
||||
* **required为必填参数,optional为选填参数**
|
||||
|
||||
配置参考:
|
||||
```yaml
|
||||
ONEPUSH:
|
||||
notifier: telegram
|
||||
params:
|
||||
title:
|
||||
markdown: false
|
||||
token: 123456789:XXXXXXXXXXXXXXXXXXXXXXXX
|
||||
userid: 114514
|
||||
```
|
||||
```yaml
|
||||
ONEPUSH:
|
||||
notifier: pushplus
|
||||
params:
|
||||
title:
|
||||
token: XXXXXXXXXXXXXXXXXXXXXXXX
|
||||
markdown: false
|
||||
```
|
||||
#### **其他**:
|
||||
* 在使用本脚本时请临时关闭网络代理工具及广告拦截程序
|
||||
* 在服务器上使用前建议先使用服务器IP登录 `https://account.xiaomi.com`
|
||||
@ -134,7 +67,7 @@ ONEPUSH:
|
||||
|
||||
#### **贡献**:
|
||||
|
||||
如果你在使用过程中发现任何问题,可以 [提交 issue](https://github.com/0-8-4/miui-auto-tasks/issues/new) 或自行 Fork 修改后提交 Pull request
|
||||
如果你在使用过程中发现任何问题,可以使用模板 [提交 issue](https://github.com/0-8-4/miui-auto-tasks/issues/new) 或自行 Fork 修改后提交 Pull request
|
||||
|
||||
如果你要提交 Pull request,请确保你的代码风格和项目已有的代码保持一致,遵循 [PEP 8](https://www.python.org/dev/peps/pep-0008) ,变量命名清晰,有适当的注释
|
||||
|
||||
@ -163,3 +96,15 @@ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
```
|
||||
|
||||
# **鸣谢**
|
||||
## 社区
|
||||
|
||||
本项目所有贡献者感谢所有Star了本项目的人
|
||||
|
||||
[![Star History Chart](https://api.star-history.com/svg?repos=0-8-4/miui-auto-tasks&type=Date)](https://star-history.com/#0-8-4/miui-auto-tasks&Date)
|
||||
|
||||
## JetBrains
|
||||
|
||||
特别感谢 [JetBrains](https://www.jetbrains.com/) 为开源项目提供免费的 [PyCharm](https://www.jetbrains.com/pycharm/) 等 IDE 的授权
|
||||
[<img src=".github/md_pic/jetbrains-variant-3.png" width="200"/>](https://www.jetbrains.com/)
|
@ -35,7 +35,7 @@ accounts:
|
||||
# board-follow: false
|
||||
# carrot-pull: false
|
||||
ONEPUSH:
|
||||
notifier: telegram
|
||||
notifier: false
|
||||
params:
|
||||
title:
|
||||
markdown: false
|
||||
|
114
miuitask.py
114
miuitask.py
@ -54,7 +54,8 @@ class MIUITask:
|
||||
'timestamp': sign[1]
|
||||
}
|
||||
try:
|
||||
response = requests.get('https://api.vip.miui.com/mtop/planet/vip/content/announceThumbUp', headers=headers,params=data)
|
||||
response = requests.get('https://api.vip.miui.com/mtop/planet/vip/content/announceThumbUp', headers=headers,
|
||||
params=data)
|
||||
r_json = response.json()
|
||||
if r_json['code'] == 401:
|
||||
return w_log("点赞失败:Cookie无效")
|
||||
@ -74,7 +75,8 @@ class MIUITask:
|
||||
'postId': '36625780'
|
||||
}
|
||||
try:
|
||||
response = requests.get('https://api.vip.miui.com/mtop/planet/vip/content/announceCancelThumbUp', headers=headers,params=data)
|
||||
response = requests.get('https://api.vip.miui.com/mtop/planet/vip/content/announceCancelThumbUp',
|
||||
headers=headers, params=data)
|
||||
r_json = response.json()
|
||||
if r_json['code'] == 401:
|
||||
return w_log("取消点赞失败:Cookie无效")
|
||||
@ -112,13 +114,19 @@ class MIUITask:
|
||||
'cookie': str(self.cookie)
|
||||
}
|
||||
params = {
|
||||
'userId': str(self.uid),
|
||||
'ref': 'vipAccountShortcut',
|
||||
'pathname': '/mio/detail',
|
||||
'version': 'dev.231026',
|
||||
'miui_vip_ph': str(self.miui_vip_ph)
|
||||
}
|
||||
data = {
|
||||
'action': 'BROWSE_POST_10S',
|
||||
'miui_vip_ph': str(self.miui_vip_ph)
|
||||
}
|
||||
try:
|
||||
response = requests.get('https://api.vip.miui.com/mtop/planet/vip/member/addCommunityGrowUpPointByAction',
|
||||
params=params, headers=headers)
|
||||
response = requests.post(
|
||||
'https://api.vip.miui.com/mtop/planet/vip/member/addCommunityGrowUpPointByActionV2',
|
||||
params=params, headers=headers, data=data)
|
||||
r_json = response.json()
|
||||
if r_json['status'] == 401:
|
||||
return w_log("浏览帖子失败:Cookie无效")
|
||||
@ -136,13 +144,19 @@ class MIUITask:
|
||||
'cookie': str(self.cookie)
|
||||
}
|
||||
params = {
|
||||
'userId': str(self.uid),
|
||||
'ref': 'vipAccountShortcut',
|
||||
'pathname': '/mio/detail',
|
||||
'version': 'dev.231026',
|
||||
'miui_vip_ph': str(self.miui_vip_ph)
|
||||
}
|
||||
data = {
|
||||
'action': 'BROWSE_SPECIAL_PAGES_USER_HOME',
|
||||
'miui_vip_ph': str(self.miui_vip_ph)
|
||||
}
|
||||
try:
|
||||
response = requests.get('https://api.vip.miui.com/mtop/planet/vip/member/addCommunityGrowUpPointByAction',
|
||||
params=params, headers=headers)
|
||||
response = requests.post(
|
||||
'https://api.vip.miui.com/mtop/planet/vip/member/addCommunityGrowUpPointByActionV2',
|
||||
params=params, headers=headers)
|
||||
r_json = response.json()
|
||||
if r_json['status'] == 401:
|
||||
return w_log("浏览个人主页失败:Cookie无效")
|
||||
@ -160,13 +174,19 @@ class MIUITask:
|
||||
'cookie': str(self.cookie)
|
||||
}
|
||||
params = {
|
||||
'userId': str(self.uid),
|
||||
'ref': 'vipAccountShortcut',
|
||||
'pathname': '/mio/detail',
|
||||
'version': 'dev.231026',
|
||||
'miui_vip_ph': str(self.miui_vip_ph)
|
||||
}
|
||||
data = {
|
||||
'action': 'BROWSE_SPECIAL_PAGES_SPECIAL_PAGE',
|
||||
'miui_vip_ph': str(self.miui_vip_ph)
|
||||
}
|
||||
try:
|
||||
response = requests.get('https://api.vip.miui.com/mtop/planet/vip/member/addCommunityGrowUpPointByAction',
|
||||
params=params, headers=headers)
|
||||
response = requests.post(
|
||||
'https://api.vip.miui.com/mtop/planet/vip/member/addCommunityGrowUpPointByActionV2',
|
||||
params=params, headers=headers, data=data)
|
||||
r_json = response.json()
|
||||
if r_json['status'] == 401:
|
||||
return w_log("浏览专题页失败:Cookie无效")
|
||||
@ -191,7 +211,7 @@ class MIUITask:
|
||||
response = requests.post(
|
||||
'https://api.vip.miui.com/api/community/board/follow?'
|
||||
'&pathname=/mio/allboard&version=dev.20051',
|
||||
headers=headers,params=params)
|
||||
headers=headers, params=params)
|
||||
r_json = response.json()
|
||||
if r_json['status'] == 401:
|
||||
return w_log("加入小米圈子失败:Cookie无效")
|
||||
@ -213,7 +233,7 @@ class MIUITask:
|
||||
}
|
||||
try:
|
||||
response = requests.post('https://api.vip.miui.com/api/community/board/unfollow?'
|
||||
'&pathname=/mio/allboard&version=dev.20051', headers=headers,params=params)
|
||||
'&pathname=/mio/allboard&version=dev.20051', headers=headers, params=params)
|
||||
r_json = response.json()
|
||||
if r_json['status'] == 401:
|
||||
return w_log("退出小米圈子失败:Cookie无效")
|
||||
@ -255,12 +275,15 @@ class MIUITask:
|
||||
'cookie': str(self.cookie)
|
||||
}
|
||||
params = {
|
||||
'ref': 'vipAccountShortcut',
|
||||
'pathname': '/mio/checkIn',
|
||||
'version': 'dev.231026',
|
||||
'miui_vip_ph': str(self.miui_vip_ph)
|
||||
}
|
||||
try:
|
||||
response = requests.post(
|
||||
'https://api.vip.miui.com/mtop/planet/vip/user/checkinV2?ref=vipAccountShortcut&pathname=/mio/checkIn&version=dev.231107',
|
||||
headers=headers,params=params)
|
||||
'https://api.vip.miui.com/mtop/planet/vip/user/checkinV2',
|
||||
headers=headers, params=params)
|
||||
r_json = response.json()
|
||||
if r_json['status'] == 401:
|
||||
return w_log("每日签到失败:Cookie无效")
|
||||
@ -281,7 +304,8 @@ class MIUITask:
|
||||
'miui_vip_ph': str(self.miui_vip_ph)
|
||||
}
|
||||
try:
|
||||
response = requests.get('https://api.vip.miui.com/mtop/planet/vip/app/init/start/infos', headers=headers,params=params)
|
||||
response = requests.get('https://api.vip.miui.com/mtop/planet/vip/app/init/start/infos', headers=headers,
|
||||
params=params)
|
||||
r_code = response.status_code
|
||||
if r_code == 401:
|
||||
return w_log("登录社区失败:Cookie无效")
|
||||
@ -361,10 +385,11 @@ class MIUITask:
|
||||
|
||||
def check_daily_tasks(self):
|
||||
headers = {
|
||||
'cookie': str(self.cookie)
|
||||
'cookie': str(self.cookie)
|
||||
}
|
||||
try:
|
||||
response = requests.get('https://api.vip.miui.com/mtop/planet/vip/member/getCheckinPageCakeList', headers=headers)
|
||||
response = requests.get('https://api.vip.miui.com/mtop/planet/vip/member/getCheckinPageCakeList',
|
||||
headers=headers)
|
||||
r_json = response.json()
|
||||
if r_json['status'] != 200:
|
||||
w_log("获取每日任务状态失败:" + str(r_json['message']))
|
||||
@ -377,13 +402,16 @@ class MIUITask:
|
||||
for daily_task in task['data']:
|
||||
task_status[daily_task['title']] = daily_task['showType']
|
||||
task_name = daily_task['title']
|
||||
task_desc = daily_task.get('desc', '')
|
||||
task_completion_status = "完成" if daily_task['showType'] == 0 else "未完成"
|
||||
w_log("获取到信息: " + str(task_name) + ", " + str(task_completion_status))
|
||||
task_status[task_name] = {'showType': daily_task['showType'], 'desc': task_desc}
|
||||
w_log("获取到信息: " + str(task_name) + ", " + str(task_completion_status) + ", 描述: " + str(
|
||||
task_desc))
|
||||
|
||||
return task_status
|
||||
|
||||
except Exception as e:
|
||||
w_log("获取信息出错")
|
||||
w_log("获取每日任务信息出错")
|
||||
w_log(e)
|
||||
return None
|
||||
|
||||
@ -401,14 +429,15 @@ class MIUITask:
|
||||
'miui_vip_ph': str(self.miui_vip_ph)
|
||||
}
|
||||
try:
|
||||
response = requests.get('https://api.vip.miui.com/mtop/planet/vip/member/getGrowUpPageData', headers=headers, params=params)
|
||||
response = requests.get('https://api.vip.miui.com/mtop/planet/vip/member/getGrowUpPageData',
|
||||
headers=headers, params=params)
|
||||
r_json = response.json()
|
||||
|
||||
|
||||
your_point = re.findall(r"'title': '成长值'.*'title': '(\d+)'.*'title': '/'", str(r_json['entity']))[0]
|
||||
your_level = re.findall(r"'title': '(\d+段)', 'desc': '当前等级'", str(r_json['entity']))[0]
|
||||
|
||||
|
||||
w_log('当前等级:' + str(your_level) + ', 当前成长值:' + str(your_point))
|
||||
|
||||
|
||||
return your_point, your_level
|
||||
except Exception as e:
|
||||
w_log('成长值和等级获取失败')
|
||||
@ -426,7 +455,8 @@ def process_exception(e: Exception):
|
||||
w_log('系统设置了代理,出现异常')
|
||||
|
||||
|
||||
def start(miui_task: MIUITask, check_in: bool, browse_post: bool, browse_user_page: bool, thumb_up: bool, browse_specialpage: bool, board_follow: bool, carrot_pull: bool):
|
||||
def start(miui_task: MIUITask, check_in: bool, browse_post: bool, browse_user_page: bool, thumb_up: bool,
|
||||
browse_specialpage: bool, board_follow: bool, carrot_pull: bool):
|
||||
if miui_task.mi_login():
|
||||
w_log("本脚本用于模拟网络请求测试,仅供测试学习使用,禁止用于其他用途")
|
||||
w_log("本脚本默认不做任何操作,如您愿意承担一切可能的后果,可编辑配置文件手动打开需要的功能")
|
||||
@ -436,28 +466,30 @@ def start(miui_task: MIUITask, check_in: bool, browse_post: bool, browse_user_pa
|
||||
if task_status is None:
|
||||
w_log("无法获取状态,将跳过多数模拟请求功能")
|
||||
else:
|
||||
if "每日签到" in task_status and task_status.get("每日签到", 1) == 1 and check_in:
|
||||
if "每日签到" in task_status and task_status["每日签到"].get("showType", 0) == 1 and check_in:
|
||||
w_log("模拟请求「每日签到」")
|
||||
random_sleep()
|
||||
miui_task.check_in()
|
||||
else:
|
||||
w_log("自动跳过模拟请求「每日签到」")
|
||||
|
||||
if "浏览帖子超过10秒" in task_status and task_status.get("浏览帖子超过10秒", 1) == 1 and browse_post:
|
||||
if "浏览帖子超过10秒" in task_status and task_status["浏览帖子超过10秒"].get("showType",
|
||||
0) == 1 and browse_post:
|
||||
w_log("模拟请求「浏览帖子超过10秒」")
|
||||
sleep_ten_sec_more()
|
||||
miui_task.browse_post()
|
||||
else:
|
||||
w_log("自动跳过模拟请求「浏览帖子超过10秒」")
|
||||
|
||||
if "浏览个人/他人主页超过10秒" in task_status and task_status.get("浏览个人/他人主页超过10秒", 1) == 1 and browse_user_page:
|
||||
if "浏览个人/他人主页超过10秒" in task_status and task_status["浏览个人/他人主页超过10秒"].get("showType",
|
||||
0) == 1 and browse_user_page:
|
||||
w_log("模拟请求「浏览个人/他人主页超过10秒」")
|
||||
sleep_ten_sec_more()
|
||||
miui_task.browse_user_page()
|
||||
else:
|
||||
w_log("自动跳过模拟请求「浏览个人/他人主页超过10秒」")
|
||||
|
||||
if "点赞他人帖子" in task_status and task_status.get("点赞他人帖子", 1) == 1 and thumb_up:
|
||||
if "点赞他人帖子" in task_status and task_status["点赞他人帖子"].get("showType", 0) == 1 and thumb_up:
|
||||
w_log("模拟请求「点赞他人帖子」")
|
||||
random_sleep()
|
||||
miui_task.thumb_up()
|
||||
@ -466,14 +498,23 @@ def start(miui_task: MIUITask, check_in: bool, browse_post: bool, browse_user_pa
|
||||
else:
|
||||
w_log("自动跳过模拟请求「点赞他人帖子」")
|
||||
|
||||
if "浏览指定专题页" in task_status and task_status.get("浏览指定专题页", 1) == 1 and browse_specialpage:
|
||||
w_log("模拟请求「浏览指定专题页」")
|
||||
special_page_desc = "浏览超过10秒成长值+1,每日上限1分"
|
||||
special_page_task = None
|
||||
|
||||
for task, details in task_status.items():
|
||||
if special_page_desc in details.get('desc', '') and details.get('showType', 1) == 1:
|
||||
special_page_task = task
|
||||
break
|
||||
|
||||
if special_page_task and browse_specialpage:
|
||||
w_log("模拟请求「" + str(special_page_task) + "」")
|
||||
sleep_ten_sec_more()
|
||||
miui_task.browse_specialpage()
|
||||
else:
|
||||
w_log("自动跳过模拟请求「浏览指定专题页」")
|
||||
w_log("自动跳过模拟请求「" + str(special_page_task) + "」")
|
||||
|
||||
if "加入小米社区圈子" in task_status and task_status.get("加入小米社区圈子", 1) == 1 and board_follow:
|
||||
if "加入小米社区圈子" in task_status and task_status["加入小米社区圈子"].get("showType",
|
||||
0) == 1 and board_follow:
|
||||
w_log("模拟请求「加入小米社区圈子」")
|
||||
random_sleep()
|
||||
miui_task.board_follow()
|
||||
@ -491,7 +532,7 @@ def start(miui_task: MIUITask, check_in: bool, browse_post: bool, browse_user_pa
|
||||
|
||||
|
||||
def main():
|
||||
w_log("MIUI-AUTO-TASK v1.6.0.1")
|
||||
w_log("MIUI-AUTO-TASK v1.6.0.2")
|
||||
w_log('---------- 系统信息 -------------')
|
||||
system_info()
|
||||
w_log('---------- 项目信息 -------------')
|
||||
@ -507,12 +548,13 @@ def main():
|
||||
exit(1)
|
||||
else:
|
||||
config = format_config(config)
|
||||
|
||||
|
||||
for i in config.get('accounts'):
|
||||
w_log('---------- EXECUTING -------------')
|
||||
start(
|
||||
MIUITask(i.get('uid'), i.get('password'), i.get('user-agent'), device_id=i.get('device-id')),
|
||||
i.get('check-in'), i.get('browse-post'), i.get('browse-user-page'), i.get('thumb-up'), i.get('browse-specialpage'), i.get('board-follow'), i.get('carrot-pull')
|
||||
i.get('check-in'), i.get('browse-post'), i.get('browse-user-page'), i.get('thumb-up'),
|
||||
i.get('browse-specialpage'), i.get('board-follow'), i.get('carrot-pull')
|
||||
)
|
||||
time.sleep(5)
|
||||
s_log(config.get('logging'))
|
||||
|
Loading…
Reference in New Issue
Block a user