From 1ece98674a96c5fccf1f16bc97d8d2b606dc6635 Mon Sep 17 00:00:00 2001 From: Ryan Wang Date: Thu, 29 Aug 2024 22:59:23 +0800 Subject: [PATCH] =?UTF-8?q?fix(douyu):=20=E4=B8=AA=E5=88=AB=E6=88=BF?= =?UTF-8?q?=E9=97=B4=E5=9C=A8=E4=B8=AA=E5=88=AB=E6=97=B6=E9=97=B4=E6=AE=B5?= =?UTF-8?q?=E5=8F=AF=E8=83=BD=E8=A7=A3=E6=9E=90=E5=A4=B1=E8=B4=A5,=20?= =?UTF-8?q?=E5=BC=95=E8=B5=B7=E9=A1=B5=E9=9D=A2=E7=8A=B6=E6=80=81=E4=B8=8D?= =?UTF-8?q?=E6=9B=B4=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 此问题未发现原因, 待进一步研究修复 --- src/parser/douyu/index.ts | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/parser/douyu/index.ts b/src/parser/douyu/index.ts index 1c4591a..aab2b34 100644 --- a/src/parser/douyu/index.ts +++ b/src/parser/douyu/index.ts @@ -132,6 +132,12 @@ class Douyu { signFunc = eval(ub98484234 + matchResult[0] + ub98484234Call) as string; } } + + // FIXME: signFunc 为空很奇怪, 需要进一步修复 + if (!signFunc) { + return Error(`此房间未获取到 signFunc, 解析失败: ${this.roomID}`); + } + const v = signFunc.match(/\w{12}/)!; const md5 = await computeMD5(`${this.finalRoomID}${did}${ts}${v[0]}`); @@ -168,7 +174,12 @@ class Douyu { } } - this.signFunc = await this.matchSignFunc(html); + const signFunc = await this.matchSignFunc(html); + if (signFunc instanceof Error) { + return signFunc; + } + + this.signFunc = signFunc; const anchor = html.match(/
/); this.anchor = anchor![1];