fix(douyu): 优先使用旧版角色绑定入口
This commit is contained in:
@@ -418,7 +418,13 @@ class DouyuActivityClient:
|
||||
return ctn
|
||||
|
||||
def get_bind_qr(self, act_alias: str) -> dict[str, Any]:
|
||||
"""按最新活动页链路生成腾讯游戏角色绑定二维码。"""
|
||||
"""生成腾讯游戏角色绑定二维码。
|
||||
|
||||
2026-11-22 新 HAR:活动页“切换”按钮会引导用户去斗鱼个人中心,个人中心
|
||||
普通入口携带完整游戏列表,二维码无法自动选中和平精英。``gameRoleBindUrl``
|
||||
仍是旧版直接角色绑定页,带 ``gameIdList=cjm``,优先使用;只有旧入口缺失
|
||||
时才回退到普通 ``url``。
|
||||
"""
|
||||
ctn = self.acf_ccn(refresh_subscribe=False)
|
||||
payload = self._request_json(
|
||||
"get",
|
||||
@@ -430,7 +436,7 @@ class DouyuActivityClient:
|
||||
},
|
||||
)
|
||||
data = payload.get("data") or {}
|
||||
url = data.get("url") or data.get("gameRoleBindUrl") or ""
|
||||
url = data.get("gameRoleBindUrl") or data.get("url") or ""
|
||||
if not url:
|
||||
raise DouyuActivityError(payload.get("msg") or "获取绑定二维码失败")
|
||||
return {
|
||||
|
||||
@@ -528,7 +528,8 @@ def test_qr_and_confirm_requests_follow_latest_har(monkeypatch):
|
||||
qr = client.get_bind_qr(ACT_ALIAS)
|
||||
confirmed = client.confirm_bind(ACT_ALIAS)
|
||||
|
||||
assert qr["url"] == "https://livelink.example/role"
|
||||
assert qr["url"] == "https://livelink.example/bind"
|
||||
assert qr["role_param_url"] == "https://livelink.example/role"
|
||||
assert qr["game_role_bind_url"] == "https://livelink.example/bind"
|
||||
assert confirmed["ctn"] == "ctn"
|
||||
assert calls[0]["method"] == "get"
|
||||
@@ -566,3 +567,25 @@ def test_confirm_bind_preserves_platform_cooldown_error_code(monkeypatch):
|
||||
|
||||
assert exc_info.value.code == -200001
|
||||
assert exc_info.value.payload == payload
|
||||
|
||||
|
||||
def test_get_bind_qr_falls_back_to_role_param_url(monkeypatch):
|
||||
client = DouyuActivityClient("acf_ccn=ctn")
|
||||
monkeypatch.setattr(
|
||||
client,
|
||||
"acf_ccn",
|
||||
lambda *, refresh_subscribe=True: "ctn",
|
||||
)
|
||||
monkeypatch.setattr(
|
||||
client,
|
||||
"_request_json",
|
||||
lambda *_args, **_kwargs: {
|
||||
"error": 0,
|
||||
"data": {"url": "https://livelink.example/role"},
|
||||
},
|
||||
)
|
||||
|
||||
qr = client.get_bind_qr(ACT_ALIAS)
|
||||
|
||||
assert qr["url"] == "https://livelink.example/role"
|
||||
assert qr["game_role_bind_url"] == ""
|
||||
|
||||
Reference in New Issue
Block a user