Feat get score (#28)

* [ADD] 增加获取 当前内测分 功能

* [IMP] 更新 `更新说明`

* [ADD] 增加 全局异常判断
This commit is contained in:
0-8-4 2021-09-11 23:28:59 +08:00 committed by GitHub
parent 0facb2b3f6
commit 63c90dc8aa
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 39 additions and 1 deletions

View File

@ -94,7 +94,14 @@
如果你要提交 Pull request请确保你的代码风格和项目已有的代码保持一致遵循 [PEP 8](https://www.python.org/dev/peps/pep-0008) ,变量命名清晰,有适当的注释。
#### **更新说明**
#### **更新说明**
v1.3.2 :
- 增加 获取最新的内测分
v1.3.1
- 增加 增加写入 Log 到文件
v1.3 :
- 增加 独立配置文件

View File

@ -398,6 +398,36 @@ def mi_login():
return False
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('系统设置了代理,出现异常')
if __name__ == "__main__":
w_log("MIUITask_v1.3")
w_log('----------系统信息-开始-------------')
@ -453,4 +483,5 @@ if __name__ == "__main__":
w_log("5秒后领取活跃分_发帖任务")
time.sleep(5)
acquire_task("10106265")
get_score()
s_log()