Skip to content

Commit

Permalink
fix: b站字幕获取,对没有pageNumber但是有pages的合集视频增加兼容
Browse files Browse the repository at this point in the history
  • Loading branch information
Yuiffy committed Jul 12, 2023
1 parent 658e7f9 commit 239d875
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/bilibili/fetchBilibiliSubtitleUrls.ts
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@ export const fetchBilibiliSubtitleUrls = async (
const json = await response.json()

// support multiple parts of video
if (pageNumber) {
if (pageNumber || json?.data?.pages?.length > 0) {
const { aid, pages } = json?.data || {}
const { cid } = find(pages, { page: Number(pageNumber) }) || {}
const { cid } = find(pages, { page: Number(pageNumber || 1) }) || {}

// https://api.bilibili.com/x/player/v2?aid=865462240&cid=1035524244
const pageUrl = `https://api.bilibili.com/x/player/v2?aid=${aid}&cid=${cid}`
Expand Down

0 comments on commit 239d875

Please sign in to comment.