feat: bilibili video link parser support specific episode selection (#892)
This commit is contained in:
parent
59f406de6f
commit
6efad96133
|
|
@ -16,12 +16,15 @@ const getTimeValueInSeconds = (timeValue: string) => {
|
|||
}
|
||||
|
||||
const getBilibiliIFrameSrc = (url: URL) => {
|
||||
const match = url.pathname.match(/\/video\/([A-Za-z0-9]+)\//)
|
||||
const match = url.pathname.match(/\/video\/([A-Za-z0-9]+)\/?/)
|
||||
if (!match || match.length < 1) return
|
||||
const bvid = match[1]
|
||||
|
||||
const page = url.searchParams.get('p')
|
||||
const pageParam = (page) ? `&page=${page}` : ''
|
||||
|
||||
const embedUrl = new URL(
|
||||
`https://player.bilibili.com/player.html?bvid=${bvid}&autoplay=false`,
|
||||
`https://player.bilibili.com/player.html?bvid=${bvid}&autoplay=false` + pageParam,
|
||||
)
|
||||
|
||||
return embedUrl.toString()
|
||||
|
|
|
|||
Loading…
Reference in New Issue