Add /live/
to supported YouTube embed URLs (#4932)
This commit is contained in:
parent
630ebf523d
commit
26d3777ecc
2 changed files with 18 additions and 5 deletions
|
@ -103,16 +103,21 @@ export function parseEmbedPlayerFromUrl(
|
|||
urlp.hostname === 'm.youtube.com' ||
|
||||
urlp.hostname === 'music.youtube.com'
|
||||
) {
|
||||
const [_, page, shortVideoId] = urlp.pathname.split('/')
|
||||
const [_, page, shortOrLiveVideoId] = urlp.pathname.split('/')
|
||||
|
||||
const isShorts = page === 'shorts'
|
||||
const isLive = page === 'live'
|
||||
const videoId =
|
||||
page === 'shorts' ? shortVideoId : (urlp.searchParams.get('v') as string)
|
||||
isShorts || isLive
|
||||
? shortOrLiveVideoId
|
||||
: (urlp.searchParams.get('v') as string)
|
||||
const seek = encodeURIComponent(urlp.searchParams.get('t') ?? 0)
|
||||
|
||||
if (videoId) {
|
||||
return {
|
||||
type: page === 'shorts' ? 'youtube_short' : 'youtube_video',
|
||||
source: page === 'shorts' ? 'youtubeShorts' : 'youtube',
|
||||
hideDetails: page === 'shorts' ? true : undefined,
|
||||
type: isShorts ? 'youtube_short' : 'youtube_video',
|
||||
source: isShorts ? 'youtubeShorts' : 'youtube',
|
||||
hideDetails: isShorts ? true : undefined,
|
||||
playerUri: `${IFRAME_HOST}/iframe/youtube.html?videoId=${videoId}&start=${seek}`,
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue