mirror of
https://github.com/0-8-4/miui-auto-tasks.git
synced 2024-11-23 08:20:53 +00:00
fix: 修改依赖 (#232)
* fix: 修复无法构建docker镜像的问题 * Update Dockerfile * 🔧 自动更新requirements * chore: 添加自动每日运行时间提示 * chore: 将时间类型从str改成int * Add files via upload * chore: 更新日志收集方法 * chore: 遵守代码规范 * chore: update issue templates * chore: 删除测试代码 * chore: 更改日志输出样式 * chore: docker生成配置时随机生成自动运行时间 * chore: trailing-whitespace * chore: 日志添加换行 * chore: 未配置验证码解决方案时直接跳过 * chore: 使用遍历方法找到键值,提升泛用性 * chore: 使用cron执行自动任务 * chore: snake_case * chore: 修改运行时间 * Update config.py * chore: 添加签到重试,仅每日签到获取token * 🔧 自动更新requirements * chore: 更新版本号 * Update config.py * 改用正则获取成长值 * chore: 更新文档 * fix: 修复在一些情况下cookies被写入false * fix: Method 'get_cookie' should have "self" as first argument --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
This commit is contained in:
parent
f85232e5ee
commit
30fec316a9
11
README.md
11
README.md
@ -46,17 +46,6 @@
|
||||
```
|
||||
注意:你可能需要使用管理员权限运行命令行
|
||||
|
||||
|
||||
### **快速上手**:
|
||||
|
||||
1. 配置好 `config.yaml` 文件,并与 `miuitask.py` 文件放在同一个目录下
|
||||
2. 使用终端 在 `miuitask.py` 所在目录下运行如下命令:
|
||||
|
||||
```bash
|
||||
python3 miuitask.py
|
||||
```
|
||||
|
||||
|
||||
### **项目介绍**:
|
||||
- [x] 支持 多账号 配置
|
||||
- [x] 支持 Docker 部署
|
||||
|
@ -12,7 +12,7 @@ dependencies = [
|
||||
"pyyaml>=6.0.1",
|
||||
"tenacity>=8.2.3",
|
||||
"tzdata>=2023.3",
|
||||
"onepush @ git+https://github.com/y1ndan/onepush.git@main",
|
||||
"onepush>=1.3.0",
|
||||
]
|
||||
requires-python = ">=3.11"
|
||||
license = {text = "MIT"}
|
||||
|
@ -14,18 +14,6 @@ from ..logger import log
|
||||
from ..request import get, post
|
||||
from .sign import BaseSign
|
||||
|
||||
|
||||
async def get_cookie(url: str) -> Union[Dict[str, str], bool]:
|
||||
"""获取社区 Cookie"""
|
||||
try:
|
||||
response = await get(url, follow_redirects=False)
|
||||
log.debug(response.text)
|
||||
return dict(response.cookies)
|
||||
except Exception: # pylint: disable=broad-exception-caught
|
||||
log.exception("社区获取 Cookie 失败")
|
||||
return False
|
||||
|
||||
|
||||
class Login:
|
||||
"""登录类"""
|
||||
|
||||
@ -90,7 +78,8 @@ class Login:
|
||||
api_data = LoginResultHandler(data)
|
||||
if api_data.success:
|
||||
log.success('小米账号登录成功')
|
||||
cookies = await get_cookie(api_data.location)
|
||||
if (cookies := await self.get_cookie(api_data.location)) is False:
|
||||
return False
|
||||
self.account.cookies = cookies
|
||||
write_plugin_data()
|
||||
return cookies
|
||||
@ -104,3 +93,14 @@ class Login:
|
||||
except Exception: # pylint: disable=broad-exception-caught
|
||||
log.exception("登录小米账号出错")
|
||||
return False
|
||||
|
||||
async def get_cookie(self, url: str) -> Union[Dict[str, str], bool]:
|
||||
"""获取社区 Cookie"""
|
||||
try:
|
||||
response = await get(url, follow_redirects=False)
|
||||
log.debug(response.text)
|
||||
return dict(response.cookies)
|
||||
except Exception: # pylint: disable=broad-exception-caught
|
||||
log.exception("社区获取 Cookie 失败")
|
||||
return False
|
||||
|
Loading…
Reference in New Issue
Block a user