Skip to content

Commit

Permalink
Merge pull request #149 from Yuiffy/upstream/main-upstream-bilibili-s…
Browse files Browse the repository at this point in the history
…ubtitle-api-pages-fix

fix: b站字幕获取,对没有pageNumber但是有pages的合集视频增加兼容
  • Loading branch information
JimmyLv authored Jul 13, 2023
2 parents 658e7f9 + 239d875 commit e491477
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 e491477

Please sign in to comment.