diff --git a/src/index.scss b/src/index.scss index 34b00ff..87a3159 100644 --- a/src/index.scss +++ b/src/index.scss @@ -23,6 +23,15 @@ --alley-color-mask: rgba(0, 0, 0, 0.5); + --alley-color-info-bg: rgb(41 44 104 / 30%); + --alley-color-info-border: #4045a3; + + --alley-color-success-bg: #092b00; + --alley-color-success-border: #237804; + + --alley-color-error-bg: #5c0011; + --alley-color-error-border: #820014; + .alley-input { --alley-input-addon-bg: rgba(255, 255, 255, 0.04); // --alley-input-active-border-color: #1668dc; diff --git a/src/parser/huya/index.ts b/src/parser/huya/index.ts index 05f8cf3..c2256d9 100644 --- a/src/parser/huya/index.ts +++ b/src/parser/huya/index.ts @@ -81,7 +81,14 @@ class Huya { }); const ptn = /stream: (\{.+"iFrameRate":\d+\})/; - const streamStr = ptn.exec(html)![1]; + + const streamStr = ptn.exec(html)?.[1]; + if (!streamStr) { + return Error( + `获取 streamStr 失败, 可能因为网页解码错误, 房间号: ${this.roomID}`, + ); + } + const stream = JSON.parse(streamStr); const roomID = stream.data[0].gameLiveInfo.profileRoom as string; info(log_prefix, `真实房间 id:${roomID}`); @@ -227,9 +234,11 @@ class Huya { async parse() { const roomID = await this.getFinalRoomID(); - const result = await this.getRoomProfile(roomID); + if (roomID instanceof Error) { + return roomID; + } - console.log(result); + const result = await this.getRoomProfile(roomID); return result; }