Skip to content

Commit

Permalink
对于没有 playinfo 的页面采用降级方案
Browse files Browse the repository at this point in the history
  • Loading branch information
tcdw committed Dec 3, 2024
1 parent 480b178 commit 8774f66
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions api/external/direct.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,10 +68,19 @@ export const getVideo = async ({
/window\.__INITIAL_STATE__=(\{.+});\(function\(\){/,
response,
);
const playInfo: WebPlayInfo = extractJSON(
/window\.__playinfo__=(\{.+})<\/script><script>window.__INITIAL_STATE__=/,
response,
);
let playInfo: WebPlayInfo;
try {
playInfo = extractJSON(/window\.__playinfo__=(\{.+})<\/script><script>window.__INITIAL_STATE__=/, response);
} catch (e) {
log.debug(`匹配关键词失败:${e}`);
log.debug("正在采用降级方案……");
playInfo = await getVideoUrlFestival(
finalUrl,
initialState.videoData.aid,
initialState.videoData.bvid,
initialState.videoData.pages.find(e => e.page === Number(episode))?.cid ?? 0,
);
}
return { type: "regular", initialState, playInfo };
}
};

0 comments on commit 8774f66

Please sign in to comment.