Skip to content

Commit

Permalink
Merge pull request #83 from alley-rs/dev
Browse files Browse the repository at this point in the history
fix(douyu): 获取重播状态时可能得到错误响应
  • Loading branch information
thep0y authored Sep 6, 2024
2 parents fdf4c88 + b990541 commit a322c1d
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 8 deletions.
14 changes: 14 additions & 0 deletions src-tauri/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

17 changes: 9 additions & 8 deletions src/parser/douyu/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,15 +55,15 @@ class DouyuParser extends LiveStreamParser {
}

async parse(): Promise<ParsedResult | typeof NOT_LIVE | Error> {
const isReplay = await this.isReplay();
if (isReplay) {
return IS_REPLAY;
}

try {
const params = await this.getRequestParams();
if (params instanceof Error) return params;

const isReplay = await this.isReplay();
if (isReplay) {
return IS_REPLAY;
}

const info = await this.getRoomInfo(params);
return this.parseRoomInfo(info);
} catch (error) {
Expand Down Expand Up @@ -230,9 +230,10 @@ class DouyuParser extends LiveStreamParser {
}

private async isReplay() {
const { body } = await get<{ room: { videoLoop: boolean } }>(
`https://www.douyu.com/betard/${this.roomID}`,
);
const { body } = await get<{
room: { videoLoop: boolean };
}>(`https://www.douyu.com/betard/${this.finalRoomID}`);

return body.room.videoLoop;
}

Expand Down

0 comments on commit a322c1d

Please sign in to comment.