Bluesky app fork with some witchin' additions 💫
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Set start time on YouTube embeds (#2565)

* fix: set start time on yt embeds

* fix: re-encode to be on the safe side

* chore: fix embed tests

authored by

Mary and committed by
GitHub
4bd95b5e 0dfe740d

+11 -9
+7 -7
__tests__/lib/string.test.ts
··· 463 463 type: 'youtube_video', 464 464 source: 'youtube', 465 465 playerUri: 466 - 'https://www.youtube.com/embed/videoId?autoplay=1&playsinline=1', 466 + 'https://www.youtube.com/embed/videoId?autoplay=1&playsinline=1&start=0', 467 467 }, 468 468 { 469 469 type: 'youtube_video', 470 470 source: 'youtube', 471 471 playerUri: 472 - 'https://www.youtube.com/embed/videoId?autoplay=1&playsinline=1', 472 + 'https://www.youtube.com/embed/videoId?autoplay=1&playsinline=1&start=0', 473 473 }, 474 474 { 475 475 type: 'youtube_video', 476 476 source: 'youtube', 477 477 playerUri: 478 - 'https://www.youtube.com/embed/videoId?autoplay=1&playsinline=1', 478 + 'https://www.youtube.com/embed/videoId?autoplay=1&playsinline=1&start=0', 479 479 }, 480 480 { 481 481 type: 'youtube_video', 482 482 source: 'youtube', 483 483 playerUri: 484 - 'https://www.youtube.com/embed/videoId?autoplay=1&playsinline=1', 484 + 'https://www.youtube.com/embed/videoId?autoplay=1&playsinline=1&start=0', 485 485 }, 486 486 { 487 487 type: 'youtube_video', 488 488 source: 'youtube', 489 489 playerUri: 490 - 'https://www.youtube.com/embed/videoId?autoplay=1&playsinline=1', 490 + 'https://www.youtube.com/embed/videoId?autoplay=1&playsinline=1&start=0', 491 491 }, 492 492 { 493 493 type: 'youtube_short', 494 494 source: 'youtubeShorts', 495 495 hideDetails: true, 496 496 playerUri: 497 - 'https://www.youtube.com/embed/videoId?autoplay=1&playsinline=1', 497 + 'https://www.youtube.com/embed/videoId?autoplay=1&playsinline=1&start=0', 498 498 }, 499 499 { 500 500 type: 'youtube_video', 501 501 source: 'youtube', 502 502 playerUri: 503 - 'https://www.youtube.com/embed/videoId?autoplay=1&playsinline=1', 503 + 'https://www.youtube.com/embed/videoId?autoplay=1&playsinline=1&start=0', 504 504 }, 505 505 506 506 undefined,
+4 -2
src/lib/strings/embed-player.ts
··· 68 68 // youtube 69 69 if (urlp.hostname === 'youtu.be') { 70 70 const videoId = urlp.pathname.split('/')[1] 71 + const seek = encodeURIComponent(urlp.searchParams.get('t') ?? 0) 71 72 if (videoId) { 72 73 return { 73 74 type: 'youtube_video', 74 75 source: 'youtube', 75 - playerUri: `https://www.youtube.com/embed/${videoId}?autoplay=1&playsinline=1`, 76 + playerUri: `https://www.youtube.com/embed/${videoId}?autoplay=1&playsinline=1&start=${seek}`, 76 77 } 77 78 } 78 79 } ··· 84 85 const [_, page, shortVideoId] = urlp.pathname.split('/') 85 86 const videoId = 86 87 page === 'shorts' ? shortVideoId : (urlp.searchParams.get('v') as string) 88 + const seek = encodeURIComponent(urlp.searchParams.get('t') ?? 0) 87 89 88 90 if (videoId) { 89 91 return { 90 92 type: page === 'shorts' ? 'youtube_short' : 'youtube_video', 91 93 source: page === 'shorts' ? 'youtubeShorts' : 'youtube', 92 94 hideDetails: page === 'shorts' ? true : undefined, 93 - playerUri: `https://www.youtube.com/embed/${videoId}?autoplay=1&playsinline=1`, 95 + playerUri: `https://www.youtube.com/embed/${videoId}?autoplay=1&playsinline=1&start=${seek}`, 94 96 } 95 97 } 96 98 }