Problem/Motivation

Providing a Youtube playlist URL (for example https://www.youtube.com/playlist?list=PLbpi6ZahtOH6PVhBTPhS6iDUkFGJBeH9g) does not work. The error "Could not find a video provider to handle the given URL" is thrown.

The source of the problem is the regex in \Drupal\video_embed_field\Plugin\video_embed_field\Provider\YouTubePlaylist::getUrlComponent. The regex searches for "/watch?" but not "/playlist?". Both are valid. The difference is that "/watch?" will autoplay.

Additionally but unrelated, there are a couple incorrect implementations of \Drupal\video_embed_field\ProviderPluginInterface::renderEmbedCode that are missing arguments which throw errors such as: "Fatal error: Declaration of Drupal\video_embed_echo360\Plugin\video_embed_field\Provider\Echo360::renderEmbedCode($width, $height, $autoplay) must be compatible with Drupal\video_embed_field\ProviderPluginInterface::renderEmbedCode($width, $height, $autoplay, $title_format = null, $use_title_fallback = true) in /app/docroot/modules/custom/video_embed_echo360/src/Plugin/video_embed_field/Provider/Echo360.php on line 20".
These are fatal errors that cause the page to not load.
Ignore this. Did not realize there is a custom module built on top of video_embed_field.

Steps to reproduce

Enter "https://www.youtube.com/playlist?list=PLbpi6ZahtOH6PVhBTPhS6iDUkFGJBeH9g" in a video embed field.

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

maskedjellybean created an issue. See original summary.

maskedjellybean’s picture

Issue summary: View changes

maskedjellybean’s picture

Created a merge request with correct regex. Both "/watch?" and "/playlist?" should work.

I'm not sure that we actually need this part of the regex: (?=.*v=(?<video_id>[0-9A-Za-z_-]*)), so I made it optional. It seems like this would only be relevant for a URL to a single video.

mably’s picture

Here is what Claude gives me:

Playlist URLs:

https://youtube.com/playlist?list=PLAYLIST_ID
https://youtube.com/watch?v=VIDEO_ID&list=PLAYLIST_ID (specific video in playlist)
https://www.youtube.com/watch?v=VIDEO_ID&list=PLAYLIST_ID&index=3 (specific position in playlist)

maskedjellybean’s picture

Ok, updated the MR.

We can support index I think. Might as well add support for all the currently unsupported URL patterns in this issue. Also we were regexing for v (VIDEO_ID) and doing nothing with it, so I tried to address that.

From what I've seen, URLs in those 3 patterns now work, however I see no change in the first video played no matter what. My assumption is that in \Drupal\video_embed_field\Plugin\video_embed_field\Provider\YouTubePlaylist::renderEmbedCode we should set $embed_code['#query']['v'] and $embed_code['#query']['index']. At the very least doing this does not cause any issues loading the playlist.

mably’s picture

Status: Active » Needs work

Thanks for the update but sadly some unit tests seem to be failing now.

mably’s picture

Status: Needs work » Fixed

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.

calbasi’s picture

It seems there are other regexp that fire an error, for example:

https://www.youtube.com/watch?v=EuY-8fRKOuA&list=RDEuY-8fRKOuA&start_rad...

The merged merge request doesn't address the issue.