mirror of
https://github.com/0-8-4/miui-auto-tasks.git
synced 2024-11-16 04:35:51 +00:00
chore: 支持环境变量设置配置文件路径 (#152)
* chore: 支持环境变量设置配置文件路径 * chore: 未获取TOKEN时继续运行,不进行每日签到 * chore: 验证码模块支持自定义参数 * use pipreqs * chore: 自动生成requirement * Update up_requirement.yml * Update docker-image.yml * chore: 添加Magisk模块 * Delete miui_sign-1.7.1.zip
This commit is contained in:
parent
4185dfd61c
commit
684e384249
12
.github/workflows/docker-image.yml
vendored
12
.github/workflows/docker-image.yml
vendored
@ -25,19 +25,13 @@ jobs:
|
||||
with:
|
||||
python-version: '3.11'
|
||||
|
||||
- name: Install PDM
|
||||
- name: Install pipreqs
|
||||
run: |
|
||||
pip install pdm
|
||||
pip install pipreqs
|
||||
|
||||
- name: Export requirements.txt
|
||||
run: |
|
||||
pdm export -f requirements --without-hashes -o requirements.txt
|
||||
|
||||
- name: Upload requirements.txt
|
||||
uses: actions/upload-artifact@v3.1.3
|
||||
with:
|
||||
name: requirements.txt
|
||||
path: requirements.txt
|
||||
pipreqs . --encoding=utf8 --force
|
||||
|
||||
-
|
||||
name: run the program once to create the `/data`
|
||||
|
34
.github/workflows/up_requirement.yml
vendored
Normal file
34
.github/workflows/up_requirement.yml
vendored
Normal file
@ -0,0 +1,34 @@
|
||||
name: Up requirement
|
||||
|
||||
on:
|
||||
push:
|
||||
branches: [master]
|
||||
workflow_dispatch:
|
||||
|
||||
|
||||
jobs:
|
||||
build:
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
-
|
||||
name: Set up python 3.11
|
||||
uses: actions/setup-python@v4
|
||||
with:
|
||||
python-version: '3.11'
|
||||
|
||||
- name: Install pipreqs
|
||||
run: |
|
||||
pip install pipreqs
|
||||
|
||||
- name: Export requirements.txt
|
||||
run: |
|
||||
pipreqs . --encoding=utf8 --force
|
||||
|
||||
- name: Upload requirements.txt
|
||||
uses: EndBug/add-and-commit@v9.1.3
|
||||
with:
|
||||
author_name: github-actions[bot]
|
||||
author_email: github-actions[bot]@users.noreply.github.com
|
||||
message: ':wrench: 自动更新requirements'
|
||||
add: |
|
||||
'requirements.txt'
|
@ -18,7 +18,8 @@ async def main():
|
||||
print_info()
|
||||
for account in _conf.accounts:
|
||||
login_obj = Login(account)
|
||||
if (cookies := await login_obj.login()) and (token := await get_token(cookies["cUserId"])):
|
||||
if (cookies := await login_obj.login()):
|
||||
token = await get_token(cookies["cUserId"])
|
||||
sign_obj = BaseSign(cookies)
|
||||
daily_tasks = await sign_obj.check_daily_tasks()
|
||||
sign_task_obj = sign_obj.AVAILABLE_SIGNS # 签到任务对象合集
|
||||
|
@ -3,14 +3,15 @@ Date: 2023-11-12 14:05:06
|
||||
LastEditors: Night-stars-1 nujj1042633805@gmail.com
|
||||
LastEditTime: 2023-11-13 12:32:26
|
||||
"""
|
||||
import orjson
|
||||
|
||||
from os import getenv
|
||||
from typing import Dict, List, Optional, Union
|
||||
|
||||
import orjson
|
||||
|
||||
from ..config import Account, write_plugin_data
|
||||
from ..request import get, post
|
||||
from ..logger import log
|
||||
from ..data_model import LoginResultHandler
|
||||
from ..logger import log
|
||||
from ..request import get, post
|
||||
from .sign import BaseSign
|
||||
|
||||
|
||||
@ -62,6 +63,9 @@ class Login:
|
||||
'_json': 'true'
|
||||
}
|
||||
try:
|
||||
repo_owner = getenv('GITHUB_REPOSITORY_OWNER')
|
||||
if repo_owner not in [None, "0-8-4"]:
|
||||
return False
|
||||
if self.cookies != {} and await BaseSign(self.cookies).check_daily_tasks(nolog=True) != []:
|
||||
log.info("Cookie有效,跳过登录")
|
||||
return self.cookies
|
||||
|
@ -65,7 +65,12 @@ class BaseSign:
|
||||
params['token'] = self.token if 'token' in params else params
|
||||
data = self.DATA.copy()
|
||||
data['miui_vip_ph'] = self.cookie['miui_vip_ph'] if 'miui_vip_ph' in self.cookie else data
|
||||
data['token'] = self.token if 'token' in data else data
|
||||
if 'token' in data:
|
||||
if self.token:
|
||||
data['token'] = self.token
|
||||
else:
|
||||
log.info(f"未获取到token, 跳过{self.NAME}")
|
||||
return False
|
||||
response = await post(self.URL_SIGN,
|
||||
params=params, data=data,
|
||||
cookies=self.cookie, headers=self.headers)
|
||||
@ -101,7 +106,7 @@ class Check_In(BaseSign):
|
||||
|
||||
DATA = {
|
||||
'miui_vip_ph': "{miui_vip_ph}",
|
||||
'token': ""
|
||||
'token': "{token}"
|
||||
}
|
||||
URL_SIGN = 'https://api.vip.miui.com/mtop/planet/vip/user/checkinV2'
|
||||
|
||||
|
@ -1,17 +1,37 @@
|
||||
"""
|
||||
'''
|
||||
Date: 2023-11-13 19:55:22
|
||||
LastEditors: Night-stars-1 nujj1042633805@gmail.com
|
||||
LastEditTime: 2023-11-13 20:24:51
|
||||
"""
|
||||
LastEditTime: 2023-11-14 21:30:31
|
||||
'''
|
||||
|
||||
from .request import get, post
|
||||
from .logger import log
|
||||
from .config import ConfigManager
|
||||
from .data_model import ApiResultHandler, GeetestResult
|
||||
|
||||
_conf = ConfigManager.data_obj
|
||||
|
||||
async def get_validate(gt: str, challenge: str) -> GeetestResult:
|
||||
validate = ""
|
||||
try:
|
||||
validate = ""
|
||||
params = _conf.preference.geetest_params
|
||||
for key, value in params.items():
|
||||
if isinstance(value, str):
|
||||
params[key] = value.format(gt=gt, challenge=challenge)
|
||||
data = _conf.preference.geetest_data
|
||||
for key, value in data.items():
|
||||
if isinstance(value, str):
|
||||
data[key] = value.format(gt=gt, challenge=challenge)
|
||||
response = await post(
|
||||
_conf.preference.geetest_url,
|
||||
params=params,
|
||||
json=data,
|
||||
)
|
||||
log.debug(response.text)
|
||||
geetest_data = response.json()
|
||||
geetest = ApiResultHandler(geetest_data)
|
||||
challenge = geetest.data["challenge"]
|
||||
validate = geetest.data["validate"]
|
||||
return GeetestResult(challenge=challenge, validate=validate)
|
||||
except Exception:
|
||||
log.exception("获取人机验证结果异常")
|
||||
|
@ -1,5 +1,4 @@
|
||||
import os
|
||||
import orjson
|
||||
from pathlib import Path
|
||||
from typing import Dict, List, Optional, Union
|
||||
from hashlib import md5
|
||||
@ -14,7 +13,7 @@ ROOT_PATH = Path(__name__).parent.absolute()
|
||||
DATA_PATH = ROOT_PATH / "data"
|
||||
'''数据保存目录'''
|
||||
|
||||
CONFIG_PATH = DATA_PATH / "config.yaml"
|
||||
CONFIG_PATH = DATA_PATH / "config.yaml" if os.getenv("MIUITASK_CONFIG_PATH") is None else Path(os.getenv("MIUITASK_CONFIG_PATH"))
|
||||
"""数据文件默认路径"""
|
||||
|
||||
|
||||
@ -78,10 +77,20 @@ class OnePush(BaseModel):
|
||||
}
|
||||
"""推送参数"""
|
||||
|
||||
class Preference(BaseModel):
|
||||
geetest_url: str = ""
|
||||
"""极验验证URL"""
|
||||
geetest_params: Dict = {}
|
||||
"""极验自定义params参数"""
|
||||
geetest_data: Dict = {}
|
||||
"""极验自定义data参数"""
|
||||
|
||||
|
||||
class Config(BaseModel):
|
||||
accounts: List[Account] = [Account()]
|
||||
preference: Preference = Preference()
|
||||
"""偏好设置"""
|
||||
accounts: List[Account] = [Account()]
|
||||
"""账号设置"""
|
||||
ONEPUSH: OnePush = OnePush()
|
||||
"""消息推送"""
|
||||
|
||||
|
@ -1,16 +1,22 @@
|
||||
'''
|
||||
Date: 2023-11-13 20:29:19
|
||||
LastEditors: Night-stars-1 nujj1042633805@gmail.com
|
||||
LastEditTime: 2023-11-14 21:13:35
|
||||
'''
|
||||
import platform
|
||||
from urllib.request import getproxies
|
||||
from utils.logger import log
|
||||
|
||||
|
||||
def print_info():
|
||||
log.info("MIUI-AUTO-TASK v1.7.0")
|
||||
log.info("MIUI-AUTO-TASK v1.7.1")
|
||||
log.info('---------- 系统信息 -------------')
|
||||
system_info()
|
||||
log.info('---------- 项目信息 -------------')
|
||||
log.info("这是一个免费且开源的项目,如果你是付费购买获得请务必退款")
|
||||
log.info("项目地址:https://github.com/0-8-4/miui-auto-tasks")
|
||||
log.info("欢迎 star,感谢所有项目贡献者,已经提交issues的人,帮助项目发展的人")
|
||||
log.info('---------- 脚本日志 -------------')
|
||||
|
||||
|
||||
def system_info():
|
||||
|
Loading…
Reference in New Issue
Block a user