Bluesky app fork with some witchin' additions 💫

Add `/live/` to supported YouTube embed URLs (#4932)

authored by hailey.at and committed by

GitHub 26d3777e 630ebf52

+18 -5
+8
__tests__/lib/string.test.ts
··· 340 340 'https://youtube.com/watch?v=videoId', 341 341 'https://youtube.com/watch?v=videoId&feature=share', 342 342 'https://youtube.com/shorts/videoId', 343 + 'https://youtube.com/live/videoId', 343 344 'https://m.youtube.com/watch?v=videoId', 344 345 'https://music.youtube.com/watch?v=videoId', 345 346 346 347 'https://youtube.com/shorts/', 347 348 'https://youtube.com/', 348 349 'https://youtube.com/random', 350 + 'https://youtube.com/live/', 349 351 350 352 'https://twitch.tv/channelName', 351 353 'https://www.twitch.tv/channelName', ··· 475 477 source: 'youtube', 476 478 playerUri: 'https://bsky.app/iframe/youtube.html?videoId=videoId&start=0', 477 479 }, 480 + { 481 + type: 'youtube_video', 482 + source: 'youtube', 483 + playerUri: 'https://bsky.app/iframe/youtube.html?videoId=videoId&start=0', 484 + }, 478 485 486 + undefined, 479 487 undefined, 480 488 undefined, 481 489 undefined,
+10 -5
src/lib/strings/embed-player.ts
··· 103 103 urlp.hostname === 'm.youtube.com' || 104 104 urlp.hostname === 'music.youtube.com' 105 105 ) { 106 - const [_, page, shortVideoId] = urlp.pathname.split('/') 106 + const [_, page, shortOrLiveVideoId] = urlp.pathname.split('/') 107 + 108 + const isShorts = page === 'shorts' 109 + const isLive = page === 'live' 107 110 const videoId = 108 - page === 'shorts' ? shortVideoId : (urlp.searchParams.get('v') as string) 111 + isShorts || isLive 112 + ? shortOrLiveVideoId 113 + : (urlp.searchParams.get('v') as string) 109 114 const seek = encodeURIComponent(urlp.searchParams.get('t') ?? 0) 110 115 111 116 if (videoId) { 112 117 return { 113 - type: page === 'shorts' ? 'youtube_short' : 'youtube_video', 114 - source: page === 'shorts' ? 'youtubeShorts' : 'youtube', 115 - hideDetails: page === 'shorts' ? true : undefined, 118 + type: isShorts ? 'youtube_short' : 'youtube_video', 119 + source: isShorts ? 'youtubeShorts' : 'youtube', 120 + hideDetails: isShorts ? true : undefined, 116 121 playerUri: `${IFRAME_HOST}/iframe/youtube.html?videoId=${videoId}&start=${seek}`, 117 122 } 118 123 }