fix: 修复主程序卡死与下载器集成,新增真实数据测试

- LookingWebMain: 强制 IPv4 避免 IPv6 不可达挂起;requests 加超时防卡死
- get_seed_from_element_detail: 修复限流页崩溃与 favicon 误作来源 URL,改用 canonical/传入 URL
- QbittorrentDownloader: 修复 main() 中模块/类误用导致的 download_by_seed AttributeError;请求加超时
- MySqlService: 修复数据库不可达时 query/execute/close 的 None 崩溃,close 后置空 connection
- 新增 cf_session: Cloudflare 人机认证 cookie 管理 + 限流退避重试 + 自动弹浏览器刷新验证
- 新增 refresh_cf_cookies.py: 弹出浏览器手动验证并保存 cf_clearance
- tests/: 真实网络/数据库测试(get_page、seed_is_exist、cf_session)+ run_tests.py runner
- 清理无用脚本(final_test2/verify_replace/REPLACEMENT_INFO),.idea 与 cookie 文件入 .gitignore

注: test_qbittorrent_downloader.py 11 个用例为既有失败(mock 目标 session 为实例属性,与实现错配),未在本次范围
This commit is contained in:
2026-08-30 12:24:26 +08:00
parent f8e8fd38b4
commit 01827224d6
14 changed files with 1327 additions and 18 deletions
+9 -3
View File
@@ -22,9 +22,9 @@ class MySQLDatabase:
def __enter__(self):
self.connect()
return self
def __exit__(self, exc_type, exc_val, exc_tb):
self.connection.close()
if self.connection and self.connection.open:
self.connection.close()
@classmethod
def create_connection(cls):
@@ -46,9 +46,12 @@ class MySQLDatabase:
def close(self):
if self.connection and self.connection.open:
self.connection.close()
self.connection = None
def query(self, sql, params=None):
self.connect()
if not self.connection:
logger.error("查询失败:{},无数据库连接", sql)
return None
with self.connection.cursor() as cursor:
try:
cursor.execute(sql, params or ())
@@ -61,6 +64,9 @@ class MySQLDatabase:
def execute(self, sql, params=None):
self.connect()
if not self.connection:
logger.error("执行失败:{},无数据库连接", sql)
return
with self.connection.cursor() as cursor:
cursor.execute(sql, params or ())
self.connection.commit()