mirror of
https://github.com/0-8-4/miui-auto-tasks.git
synced 2024-11-21 22:58:06 +00:00
feat: 添加设置login_user_agent提示 (#293)
* feat: 添加视频浏览任务 * fix: 修复无法找到视频任务配置的问题 * feat: 添加未设置`login_user_agent`提示 * fix: string statement has no effect
This commit is contained in:
parent
8a7913aba9
commit
971b867321
2
.github/workflows/up_requirement.yml
vendored
2
.github/workflows/up_requirement.yml
vendored
@ -27,7 +27,7 @@ jobs:
|
|||||||
pipreqs . --encoding=utf8 --force
|
pipreqs . --encoding=utf8 --force
|
||||||
|
|
||||||
- name: Upload requirements.txt
|
- name: Upload requirements.txt
|
||||||
uses: EndBug/add-and-commit@v9.1.3
|
uses: EndBug/add-and-commit@v9.1.4
|
||||||
with:
|
with:
|
||||||
author_name: github-actions[bot]
|
author_name: github-actions[bot]
|
||||||
author_email: github-actions[bot]@users.noreply.github.com
|
author_email: github-actions[bot]@users.noreply.github.com
|
||||||
|
15
.vscode/launch.json
vendored
Normal file
15
.vscode/launch.json
vendored
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
{
|
||||||
|
// 使用 IntelliSense 了解相关属性。
|
||||||
|
// 悬停以查看现有属性的描述。
|
||||||
|
// 欲了解更多信息,请访问: https://go.microsoft.com/fwlink/?linkid=830387
|
||||||
|
"version": "0.2.0",
|
||||||
|
"configurations": [
|
||||||
|
{
|
||||||
|
"name": "Python 调试程序: 签到",
|
||||||
|
"type": "debugpy",
|
||||||
|
"request": "launch",
|
||||||
|
"program": "${workspaceFolder}/miuitask.py",
|
||||||
|
"console": "integratedTerminal"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
@ -1,13 +1,9 @@
|
|||||||
"""
|
"""
|
||||||
Author: Night-stars-1 nujj1042633805@gmail.com
|
Author: Night-stars-1 nujj1042633805@gmail.com
|
||||||
Date: 2024-02-21 22:50:45
|
Date: 2024-02-21 22:50:45
|
||||||
LastEditTime: 2024-04-05 22:43:45
|
LastEditTime: 2024-08-20 22:36:18
|
||||||
LastEditors: Night-stars-1 nujj1042633805@gmail.com
|
LastEditors: Night-stars-1 nujj1042633805@gmail.com
|
||||||
"""
|
"""
|
||||||
|
|
||||||
# new Env("MIUI-Auto-Task") # pylint: disable=missing-module-docstring
|
|
||||||
# cron 30 8 * * * miuitask.py
|
|
||||||
|
|
||||||
import asyncio
|
import asyncio
|
||||||
|
|
||||||
from tenacity import Retrying, stop_after_attempt
|
from tenacity import Retrying, stop_after_attempt
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
"""
|
"""
|
||||||
Date: 2023-11-12 14:05:06
|
Date: 2023-11-12 14:05:06
|
||||||
LastEditors: Night-stars-1 nujj1042633805@gmail.com
|
LastEditors: Night-stars-1 nujj1042633805@gmail.com
|
||||||
LastEditTime: 2024-04-05 22:53:24
|
LastEditTime: 2024-08-20 22:40:54
|
||||||
"""
|
"""
|
||||||
|
|
||||||
import time
|
import time
|
||||||
@ -14,8 +14,8 @@ from ..config import Account, write_plugin_data
|
|||||||
from ..data_model import LoginResultHandler
|
from ..data_model import LoginResultHandler
|
||||||
from ..logger import log
|
from ..logger import log
|
||||||
from ..request import get, post
|
from ..request import get, post
|
||||||
from .sign import BaseSign
|
|
||||||
from ..utils import generate_qrcode
|
from ..utils import generate_qrcode
|
||||||
|
from .sign import BaseSign
|
||||||
|
|
||||||
|
|
||||||
class Login:
|
class Login:
|
||||||
@ -33,6 +33,9 @@ class Login:
|
|||||||
self,
|
self,
|
||||||
) -> Union[Dict[str, str], bool]:
|
) -> Union[Dict[str, str], bool]:
|
||||||
"""登录小米账号"""
|
"""登录小米账号"""
|
||||||
|
if not self.user_agent:
|
||||||
|
log.error("请设置 login_user_agent")
|
||||||
|
return False
|
||||||
headers = {
|
headers = {
|
||||||
"Content-Type": "application/x-www-form-urlencoded",
|
"Content-Type": "application/x-www-form-urlencoded",
|
||||||
"User-Agent": self.user_agent,
|
"User-Agent": self.user_agent,
|
||||||
@ -83,15 +86,14 @@ class Login:
|
|||||||
log.success("小米账号登录成功")
|
log.success("小米账号登录成功")
|
||||||
self.account.cookies["passToken"] = api_data.pass_token
|
self.account.cookies["passToken"] = api_data.pass_token
|
||||||
self.account.uid = api_data.user_id
|
self.account.uid = api_data.user_id
|
||||||
if (
|
if cookies := await self.get_cookies_by_passtk(
|
||||||
cookies := await self.get_cookies_by_passtk(
|
|
||||||
api_data.user_id, api_data.pass_token
|
api_data.user_id, api_data.pass_token
|
||||||
)
|
):
|
||||||
) is False:
|
|
||||||
return False
|
|
||||||
self.account.cookies.update(cookies)
|
self.account.cookies.update(cookies)
|
||||||
write_plugin_data()
|
write_plugin_data()
|
||||||
return cookies
|
return cookies
|
||||||
|
log.error("获取Cookie失败,可能是 login_user_agent 异常")
|
||||||
|
return False
|
||||||
elif api_data.pwd_wrong:
|
elif api_data.pwd_wrong:
|
||||||
log.error("小米账号登录失败:用户名或密码不正确, 请扫码登录")
|
log.error("小米账号登录失败:用户名或密码不正确, 请扫码登录")
|
||||||
check_url = await self.qr_login()
|
check_url = await self.qr_login()
|
||||||
@ -120,9 +122,7 @@ class Login:
|
|||||||
log.exception("社区获取 Cookie 失败")
|
log.exception("社区获取 Cookie 失败")
|
||||||
return False
|
return False
|
||||||
|
|
||||||
async def get_cookies_by_passtk(
|
async def get_cookies_by_passtk(self, user_id: str, pass_token: str):
|
||||||
self, user_id: str, pass_token: str
|
|
||||||
) -> Union[Dict[str, str], bool]:
|
|
||||||
"""使用passToken获取签到cookies"""
|
"""使用passToken获取签到cookies"""
|
||||||
try:
|
try:
|
||||||
headers = {
|
headers = {
|
||||||
|
Loading…
Reference in New Issue
Block a user