From 30fec316a920dc4c8a76a8b8147577b14f4ef41d Mon Sep 17 00:00:00 2001 From: Night-stars-1 <99261160+Night-stars-1@users.noreply.github.com> Date: Thu, 7 Dec 2023 22:19:50 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E6=94=B9=E4=BE=9D=E8=B5=96=20(?= =?UTF-8?q?#232)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * fix: 修复无法构建docker镜像的问题 * Update Dockerfile * :wrench: 自动更新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 * :wrench: 自动更新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] --- README.md | 11 ----------- pyproject.toml | 2 +- utils/api/login.py | 26 +++++++++++++------------- 3 files changed, 14 insertions(+), 25 deletions(-) diff --git a/README.md b/README.md index 7d9c9fc..f1164ff 100644 --- a/README.md +++ b/README.md @@ -46,17 +46,6 @@ ``` 注意:你可能需要使用管理员权限运行命令行 - -### **快速上手**: - -1. 配置好 `config.yaml` 文件,并与 `miuitask.py` 文件放在同一个目录下 -2. 使用终端 在 `miuitask.py` 所在目录下运行如下命令: - - ```bash - python3 miuitask.py - ``` - - ### **项目介绍**: - [x] 支持 多账号 配置 - [x] 支持 Docker 部署 diff --git a/pyproject.toml b/pyproject.toml index 252c31e..60ef542 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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"} diff --git a/utils/api/login.py b/utils/api/login.py index 69560f7..01b0b74 100644 --- a/utils/api/login.py +++ b/utils/api/login.py @@ -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 + \ No newline at end of file