Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add support for embedding playlists #296

Open
wants to merge 7 commits into
base: main
Choose a base branch
from
Open

Conversation

gfscott
Copy link
Owner

@gfscott gfscott commented Oct 21, 2024

Closes #149

At very long last, this PR adds support for YouTube playlists. There are two use cases:

  1. Embed a playlist that starts playing from the beginning. These URLs only include a Playlist ID and therefore don't work in Lite mode:
    https://www.youtube.com/playlist?list=PLFtSvldL7Mh4ismj4BgH33pBR9hbtBkxz
  2. Embed a single video as part of a larger playlist. These URLs include both a Video and a Playlist ID, and often the video's index, or position within the playlist. In Lite mode, these URLs will render the single video, instead of the playlist.
    https://www.youtube.com/watch?v=C04JZsoqs1A&list=PLFtSvldL7Mh4ismj4BgH33pBR9hbtBkxz&index=4

Known limitations in Lite mode

lite-youtube-embed doesn't recognize playlist IDs so if there's no video ID, the embed won't display anything in Lite mode. But if it finds a video ID (such as in the second example above) it will embed just that video.

@gfscott gfscott self-assigned this Oct 21, 2024
Copy link

changeset-bot bot commented Oct 21, 2024

🦋 Changeset detected

Latest commit: d8dbccb

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 3 packages
Name Type
eleventy-plugin-youtube-embed Minor
eleventy-plugin-embed-everything-demo Patch
eleventy-plugin-embed-everything Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@gfscott gfscott requested a review from Copilot December 3, 2024 16:36
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot reviewed 5 out of 8 changed files in this pull request and generated 1 suggestion.

Files not reviewed (3)
  • packages/youtube/test/embed.default.test.js: Evaluated as low risk
  • packages/youtube/test/_urls.mjs: Evaluated as low risk
  • demo/src/youtube.md: Evaluated as low risk
Comments skipped due to low confidence (2)

packages/youtube/lib/embed.js:87

  • The use of 'id ?? playlist' should be reviewed to ensure it doesn't introduce unintended behavior when both are present or missing.
return `https://i.ytimg.com/${fileTypePath}/${id ?? playlist}/${fileName}`;

packages/youtube/lib/embed.js:181

  • [nitpick] The error message should be reviewed for consistency with other error messages in the codebase.
console.info("Couldn’t fetch video title. Falling back to default...\n", error);

);
});
test(`Build embed lite mode, 1+ index, responsive true`, t => {
t.is(embed(extract(testString), override({lite: { responive: true }}), 1),
Copy link
Preview

Copilot AI Dec 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Typo in the property name 'responive' should be 'responsive'.

Suggested change
t.is(embed(extract(testString), override({lite: { responive: true }}), 1),
t.is(embed(extract(testString), override({lite: { responsive: true }}), 1),

Copilot is powered by AI, so mistakes are possible. Review output carefully before use.

Positive Feedback
Negative Feedback

Provide additional feedback

Please help us improve GitHub Copilot by sharing more details about this comment.

Please select one or more of the options
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Support embedding playlists
1 participant