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

Merged
merged 6 commits into from
Feb 5, 2025
Merged

Add support for embedding playlists #296

merged 6 commits into from
Feb 5, 2025

Conversation

gfscott
Copy link
Owner

@gfscott gfscott commented Oct 21, 2024

Closes #149

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

Standalone playlists

These are YouTube playlist URLs that don't specify an individual video ID:
https://www.youtube.com/playlist?list=PLFtSvldL7Mh4ismj4BgH33pBR9hbtBkxz

For standalone playlists, the plugin embeds the player and starts playing from the first video in the list.

⚠️ In lite mode, the plugin simply returns the original URL. Playlists aren't supported by the lite-youtube-embed package.

Videos with associated playlists

These are YouTube URLs that include both a video ID and a playlist ID:
https://www.youtube.com/watch?v=C04JZsoqs1A&list=PLFtSvldL7Mh4ismj4BgH33pBR9hbtBkxz

For this type of URL, the plugin embeds the player and starts playing from the specified video, wherever it is in the playlist numbering.

ℹ️ In lite mode, only the individual video will be embedded. Playlists aren't supported by the lite-youtube-embed package.

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

changeset-bot bot commented Oct 21, 2024

🦋 Changeset detected

Latest commit: fcde9ca

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
Contributor

@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);

packages/youtube/test/embed.lite.playlist.test.js Outdated Show resolved Hide resolved
gfscott and others added 6 commits February 4, 2025 20:03
More refactoring and cleanup
Cleanup, a little more refactoring

Fix typo

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@gfscott gfscott merged commit 41d73cc into main Feb 5, 2025
12 checks passed
@gfscott gfscott deleted the youtube-playlists branch February 5, 2025 01:08
@github-actions github-actions bot mentioned this pull request Feb 4, 2025
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