refactor: 优化report.py中的主流程逻辑,恢复状态更新功能并添加错误处理
This commit is contained in:
parent
97d00d04ab
commit
712a2cbdae
36
report.py
36
report.py
@ -22,24 +22,24 @@ while True:
|
||||
now = int(time.time())
|
||||
|
||||
# 处理主流程
|
||||
# if now - last_main_run >= MAIN_INTERVAL:
|
||||
# last_main_run = now
|
||||
# lis = db.get_report_video()
|
||||
# if len(lis) > 0:
|
||||
# for li in lis:
|
||||
# logger.logger.info(f"name:{li['name_title']},link:{li['link']} ")
|
||||
# try:
|
||||
# info, report_id, status, report_ts = d.process_ticket(li['name_title'], li['link'])
|
||||
# subsequent_status = k.get(status, 1)
|
||||
# db.update_fight_record_status(
|
||||
# li['id'], report_id, 2, f"http://123.58.197.91:5000/image/{info}",
|
||||
# report_ts, subsequent_status
|
||||
# )
|
||||
# db.flush()
|
||||
# except Exception as e:
|
||||
# logger.logger.error(f"ID:{li['id']}, e:{e}")
|
||||
# db.update_fight_record_status(li['id'], 0, 3, str(e))
|
||||
# time.sleep(60) # 出错延迟
|
||||
if now - last_main_run >= MAIN_INTERVAL:
|
||||
last_main_run = now
|
||||
lis = db.get_report_video()
|
||||
if len(lis) > 0:
|
||||
for li in lis:
|
||||
logger.logger.info(f"name:{li['name_title']},link:{li['link']} ")
|
||||
try:
|
||||
info, report_id, status, report_ts = d.process_ticket(li['name_title'], li['link'])
|
||||
subsequent_status = k.get(status, 1)
|
||||
db.update_fight_record_status(
|
||||
li['id'], report_id, 2, f"http://123.58.197.91:5000/image/{info}",
|
||||
report_ts, subsequent_status
|
||||
)
|
||||
db.flush()
|
||||
except Exception as e:
|
||||
logger.logger.error(f"ID:{li['id']}, e:{e}")
|
||||
db.update_fight_record_status(li['id'], 0, 3, str(e))
|
||||
time.sleep(60) # 出错延迟
|
||||
|
||||
|
||||
if now - last_subsequent_run >= SUBSEQUENT_INTERVAL:
|
||||
|
@ -129,7 +129,8 @@ class DailymotionClient:
|
||||
|
||||
def _do_login(self) -> None:
|
||||
self.page.goto(self.url, timeout=30000)
|
||||
self.page.wait_for_load_state("networkidle", timeout=30000)
|
||||
# self.page.wait_for_load_state("networkidle", timeout=30000)
|
||||
self.page.wait_for_timeout(3000)
|
||||
|
||||
file_path = f'screenshots/{str(int(time.time()))}.png'
|
||||
self.page.screenshot(path=file_path)
|
||||
@ -176,7 +177,7 @@ class DailymotionClient:
|
||||
|
||||
def _detect_login(self) -> bool:
|
||||
self.page.goto(self.url, timeout=30000)
|
||||
self.page.wait_for_load_state("networkidle", timeout=30000)
|
||||
self.page.wait_for_timeout(3000)
|
||||
return self.page.locator("//a[@class='login button']").count() == 0
|
||||
|
||||
def is_logged_in(self) -> bool:
|
||||
|
Loading…
x
Reference in New Issue
Block a user