|
|
@@ -369,7 +369,19 @@ class WeixinPublisher(BasePublisher):
|
|
|
if proxy and proxy.get("server"):
|
|
|
# 启用上传 bypass 时:仅对上传 CDN 直连,其余仍走代理
|
|
|
if WEIXIN_UPLOAD_BYPASS_PROXY:
|
|
|
- bypass = "findeross.weixin.qq.com,upload.weixin.qq.com,*.cos.qq.com,*.myqcloud.com,*.tencentcloudapi.com"
|
|
|
+ bypass = ",".join([
|
|
|
+ "findeross.weixin.qq.com",
|
|
|
+ "upload.weixin.qq.com",
|
|
|
+ "finder.video.qq.com",
|
|
|
+ "szextshort.weixin.qq.com",
|
|
|
+ "mp.weixin.qq.com",
|
|
|
+ "*.cos.qq.com",
|
|
|
+ "*.cos.ap-*.myqcloud.com",
|
|
|
+ "*.myqcloud.com",
|
|
|
+ "*.tencentcloudapi.com",
|
|
|
+ "*.video.qq.com",
|
|
|
+ "*.cdn-go.cn",
|
|
|
+ ])
|
|
|
proxy = dict(proxy)
|
|
|
proxy["bypass"] = bypass
|
|
|
print(
|
|
|
@@ -1225,6 +1237,42 @@ class WeixinPublisher(BasePublisher):
|
|
|
|
|
|
self.report_progress(30, "等待视频上传完成...")
|
|
|
|
|
|
+ # 监控网络请求,捕捉上传相关域名和状态
|
|
|
+ _upload_domains_seen = set()
|
|
|
+ def _on_request(req):
|
|
|
+ url = req.url
|
|
|
+ if any(kw in url for kw in ["upload", "cos.", "myqcloud", "finder", "video", "media"]):
|
|
|
+ from urllib.parse import urlparse
|
|
|
+ domain = urlparse(url).netloc
|
|
|
+ method = req.method
|
|
|
+ if domain not in _upload_domains_seen:
|
|
|
+ _upload_domains_seen.add(domain)
|
|
|
+ print(f"[{self.platform_name}] ⭐ 上传相关请求: {method} {domain} ({url[:120]})", flush=True)
|
|
|
+
|
|
|
+ def _on_response(resp):
|
|
|
+ url = resp.url
|
|
|
+ if any(kw in url for kw in ["upload", "cos.", "myqcloud", "finder", "video", "media"]):
|
|
|
+ from urllib.parse import urlparse
|
|
|
+ domain = urlparse(url).netloc
|
|
|
+ status = resp.status
|
|
|
+ if status >= 400 or status == 0:
|
|
|
+ print(f"[{self.platform_name}] ❌ 上传响应失败: {status} {domain} ({url[:120]})", flush=True)
|
|
|
+ else:
|
|
|
+ print(f"[{self.platform_name}] ✅ 上传响应: {status} {domain}", flush=True)
|
|
|
+
|
|
|
+ def _on_request_failed(req):
|
|
|
+ url = req.url
|
|
|
+ if any(kw in url for kw in ["upload", "cos.", "myqcloud", "finder", "video", "media"]):
|
|
|
+ from urllib.parse import urlparse
|
|
|
+ domain = urlparse(url).netloc
|
|
|
+ failure = req.failure
|
|
|
+ print(f"[{self.platform_name}] ❌ 上传请求失败: {domain} failure={failure} ({url[:120]})", flush=True)
|
|
|
+
|
|
|
+ self.page.on("request", _on_request)
|
|
|
+ self.page.on("response", _on_response)
|
|
|
+ self.page.on("requestfailed", _on_request_failed)
|
|
|
+ print(f"[{self.platform_name}] 已启用上传网络请求监控", flush=True)
|
|
|
+
|
|
|
# 代理模式下增加重试次数和总时长,应对「网络出错」等不稳定情况
|
|
|
using_proxy = isinstance(
|
|
|
getattr(self, "proxy_config", None), dict
|
|
|
@@ -1243,10 +1291,21 @@ class WeixinPublisher(BasePublisher):
|
|
|
try:
|
|
|
# 每 30 秒打印一次进度,避免“卡住”的错觉
|
|
|
if i > 0 and i % 10 == 0:
|
|
|
+ elapsed_s = i * 3
|
|
|
print(
|
|
|
- f"[{self.platform_name}] 仍在等待上传完成... ({i * 3}s)",
|
|
|
+ f"[{self.platform_name}] 仍在等待上传完成... ({elapsed_s}s)",
|
|
|
flush=True,
|
|
|
)
|
|
|
+ # 每 60 秒保存一次截图,方便排查上传卡住问题
|
|
|
+ if i % 20 == 0:
|
|
|
+ try:
|
|
|
+ ss_path = await self.save_screenshot_to_file(
|
|
|
+ filename_prefix=f"weixin_upload_waiting_{elapsed_s}s"
|
|
|
+ )
|
|
|
+ if ss_path:
|
|
|
+ print(f"[{self.platform_name}] 等待中截图已保存: {ss_path}", flush=True)
|
|
|
+ except Exception as ss_err:
|
|
|
+ print(f"[{self.platform_name}] 等待中截图失败: {ss_err}", flush=True)
|
|
|
|
|
|
# 尝试多种选择器定位“发表”按钮(页面结构可能变化)
|
|
|
publish_btn = None
|