Merge branch 'main' into feat/db

This commit is contained in:
felinae98
2022-04-30 15:17:08 +08:00
11 changed files with 132 additions and 105 deletions
@@ -47,7 +47,7 @@ class Bilibili(NewMessage):
)
res_dict = json.loads(res.text)
if res_dict["code"] == 0:
return res_dict["data"]["cards"]
return res_dict["data"].get("cards")
else:
return []
+1 -1
View File
@@ -130,7 +130,7 @@ class Weibo(NewMessage):
)
try:
full_json_text = re.search(
r'"status": ([\s\S]+),\s+"hotScheme"', res.text
r'"status": ([\s\S]+),\s+"call"', res.text
).group(1)
info = json.loads(full_json_text)
except:
+12 -13
View File
@@ -17,6 +17,18 @@ scheduler = AsyncIOScheduler(timezone="Asia/Shanghai")
@get_driver().on_startup
async def _start():
for platform_name, platform in platform_manager.items():
if platform.schedule_type in ["cron", "interval", "date"]:
logger.info(
f"start scheduler for {platform_name} with {platform.schedule_type} {platform.schedule_kw}"
)
scheduler.add_job(
fetch_and_send,
platform.schedule_type,
**platform.schedule_kw,
args=(platform_name,),
)
scheduler.configure({"apscheduler.timezone": "Asia/Shanghai"})
scheduler.start()
@@ -64,19 +76,6 @@ async def fetch_and_send(target_type: str):
)
for platform_name, platform in platform_manager.items():
if platform.schedule_type in ["cron", "interval", "date"]:
logger.info(
f"start scheduler for {platform_name} with {platform.schedule_type} {platform.schedule_kw}"
)
scheduler.add_job(
fetch_and_send,
platform.schedule_type,
**platform.schedule_kw,
args=(platform_name,),
)
class CustomLogHandler(LoguruHandler):
def filter(self, record: logging.LogRecord):
return record.msg != (