增加另一个登录接口-登录错误

This commit is contained in:
yml2213
2026-06-26 17:43:00 +08:00
parent d7d7c0cbb0
commit 0faaa2c302
2 changed files with 33 additions and 19 deletions
+6 -1
View File
@@ -543,7 +543,12 @@ class DouyuLogin:
remote_code = self.api.extract_remote_code(payload) remote_code = self.api.extract_remote_code(payload)
if not remote_code: if not remote_code:
raise ValueError("获取remote_code失败") # 提取可能的风控提示
data = payload.get('data', {})
security_quiz = data.get('securityQuiz', '')
msg = payload.get('msg', '')
detail = security_quiz or msg or '未知原因'
raise ValueError(f"获取remote_code失败: {detail}")
logger.info(f"获取remote_code成功: {remote_code[:20]}...") logger.info(f"获取remote_code成功: {remote_code[:20]}...")
+27 -18
View File
@@ -10,13 +10,11 @@ from .login_api import LoginAPIStrategy
class IframeLoginAPI(LoginAPIStrategy): class IframeLoginAPI(LoginAPIStrategy):
"""iframe 版接口策略 """iframe 版接口策略
使用旧版 iframe 接口,参数嵌套结构,用户名 RC4 加密后 URL 编码。 混合模式(与 e 语言一致):
第一次登录使用 wgapi 接口获取极验参数,第二次登录使用 iframe 接口。 - 登录使用 wgapi 接口
- 邮箱验证:使用 iframe 接口
""" """
# e 语言中硬编码的 did 值
DEFAULT_DID = "6ab33184203a7d50d5f9a8fa00021701"
@property @property
def name(self) -> str: def name(self) -> str:
return "iframe" return "iframe"
@@ -28,15 +26,17 @@ class IframeLoginAPI(LoginAPIStrategy):
@property @property
def login_url(self) -> str: def login_url(self) -> str:
"""第二次登录用 iframe 接口""" """第二次登录用 wgapi 接口(与 e 语言一致)"""
return "https://passport.douyu.com/iframe/loginNew" return "https://passport.douyu.com/wgapi/member/passport/login"
@property @property
def send_email_url(self) -> str: def send_email_url(self) -> str:
"""发送邮箱验证用 iframe 接口"""
return "https://passport.douyu.com/iframe/sendEmail" return "https://passport.douyu.com/iframe/sendEmail"
@property @property
def verify_url(self) -> str: def verify_url(self) -> str:
"""提交验证码用 iframe 接口"""
return "https://passport.douyu.com/iframe/remoteLogin" return "https://passport.douyu.com/iframe/remoteLogin"
def encrypt_username(self, username: str) -> str: def encrypt_username(self, username: str) -> str:
@@ -78,28 +78,37 @@ class IframeLoginAPI(LoginAPIStrategy):
) -> dict: ) -> dict:
"""构建第二次登录参数(带极验验证) """构建第二次登录参数(带极验验证)
使用 iframe 接口的嵌套参数结构 登录使用 wgapi 接口,参数格式与 wgapi 策略一致
注意:iframe 接口使用 username 参数(直接用户名URL编码),而非 nicknameOrPhoneEncrypt。
""" """
# seccode 格式: validate|jordan # seccode 格式: validate|jordanrequests 会自动 URL 编码)
seccode_value = validate + '%7Cjordan' seccode_value = validate + '|jordan'
# 使用 base64 编码(wgapi 接口要求),而不是 URL 编码
encrypted_username = encrypt_nickname_or_phone(username)
return { return {
'username': username, # iframe 接口用 username,直接用户名 'type': '1',
'nicknameOrPhoneEncrypt': encrypted_username,
'password': encrypt_password(password), 'password': encrypt_password(password),
'room_id': '0', 'room_id': '0',
'code_verify_data[code_type]': '1', 'code_type': '1',
'code_verify_data[code_token]': code_token, 'code_token': code_token,
'code_verify_data[code_data][geetest_challenge]': challenge, 'gt_version': 'v3',
'code_verify_data[code_data][geetest_validate]': validate, 'geetest_challenge': challenge,
'code_verify_data[code_data][geetest_seccode]': seccode_value, 'geetest_validate': validate,
'code_verify_data[code_data][gt_version]': 'v3', 'geetest_seccode': seccode_value,
'code_data[geetest_challenge]': challenge,
'code_data[geetest_validate]': validate,
'code_data[geetest_seccode]': seccode_value,
'code_data[gt_version]': 'v3',
'code_data[code]': '',
'redirect_url': referer, 'redirect_url': referer,
't': str(int(time.time() * 1000)), 't': str(int(time.time() * 1000)),
'client_id': '1', 'client_id': '1',
'did': '', 'did': '',
'lang': '', 'lang': '',
'isMultiAccount': '0', 'isMultiAccount': '0',
'biz_type': '1',
} }
def build_send_email_data(self, code: str) -> dict: def build_send_email_data(self, code: str) -> dict: