fix: 修改代理获取逻辑以使用新的 fetch_proxies2 函数并优化打印信息

This commit is contained in:
晓丰 2025-05-17 13:46:45 +08:00
parent e4ae20acb4
commit 8e0c99284b
3 changed files with 15 additions and 9 deletions

1
DB.py
View File

@ -162,6 +162,7 @@ class DBVidcon:
data.setdefault("a_id", 0) data.setdefault("a_id", 0)
data.setdefault("history_status", "") data.setdefault("history_status", "")
data.setdefault("is_piracy", 3) data.setdefault("is_piracy", 3)
data.setdefault("is_repeat", 3)
data["sort"] = data.get("index", 0) data["sort"] = data.get("index", 0)
max_retries = 1 # 除了第一次外,再重试一次 max_retries = 1 # 除了第一次外,再重试一次

View File

@ -569,7 +569,7 @@ def get_searchInfo(keyword):
print('resinfo :', len(resinfo)) print('resinfo :', len(resinfo))
except Exception: except Exception:
resinfo = [] resinfo = []
print(response.text) print("[搜索接口]", response.text)
print("返回字段解析错误!") print("返回字段解析错误!")
video_tasks = [] video_tasks = []
for index, iteminfo in enumerate(resinfo): for index, iteminfo in enumerate(resinfo):

View File

@ -31,6 +31,11 @@ SIGN = "10099426b05c7119e9c4dbd6a7a0aa4e"
db = DB.DBVidcon() db = DB.DBVidcon()
def fetch_proxies2(region_code, n):
return [("http://" + region_code.lower() + "-pr.thordata.net:25000") * n]
def fetch_proxies(region_code, n): def fetch_proxies(region_code, n):
""" """
从第三方一次性请求 n 条代理返回格式化列表 从第三方一次性请求 n 条代理返回格式化列表
@ -78,7 +83,7 @@ def refill_queue(r: redis.Redis, region_name: str, region_code: str,
to_fetch = batch - length to_fetch = batch - length
print(f"[{time.strftime('%H:%M:%S')}] {key} 长度 {length} < {low},一次性拉取 {to_fetch} 条…") print(f"[{time.strftime('%H:%M:%S')}] {key} 长度 {length} < {low},一次性拉取 {to_fetch} 条…")
proxies = fetch_proxies(region_code, to_fetch) proxies = fetch_proxies2(region_code, to_fetch)
if proxies: if proxies:
r.rpush(key, *proxies) r.rpush(key, *proxies)
print(f"[{time.strftime('%H:%M:%S')}] 已入队 {len(proxies)} 条 → 新长度 {r.llen(key)}") print(f"[{time.strftime('%H:%M:%S')}] 已入队 {len(proxies)} 条 → 新长度 {r.llen(key)}")