2021-08-16 03:39:26 +00:00
|
|
|
|
# -- coding:UTF-8 --
|
|
|
|
|
import requests
|
|
|
|
|
import time
|
|
|
|
|
import json
|
|
|
|
|
|
|
|
|
|
from urllib import request
|
|
|
|
|
from http import cookiejar
|
2021-09-07 01:07:31 +00:00
|
|
|
|
from utils.utils import system_info, get_config, w_log, s_log, conf_check
|
2021-08-16 03:39:26 +00:00
|
|
|
|
|
2021-09-06 21:52:48 +00:00
|
|
|
|
|
|
|
|
|
# Config
|
|
|
|
|
config = get_config()
|
2021-08-16 03:39:26 +00:00
|
|
|
|
# 小米ID
|
2021-09-06 21:52:48 +00:00
|
|
|
|
mi_id = config.get('MI_ID')
|
2021-08-16 10:14:17 +00:00
|
|
|
|
# 小米账号的密码MD5值,请使用"passwd2md5.py"转换
|
2021-09-06 21:52:48 +00:00
|
|
|
|
p_md5 = config.get('MI_PASSWORD').upper()
|
2021-08-16 03:39:26 +00:00
|
|
|
|
# 如果登录一直需要短信验证码,在此填入设备id(在account.xiaomi.com的cookie中寻找deviceId)
|
2021-09-06 18:39:01 +00:00
|
|
|
|
dev_id = ''
|
2021-08-16 03:39:26 +00:00
|
|
|
|
# 常用浏览器UA
|
|
|
|
|
# 需要改成你自己常用的浏览器的UA
|
2021-09-06 21:52:48 +00:00
|
|
|
|
l_ua = config.get('USER_AGENT')
|
2021-08-16 03:39:26 +00:00
|
|
|
|
# 开发版内测5428803 开发版公测5433318 稳定版内测5462204 目前测试三个中完成任意一个即可全部完成
|
2021-09-06 21:52:48 +00:00
|
|
|
|
board_id = config.get('BOARD_ID')
|
2021-08-16 03:39:26 +00:00
|
|
|
|
# 留空
|
|
|
|
|
cookie = ''
|
|
|
|
|
# 留空
|
|
|
|
|
miui_vip_ph = ''
|
|
|
|
|
|
|
|
|
|
|
2021-09-06 18:39:01 +00:00
|
|
|
|
def thumb_up():
|
2021-08-16 03:39:26 +00:00
|
|
|
|
headers = {
|
|
|
|
|
'cookie': str(cookie)
|
|
|
|
|
}
|
|
|
|
|
try:
|
|
|
|
|
response = requests.get('https://api.vip.miui.com/api/community/post/thumbUp?postId=28270729', headers=headers)
|
2021-09-06 18:39:01 +00:00
|
|
|
|
r_json = response.json()
|
|
|
|
|
if r_json['code'] == 401:
|
|
|
|
|
return w_log("点赞失败:Cookie无效")
|
|
|
|
|
elif r_json['code'] != 200:
|
|
|
|
|
return w_log("点赞失败:" + str(r_json['message']))
|
|
|
|
|
w_log("点赞成功")
|
2021-08-16 03:39:26 +00:00
|
|
|
|
except:
|
2021-09-06 18:39:01 +00:00
|
|
|
|
w_log("点赞出错")
|
2021-08-16 03:39:26 +00:00
|
|
|
|
|
|
|
|
|
|
2021-09-06 18:39:01 +00:00
|
|
|
|
def cancel_thumb_up():
|
2021-08-16 03:39:26 +00:00
|
|
|
|
headers = {
|
|
|
|
|
'cookie': str(cookie)
|
|
|
|
|
}
|
|
|
|
|
try:
|
|
|
|
|
response = requests.get('https://api.vip.miui.com/api/community/post/cancelThumbUp?postId=28270729',
|
|
|
|
|
headers=headers)
|
2021-09-06 18:39:01 +00:00
|
|
|
|
r_json = response.json()
|
|
|
|
|
if r_json['code'] == 401:
|
|
|
|
|
return w_log("取消点赞失败:Cookie无效")
|
|
|
|
|
elif r_json['code'] != 200:
|
|
|
|
|
return w_log("取消点赞失败:" + str(r_json['message']))
|
|
|
|
|
w_log("取消点赞成功")
|
2021-08-16 03:39:26 +00:00
|
|
|
|
except:
|
2021-09-06 18:39:01 +00:00
|
|
|
|
w_log("取消点赞出错")
|
2021-08-16 03:39:26 +00:00
|
|
|
|
|
|
|
|
|
|
2021-09-06 18:39:01 +00:00
|
|
|
|
def delete_post(tid):
|
2021-08-16 03:39:26 +00:00
|
|
|
|
headers = {
|
|
|
|
|
'cookie': str(cookie)
|
|
|
|
|
}
|
|
|
|
|
try:
|
|
|
|
|
response = requests.get('https://api.vip.miui.com/api/community/post/detail/delete?postId=' + str(tid),
|
|
|
|
|
headers=headers)
|
2021-09-06 18:39:01 +00:00
|
|
|
|
r_json = response.json()
|
|
|
|
|
if r_json['code'] == 401:
|
|
|
|
|
return w_log("删除内容失败:Cookie无效")
|
|
|
|
|
elif r_json['code'] != 200:
|
|
|
|
|
return w_log("删除内容失败:" + str(r_json['message']))
|
|
|
|
|
w_log("删除内容成功:" + str(r_json['message']))
|
2021-08-16 03:39:26 +00:00
|
|
|
|
except:
|
2021-09-06 18:39:01 +00:00
|
|
|
|
w_log("删除内容出错,请手动删除")
|
2021-08-16 03:39:26 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# 发帖
|
2021-09-06 18:39:01 +00:00
|
|
|
|
def new_announce(t_type):
|
2021-08-16 03:39:26 +00:00
|
|
|
|
headers = {
|
|
|
|
|
'cookie': str(cookie)
|
|
|
|
|
}
|
|
|
|
|
data = {
|
2021-09-06 18:39:01 +00:00
|
|
|
|
'announce': '{"textContent":"小米社区闪退","boards":[{"boardId":"' + board_id + '"}],"announceType":"' + str(
|
|
|
|
|
t_type) + '"}',
|
2021-08-16 03:39:26 +00:00
|
|
|
|
'miui_vip_ph': str(miui_vip_ph)
|
|
|
|
|
}
|
|
|
|
|
try:
|
|
|
|
|
response = requests.post('https://api.vip.miui.com/api/community/post/add/newAnnounce', headers=headers,
|
|
|
|
|
data=data)
|
2021-09-06 18:39:01 +00:00
|
|
|
|
r_json = response.json()
|
|
|
|
|
if r_json['code'] == 401:
|
|
|
|
|
return w_log("发表内容失败:Cookie无效")
|
|
|
|
|
elif r_json['code'] != 200:
|
|
|
|
|
return w_log("发表内容失败:" + str(r_json['message']))
|
|
|
|
|
post_entity = json.loads(r_json['entity'])
|
|
|
|
|
w_log("发表内容成功,帖子ID:" + str(post_entity['announceId']) + ",将在3秒后删除")
|
|
|
|
|
add_comment_return_comment_info(str(post_entity['announceId']))
|
2021-08-16 03:39:26 +00:00
|
|
|
|
time.sleep(3)
|
|
|
|
|
# 执行5次删帖是为了防止删帖失败
|
2021-09-06 18:39:01 +00:00
|
|
|
|
for item in range(0, 5):
|
|
|
|
|
delete_post(post_entity['announceId'])
|
2021-08-16 03:39:26 +00:00
|
|
|
|
except:
|
2021-09-06 18:39:01 +00:00
|
|
|
|
w_log("发表内容出错")
|
2021-08-16 03:39:26 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# 回帖
|
2021-09-06 18:39:01 +00:00
|
|
|
|
def add_comment_return_comment_info(tid):
|
2021-08-16 03:39:26 +00:00
|
|
|
|
headers = {
|
|
|
|
|
'cookie': str(cookie)
|
|
|
|
|
}
|
|
|
|
|
data = {
|
|
|
|
|
'postId': str(tid),
|
|
|
|
|
'text': '小米社区闪退',
|
|
|
|
|
'miui_vip_ph': str(miui_vip_ph)
|
|
|
|
|
}
|
|
|
|
|
try:
|
|
|
|
|
response = requests.post('https://api.vip.miui.com/mtop/planet/vip/content/addCommentReturnCommentInfo',
|
|
|
|
|
headers=headers, data=data)
|
2021-09-06 18:39:01 +00:00
|
|
|
|
r_json = response.json()
|
|
|
|
|
if r_json['code'] == 401:
|
|
|
|
|
return w_log("回复失败:Cookie无效")
|
|
|
|
|
elif r_json['code'] != 200:
|
|
|
|
|
return w_log("回复失败:" + str(r_json['message']))
|
|
|
|
|
w_log("回复成功")
|
2021-08-16 03:39:26 +00:00
|
|
|
|
except:
|
2021-09-06 18:39:01 +00:00
|
|
|
|
w_log("回复出错")
|
2021-08-16 03:39:26 +00:00
|
|
|
|
|
|
|
|
|
|
2021-09-06 18:39:01 +00:00
|
|
|
|
def get_vip_cookie(url):
|
2021-08-16 03:39:26 +00:00
|
|
|
|
global cookie
|
|
|
|
|
global miui_vip_ph
|
|
|
|
|
try:
|
2021-09-06 18:39:01 +00:00
|
|
|
|
r_cookie = cookiejar.CookieJar()
|
|
|
|
|
handler = request.HTTPCookieProcessor(r_cookie)
|
2021-08-16 03:39:26 +00:00
|
|
|
|
opener = request.build_opener(handler)
|
|
|
|
|
response = opener.open(url)
|
2021-09-06 18:39:01 +00:00
|
|
|
|
for item in r_cookie:
|
2021-08-16 03:39:26 +00:00
|
|
|
|
cookie += item.name + '=' + item.value + ';'
|
|
|
|
|
if cookie == '':
|
|
|
|
|
return False
|
2021-09-06 18:39:01 +00:00
|
|
|
|
ck_list = cookie.replace(" ", "").split(';')
|
|
|
|
|
for ph in ck_list:
|
2021-08-16 03:39:26 +00:00
|
|
|
|
if "miui_vip_ph=" in ph:
|
|
|
|
|
miui_vip_ph = ph.replace("miui_vip_ph=", "")
|
|
|
|
|
break
|
|
|
|
|
return True
|
|
|
|
|
except:
|
|
|
|
|
return False
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# 提交满意度问卷
|
2021-09-06 18:39:01 +00:00
|
|
|
|
def submit_survey(sid):
|
2021-08-16 03:39:26 +00:00
|
|
|
|
headers = {
|
|
|
|
|
'cookie': str(cookie)
|
|
|
|
|
}
|
|
|
|
|
data = {
|
|
|
|
|
'survey': '{"surveyId":' + str(sid) + ',"answer":{"1":"A"}}',
|
|
|
|
|
'businessId': '2',
|
|
|
|
|
'miui_vip_ph': str(miui_vip_ph)
|
|
|
|
|
}
|
|
|
|
|
try:
|
|
|
|
|
response = requests.post('https://api.vip.miui.com/api/miui/dev/survey/submit', headers=headers, data=data)
|
2021-09-06 18:39:01 +00:00
|
|
|
|
r_json = response.json()
|
|
|
|
|
if r_json['code'] == 401:
|
|
|
|
|
return w_log("满意度投票失败:Cookie无效")
|
|
|
|
|
elif r_json['code'] != 200:
|
|
|
|
|
return w_log("满意度投票失败:" + str(r_json['message']))
|
|
|
|
|
w_log("满意度投票成功")
|
2021-08-16 03:39:26 +00:00
|
|
|
|
except:
|
2021-09-06 18:39:01 +00:00
|
|
|
|
w_log("满意度投票出错")
|
2021-08-16 03:39:26 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# 获取满意度投票问卷ID
|
2021-09-06 18:39:01 +00:00
|
|
|
|
def get_survey_id():
|
2021-08-16 03:39:26 +00:00
|
|
|
|
headers = {
|
|
|
|
|
'cookie': str(cookie)
|
|
|
|
|
}
|
|
|
|
|
try:
|
|
|
|
|
response = requests.get('https://api.vip.miui.com/api/miui/dev/survey?businessId=2', headers=headers)
|
2021-09-06 18:39:01 +00:00
|
|
|
|
r_json = response.json()
|
|
|
|
|
if r_json['code'] == 401:
|
|
|
|
|
return w_log("获取问卷ID失败:Cookie无效")
|
|
|
|
|
elif r_json['code'] != 200:
|
|
|
|
|
return w_log("获取问卷ID失败:" + str(r_json['message']))
|
|
|
|
|
elif r_json['entity']['surveyInfo']['surveyId'] is None:
|
|
|
|
|
w_log("获取问卷ID失败:问卷ID为空")
|
|
|
|
|
survey_id = r_json['entity']['surveyInfo']['surveyId']
|
|
|
|
|
w_log("获取问卷ID成功:" + str(survey_id))
|
|
|
|
|
submit_survey(survey_id)
|
2021-08-16 03:39:26 +00:00
|
|
|
|
except:
|
2021-09-06 18:39:01 +00:00
|
|
|
|
w_log("获取问卷ID出错,满意度投票失败")
|
2021-08-16 03:39:26 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# 取关用户
|
2021-09-06 18:39:01 +00:00
|
|
|
|
def unfollow_user():
|
2021-08-16 03:39:26 +00:00
|
|
|
|
headers = {
|
|
|
|
|
'cookie': str(cookie)
|
|
|
|
|
}
|
|
|
|
|
try:
|
|
|
|
|
response = requests.get('https://api.vip.miui.com/api/community/user/relation/unfollow?followeeId=210836962',
|
|
|
|
|
headers=headers)
|
2021-09-06 18:39:01 +00:00
|
|
|
|
r_json = response.json()
|
|
|
|
|
if r_json['code'] == 401:
|
|
|
|
|
return w_log("取关用户失败:Cookie无效")
|
|
|
|
|
elif r_json['code'] != 200:
|
|
|
|
|
return w_log("取关用户失败:" + str(r_json['message']))
|
|
|
|
|
w_log("取关用户成功")
|
2021-08-16 03:39:26 +00:00
|
|
|
|
except:
|
2021-09-06 18:39:01 +00:00
|
|
|
|
w_log("取关用户出错")
|
2021-08-16 03:39:26 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# 关注用户
|
2021-09-06 18:39:01 +00:00
|
|
|
|
def follow_user():
|
2021-08-16 03:39:26 +00:00
|
|
|
|
headers = {
|
|
|
|
|
'cookie': str(cookie)
|
|
|
|
|
}
|
|
|
|
|
try:
|
|
|
|
|
response = requests.get('https://api.vip.miui.com/api/community/user/relation/follow?followeeId=210836962',
|
|
|
|
|
headers=headers)
|
|
|
|
|
rJson = response.json()
|
|
|
|
|
if rJson['code'] == 401:
|
2021-09-06 18:39:01 +00:00
|
|
|
|
return w_log("关注用户失败:Cookie无效")
|
2021-08-16 03:39:26 +00:00
|
|
|
|
elif rJson['code'] != 200:
|
2021-09-06 18:39:01 +00:00
|
|
|
|
return w_log("关注用户失败:" + str(rJson['message']))
|
|
|
|
|
w_log("关注用户成功")
|
2021-08-16 03:39:26 +00:00
|
|
|
|
except:
|
2021-09-06 18:39:01 +00:00
|
|
|
|
w_log("关注用户出错")
|
2021-08-16 03:39:26 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# 退出圈子
|
2021-09-06 18:39:01 +00:00
|
|
|
|
def unfollow_board():
|
2021-08-16 03:39:26 +00:00
|
|
|
|
headers = {
|
|
|
|
|
'cookie': str(cookie)
|
|
|
|
|
}
|
|
|
|
|
try:
|
|
|
|
|
response = requests.get('https://api.vip.miui.com/api/community/board/unfollow?boardId=5462662',
|
|
|
|
|
headers=headers)
|
2021-09-06 18:39:01 +00:00
|
|
|
|
r_json = response.json()
|
|
|
|
|
if r_json['code'] == 401:
|
|
|
|
|
return w_log("退出圈子失败:Cookie无效")
|
|
|
|
|
elif r_json['code'] != 200:
|
|
|
|
|
return w_log("退出圈子失败:" + str(r_json['message']))
|
|
|
|
|
w_log("退出圈子成功")
|
2021-08-16 03:39:26 +00:00
|
|
|
|
except:
|
2021-09-06 18:39:01 +00:00
|
|
|
|
w_log("退出圈子出错")
|
2021-08-16 03:39:26 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# 加入圈子
|
2021-09-06 18:39:01 +00:00
|
|
|
|
def follow_board():
|
2021-08-16 03:39:26 +00:00
|
|
|
|
headers = {
|
|
|
|
|
'cookie': str(cookie)
|
|
|
|
|
}
|
|
|
|
|
try:
|
|
|
|
|
response = requests.get('https://api.vip.miui.com/api/community/board/follow?boardId=5462662', headers=headers)
|
2021-09-06 18:39:01 +00:00
|
|
|
|
r_json = response.json()
|
|
|
|
|
if r_json['code'] == 401:
|
|
|
|
|
return w_log("加入圈子失败:Cookie无效")
|
|
|
|
|
elif r_json['code'] != 200:
|
|
|
|
|
return w_log("加入圈子失败:" + str(r_json['message']))
|
|
|
|
|
w_log("加入圈子成功")
|
2021-08-16 03:39:26 +00:00
|
|
|
|
except:
|
2021-09-06 18:39:01 +00:00
|
|
|
|
w_log("加入圈子出错")
|
2021-08-16 03:39:26 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# 活跃度任务领取
|
2021-09-06 18:39:01 +00:00
|
|
|
|
def start_task(task_id):
|
2021-08-16 03:39:26 +00:00
|
|
|
|
headers = {
|
|
|
|
|
'cookie': str(cookie)
|
|
|
|
|
}
|
|
|
|
|
data = {
|
2021-09-06 18:39:01 +00:00
|
|
|
|
'taskId': str(task_id),
|
2021-08-16 03:39:26 +00:00
|
|
|
|
'miui_vip_ph': str(miui_vip_ph)
|
|
|
|
|
}
|
|
|
|
|
try:
|
|
|
|
|
response = requests.post('https://api.vip.miui.com/api/community/user/task/start?version=dev.210805',
|
|
|
|
|
headers=headers, data=data)
|
2021-09-06 18:39:01 +00:00
|
|
|
|
r_json = response.json()
|
|
|
|
|
if r_json['code'] == 401:
|
|
|
|
|
return w_log("开始活跃分任务失败:Cookie无效")
|
|
|
|
|
elif r_json['code'] != 200:
|
|
|
|
|
return w_log("开始活跃分任务失败:" + str(r_json['message']))
|
|
|
|
|
w_log("开始活跃分任务成功")
|
2021-08-16 03:39:26 +00:00
|
|
|
|
except:
|
2021-09-06 18:39:01 +00:00
|
|
|
|
w_log("开始活跃分任务出错")
|
2021-08-16 03:39:26 +00:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
# 活跃度任务完成
|
2021-09-06 18:39:01 +00:00
|
|
|
|
def acquire_task(task_id):
|
2021-08-16 03:39:26 +00:00
|
|
|
|
headers = {
|
|
|
|
|
'cookie': str(cookie)
|
|
|
|
|
}
|
|
|
|
|
data = {
|
2021-09-06 18:39:01 +00:00
|
|
|
|
'taskId': str(task_id),
|
2021-08-16 03:39:26 +00:00
|
|
|
|
'miui_vip_ph': str(miui_vip_ph)
|
|
|
|
|
}
|
|
|
|
|
try:
|
|
|
|
|
response = requests.post('https://api.vip.miui.com/api/community/user/task/acquire?version=dev.210805',
|
|
|
|
|
headers=headers, data=data)
|
2021-09-06 18:39:01 +00:00
|
|
|
|
r_json = response.json()
|
|
|
|
|
if r_json['code'] == 401:
|
|
|
|
|
return w_log("领取活跃分失败:Cookie无效")
|
|
|
|
|
elif r_json['code'] != 200:
|
|
|
|
|
return w_log("领取活跃分失败:" + str(r_json['message']))
|
|
|
|
|
w_log("领取活跃分成功")
|
2021-08-16 03:39:26 +00:00
|
|
|
|
except:
|
2021-09-06 18:39:01 +00:00
|
|
|
|
w_log("领取活跃分出错")
|
|
|
|
|
|
2021-08-16 03:39:26 +00:00
|
|
|
|
|
2021-08-21 15:52:45 +00:00
|
|
|
|
# 社区拔萝卜签到
|
2021-09-06 18:39:01 +00:00
|
|
|
|
def vip_sign_in():
|
2021-08-21 15:52:45 +00:00
|
|
|
|
headers = {
|
2021-09-06 18:39:01 +00:00
|
|
|
|
'Content-Type': 'application/x-www-form-urlencoded;charset=utf-8',
|
2021-08-21 15:52:45 +00:00
|
|
|
|
'cookie': str(cookie)
|
|
|
|
|
}
|
|
|
|
|
data = {
|
|
|
|
|
'miui_vip_ph': str(miui_vip_ph)
|
|
|
|
|
}
|
|
|
|
|
try:
|
|
|
|
|
response = requests.post('https://api.vip.miui.com/api/carrot/pull', headers=headers,
|
|
|
|
|
data=data)
|
2021-09-06 18:39:01 +00:00
|
|
|
|
r_json = response.json()
|
|
|
|
|
if r_json['code'] == 401:
|
|
|
|
|
return w_log("社区拔萝卜签到失败:Cookie无效")
|
|
|
|
|
elif r_json['code'] != 200:
|
|
|
|
|
return w_log("社区拔萝卜签到失败:" + str(r_json['message']))
|
|
|
|
|
w_log("社区拔萝卜签到成功")
|
2021-08-21 15:52:45 +00:00
|
|
|
|
except:
|
2021-09-06 18:39:01 +00:00
|
|
|
|
w_log("社区拔萝卜签到出错")
|
2021-08-21 15:52:45 +00:00
|
|
|
|
|
2021-08-16 03:39:26 +00:00
|
|
|
|
|
2021-09-06 18:39:01 +00:00
|
|
|
|
def mi_login():
|
2021-08-16 03:39:26 +00:00
|
|
|
|
proxies = {
|
|
|
|
|
'https': None,
|
|
|
|
|
'http': None
|
|
|
|
|
}
|
|
|
|
|
headers = {
|
|
|
|
|
'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8',
|
2021-09-06 18:39:01 +00:00
|
|
|
|
'Referer': 'https://account.xiaomi.com/fe/service/login/password?sid=miui_vip&qs=%253Fcallback%253Dhttp'
|
|
|
|
|
'%25253A%25252F%25252Fapi.vip.miui.com%25252Fsts%25253Fsign%25253D4II4ABwZkiJzkd2YSkyEZukI4Ak'
|
|
|
|
|
'%2525253D%252526followup%25253Dhttps%2525253A%2525252F%2525252Fapi.vip.miui.com%2525252Fpage'
|
|
|
|
|
'%2525252Flogin%2525253FdestUrl%2525253Dhttps%252525253A%252525252F%252525252Fweb.vip.miui.com'
|
|
|
|
|
'%252525252Fpage%252525252Finfo%252525252Fmio%252525252Fmio%252525252FinternalTest%252525253Fref'
|
|
|
|
|
'%252525253Dhomepage%2526sid%253Dmiui_vip&callback=http%3A%2F%2Fapi.vip.miui.com%2Fsts%3Fsign'
|
|
|
|
|
'%3D4II4ABwZkiJzkd2YSkyEZukI4Ak%253D%26followup%3Dhttps%253A%252F%252Fapi.vip.miui.com%252Fpage'
|
|
|
|
|
'%252Flogin%253FdestUrl%253Dhttps%25253A%25252F%25252Fweb.vip.miui.com%25252Fpage%25252Finfo'
|
|
|
|
|
'%25252Fmio%25252Fmio%25252FinternalTest%25253Fref%25253Dhomepage&_sign=L%2BdSQY6sjSQ%2FCRjJs4p'
|
|
|
|
|
'%2BU1vNYLY%3D&serviceParam=%7B%22checkSafePhone%22%3Afalse%2C%22checkSafeAddress%22%3Afalse%2C'
|
|
|
|
|
'%22lsrp_score%22%3A0.0%7D&showActiveX=false&theme=&needTheme=false&bizDeviceType=',
|
|
|
|
|
'User-Agent': str(l_ua),
|
2021-08-16 03:39:26 +00:00
|
|
|
|
'Origin': 'https://account.xiaomi.com',
|
|
|
|
|
'X-Requested-With': 'XMLHttpRequest',
|
2021-09-06 18:39:01 +00:00
|
|
|
|
'Cookie': 'deviceId=' + str(dev_id) + '; pass_ua=web; uLocale=zh_CN'
|
2021-08-16 03:39:26 +00:00
|
|
|
|
}
|
|
|
|
|
data = {
|
|
|
|
|
'bizDeviceType': '',
|
|
|
|
|
'needTheme': 'false',
|
|
|
|
|
'theme': '',
|
|
|
|
|
'showActiveX': 'false',
|
|
|
|
|
'serviceParam': '{"checkSafePhone":false,"checkSafeAddress":false,"lsrp_score":0.0}',
|
2021-09-06 18:39:01 +00:00
|
|
|
|
'callback': 'http://api.vip.miui.com/sts?sign=4II4ABwZkiJzkd2YSkyEZukI4Ak%3D&followup=https%3A%2F%2Fapi.vip'
|
|
|
|
|
'.miui.com%2Fpage%2Flogin%3FdestUrl%3Dhttps%253A%252F%252Fweb.vip.miui.com%252Fpage%252Finfo'
|
|
|
|
|
'%252Fmio%252Fmio%252FinternalTest%253Fref%253Dhomepage',
|
|
|
|
|
'qs': '%3Fcallback%3Dhttp%253A%252F%252Fapi.vip.miui.com%252Fsts%253Fsign%253D4II4ABwZkiJzkd2YSkyEZukI4Ak'
|
|
|
|
|
'%25253D%2526followup%253Dhttps%25253A%25252F%25252Fapi.vip.miui.com%25252Fpage%25252Flogin'
|
|
|
|
|
'%25253FdestUrl%25253Dhttps%2525253A%2525252F%2525252Fweb.vip.miui.com%2525252Fpage%2525252Finfo'
|
|
|
|
|
'%2525252Fmio%2525252Fmio%2525252FinternalTest%2525253Fref%2525253Dhomepage%26sid%3Dmiui_vip',
|
2021-08-16 03:39:26 +00:00
|
|
|
|
'sid': 'miui_vip',
|
|
|
|
|
'_sign': 'L+dSQY6sjSQ/CRjJs4p+U1vNYLY=',
|
2021-09-06 21:52:48 +00:00
|
|
|
|
'user': str(mi_id),
|
2021-08-16 03:39:26 +00:00
|
|
|
|
'cc': '+86',
|
2021-09-06 18:39:01 +00:00
|
|
|
|
'hash': str(p_md5),
|
2021-08-16 03:39:26 +00:00
|
|
|
|
'_json': 'true'
|
|
|
|
|
}
|
|
|
|
|
try:
|
|
|
|
|
response = requests.post('https://account.xiaomi.com/pass/serviceLoginAuth2', headers=headers, data=data,
|
|
|
|
|
proxies=proxies)
|
|
|
|
|
response_data = response.text.lstrip('&').lstrip('START').lstrip('&')
|
2021-09-06 18:39:01 +00:00
|
|
|
|
r_json = json.loads(response_data)
|
|
|
|
|
if r_json['code'] == 70016:
|
|
|
|
|
w_log('小米账号登录失败:用户名或密码不正确')
|
2021-08-16 03:39:26 +00:00
|
|
|
|
return False
|
2021-09-06 18:39:01 +00:00
|
|
|
|
if r_json['code'] != 0:
|
|
|
|
|
w_log('小米账号登录失败:' + r_json['desc'])
|
2021-08-16 03:39:26 +00:00
|
|
|
|
return False
|
2021-09-06 18:39:01 +00:00
|
|
|
|
if r_json['pwd'] != 1:
|
|
|
|
|
w_log('当前账号需要短信验证码,请尝试修改UA或设备ID')
|
2021-08-16 03:39:26 +00:00
|
|
|
|
return False
|
2021-09-06 18:39:01 +00:00
|
|
|
|
if not get_vip_cookie(r_json['location']):
|
|
|
|
|
w_log('小米账号登录成功,社区获取 Cookie 失败')
|
2021-08-16 03:39:26 +00:00
|
|
|
|
return False
|
2021-09-06 18:39:01 +00:00
|
|
|
|
w_log('账号登录完成')
|
2021-08-16 03:39:26 +00:00
|
|
|
|
return True
|
|
|
|
|
except:
|
2021-09-06 18:39:01 +00:00
|
|
|
|
w_log("登录小米账号出错")
|
2021-08-16 03:39:26 +00:00
|
|
|
|
return False
|
|
|
|
|
|
|
|
|
|
|
2021-09-11 15:28:59 +00:00
|
|
|
|
def get_score() -> int:
|
|
|
|
|
"""
|
|
|
|
|
这个方法待返回值的原因是,可以调用这个方法获取返回值,可根据这个方法定制自己的“消息提示功能”。
|
|
|
|
|
如:Qmsg发送到QQ 或者 发送邮件提醒
|
|
|
|
|
:return: 当前的内测分值
|
|
|
|
|
"""
|
|
|
|
|
headers = {
|
|
|
|
|
'cookie': str(cookie)
|
|
|
|
|
}
|
|
|
|
|
try:
|
|
|
|
|
response = requests.get('https://api.vip.miui.com/mtop/planet/vip/betaTest/score', headers=headers)
|
|
|
|
|
r_json = response.json()
|
|
|
|
|
your_score = r_json['entity']
|
|
|
|
|
w_log('成功获取内测分,当前内测分:' + str(your_score))
|
|
|
|
|
return your_score
|
|
|
|
|
except Exception as e:
|
|
|
|
|
w_log('内测分获取失败')
|
|
|
|
|
process_exception(e)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def process_exception(e: Exception):
|
|
|
|
|
"""
|
|
|
|
|
全局异常处理
|
|
|
|
|
:param e: 异常实例
|
|
|
|
|
:return: No return
|
|
|
|
|
"""
|
|
|
|
|
if e.__str__() == 'check_hostname requires server_hostname':
|
|
|
|
|
w_log('系统设置了代理,出现异常')
|
|
|
|
|
|
|
|
|
|
|
2021-08-16 03:39:26 +00:00
|
|
|
|
if __name__ == "__main__":
|
2021-09-07 01:07:31 +00:00
|
|
|
|
w_log("MIUITask_v1.3")
|
2021-09-06 18:39:01 +00:00
|
|
|
|
w_log('----------系统信息-开始-------------')
|
2021-09-06 21:52:48 +00:00
|
|
|
|
system_info()
|
2021-09-06 18:39:01 +00:00
|
|
|
|
w_log('----------系统信息-结束-------------')
|
|
|
|
|
w_log("项目地址:https://github.com/0-8-4/miui-auto-tasks")
|
|
|
|
|
w_log("欢迎star,感谢東雲研究所中的大佬")
|
2021-09-06 21:52:48 +00:00
|
|
|
|
w_log('----------检测配置文件-------------')
|
2021-09-07 01:07:31 +00:00
|
|
|
|
if conf_check(config):
|
|
|
|
|
w_log('----------------------------------')
|
|
|
|
|
w_log("开始登录小米账号")
|
|
|
|
|
if mi_login():
|
|
|
|
|
w_log("本脚本支持社区签到,因该功能存在风险默认禁用")
|
|
|
|
|
w_log("如您愿意承担一切可能的后果,可编辑配置文件手动打开该功能")
|
|
|
|
|
if config.get('SIGN_IN'):
|
|
|
|
|
w_log("风社险功能提示:正在进行区签到")
|
|
|
|
|
vip_sign_in()
|
|
|
|
|
start_task("10106263")
|
|
|
|
|
w_log("正在完成BUG反馈任务")
|
|
|
|
|
new_announce("7")
|
|
|
|
|
w_log("3秒后执行提建议任务")
|
|
|
|
|
acquire_task("10106263")
|
|
|
|
|
time.sleep(3)
|
|
|
|
|
w_log("正在完成提建议任务")
|
|
|
|
|
new_announce("6")
|
|
|
|
|
w_log("正在完成满意度调查任务")
|
|
|
|
|
get_survey_id()
|
|
|
|
|
w_log("正在完成点赞任务")
|
|
|
|
|
start_task("10106256")
|
|
|
|
|
for i in range(0, 5):
|
|
|
|
|
thumb_up()
|
|
|
|
|
time.sleep(0.2)
|
|
|
|
|
cancel_thumb_up()
|
|
|
|
|
time.sleep(0.2)
|
|
|
|
|
acquire_task("10106256")
|
|
|
|
|
w_log("正在完成活跃分_关注任务")
|
|
|
|
|
start_task("10106261")
|
|
|
|
|
unfollow_user()
|
|
|
|
|
follow_user()
|
|
|
|
|
w_log("5秒后领取活跃分_关注任务")
|
|
|
|
|
time.sleep(5)
|
|
|
|
|
acquire_task("10106261")
|
|
|
|
|
w_log("正在完成活跃分_加圈任务")
|
|
|
|
|
start_task("10106262")
|
|
|
|
|
unfollow_board()
|
|
|
|
|
follow_board()
|
|
|
|
|
w_log("5秒后领取活跃分_加圈任务")
|
|
|
|
|
time.sleep(5)
|
|
|
|
|
acquire_task("10106262")
|
|
|
|
|
w_log("正在完成活跃分_发帖任务")
|
|
|
|
|
start_task("10106265")
|
|
|
|
|
new_announce("5")
|
|
|
|
|
w_log("5秒后领取活跃分_发帖任务")
|
|
|
|
|
time.sleep(5)
|
|
|
|
|
acquire_task("10106265")
|
2021-09-11 15:28:59 +00:00
|
|
|
|
get_score()
|
2021-09-07 01:07:31 +00:00
|
|
|
|
s_log()
|