From 712a2cbdae4bfff1c6930823155812e5feeb9e30 Mon Sep 17 00:00:00 2001 From: Franklin-F Date: Mon, 16 Jun 2025 22:36:22 +0800 Subject: [PATCH] =?UTF-8?q?refactor:=20=E4=BC=98=E5=8C=96report.py?= =?UTF-8?q?=E4=B8=AD=E7=9A=84=E4=B8=BB=E6=B5=81=E7=A8=8B=E9=80=BB=E8=BE=91?= =?UTF-8?q?=EF=BC=8C=E6=81=A2=E5=A4=8D=E7=8A=B6=E6=80=81=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=E5=B9=B6=E6=B7=BB=E5=8A=A0=E9=94=99=E8=AF=AF?= =?UTF-8?q?=E5=A4=84=E7=90=86?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- report.py | 36 ++++++++++++++++++------------------ report_video.py | 5 +++-- 2 files changed, 21 insertions(+), 20 deletions(-) diff --git a/report.py b/report.py index 85e1722..98516ac 100644 --- a/report.py +++ b/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: diff --git a/report_video.py b/report_video.py index 5a1b067..4fc68cd 100644 --- a/report_video.py +++ b/report_video.py @@ -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: