I've searched and searched and there is practically nothing on this here or anywhere else, am I missing the obvious?

p.s
there's the following but as far as I can tell it's a solution for D6:
http://drupal.org/node/177207

Comments

jjclint’s picture

I did some digging around and it seems that there should be a pattern add on to the following code in MediaInternetYouTubeHandler.inc - so it'll normalize a playlist pattern such as: http://www.youtube.com/watchlist=PL7DEACAA1C5EB3336&v=PZgHXAek0No&featur...

or

http://www.youtube.com/view_play_list?p=PL7DEACAA1C5EB3336&v=PZgHXAek0No

/**
 * Implementation of MediaInternetBaseHandler.
 *
 * @see hook_media_internet_providers().
 */
class MediaInternetYouTubeHandler extends MediaInternetBaseHandler {
  public function parse($embedCode) {
    $patterns = array(
      '@youtube\.com/watch[#\?]v=([^"\& ]+)@i',
      '@youtube\.com/embed/([^"\&\? ]+)@i',
      '@youtube\.com/v/([^"\&\? ]+)@i',
      '@youtube\.com/\?v=([^"\& ]+)@i',
      '@youtu.be/([^"\&\? ]+)@i',
	
    );
    foreach ($patterns as $pattern) {
      preg_match($pattern, $embedCode, $matches);
      if (isset($matches[1])) {
        return file_stream_wrapper_uri_normalize('youtube://v/' . $matches[1]);
      }
    }
  }

Am I correct?

nikkubhai’s picture

Any update ? Youtube playlist has simple format like http://www.youtube.com/playlist?list=PL6B08BAA57B5C7810

jjclint’s picture

@nikkubah I've tried several things so far I only had luck with the oEmbed module, it's very strange that you can't embed playlists using the media: youtube module and there is almost no discussion about it in the issues section

traviscarden’s picture

RobW’s picture

Category: support » feature

This would be a great feature. I might be able to do some work on it next month, but until then: Patches welcome.

RobW’s picture

Version: 7.x-1.x-dev » 7.x-2.x-dev
weirdovideo’s picture

Anyone?
.........
Anyone?
..........

awolfey’s picture

Status: Active » Needs work
StatusFileSize
new7.21 KB

Here's a patch. There is some duplicated code, and some parts could be a little tighter, but it works and could use some additional eyes in the meantime.

It will handle links like:

Also, it looks like this module makes a ton of http requests to youtube. Many of those could be cached statically I think.

radiobuzzer’s picture

Do you need it to be tested or we should wait for an improved patch?

awolfey’s picture

Please test if you need it. I'm using it in production with no problems. I marked it needs work because I wanted to smooth out some things, which I have scheduled for today.

awolfey’s picture

Component: Documentation » Code
Status: Needs work » Needs review
StatusFileSize
new7.19 KB

Here's an updated patch against the current dev.

skolesnyk’s picture

I confirm the latest patch as working! Huge thanks!

skolesnyk’s picture

Issue summary: View changes

added missing link

johnhanley’s picture

I'm surprised playlist support (i.e. this patch) wasn't included in the latest RC. My client is unable to upgrade from the dev version without it.

johnhanley’s picture

I don't want to disparage the effort here, but unfortunately the playlist patch introduces a lot of adverse problems.

The URI is save incorrectly resulting in mangled URL when outputted with file_create_url():

http://youtube.com/playlist?list=PL_1TzcAmZQmjfDe-A1t6r3WJIUkA6hAxr

instead of

http://www.youtube.com/watch?v=Jx4ATI2Ito8&list=PL_1TzcAmZQmjfDe-A1t6r3W...

In addition the corresponding preview image is saved using the playlist code instead of the video code. Example:

PL_1TzcAmZQmjfDe-A1t6r3WJIUkA6hAxr.jpg

instead of

Jx4ATI2Ito8.jpg

Brian E. Conklin’s picture

Issue summary: View changes

Any updates on incorporating this into the module? It would be very useful.

shandman’s picture

Also interested in a commit.

zerolab’s picture

Attaching a new patch against latest dev, based on #11.

The patch:
1. Handles embedding videos from a playlist, with support for playing the next video automatically. e.g. https://youtu.be/_WcJfxZEZaY?list=PLjgO-QqeHQ3vE4bC3iz-0eeiH3lZo3K-Z
2. Handles playlists as above, and should handle thumbnails correctly.

Feedback is most welcome.

Cheers,
Dan

mrprasa’s picture

Will this be a feature of the next release? I am currently using 7.x-3.0 and am wondering if I should try the dev version with the patch for playlists (comment #17) or wait until the next recommended version.

zerolab’s picture

Another version that allows a graceful fallback a la #2498493: No exception handling when error from YouTube oEmbed.

ksenzee’s picture

Status: Needs review » Needs work

Patch no longer applies after #2475883: Original thumbnail path generation problem went in. Will see about rerolling it.

ksenzee’s picture

Version: 7.x-2.x-dev » 7.x-3.x-dev
Status: Needs work » Needs review
StatusFileSize
new7.39 KB

Here's a reroll that applies to 3.x. It seems to work but could use review.

justmagicmaria’s picture

Verified that this worked for me. It inserted the thumbnail from the first video and it played them one after another when played. Very nice!

heathdutton’s picture

#21 seems to work. Been 8 months, can we get it comitted?

steinmb’s picture

It would be good to have tests for this format also.

capysara’s picture

I wasn't able to apply the patch (using the dry run). I haven't applied very many patches. Am I missing something?

I ran: patch -p1 --dry-run < media_youtube-playlist-support-1405528-21.patch

patching file includes/MediaInternetYouTubeHandler.inc
patching file includes/MediaYouTubeStreamWrapper.inc
Hunk #2 succeeded at 50 with fuzz 2.
Hunk #3 FAILED at 66.
1 out of 3 hunks FAILED -- saving rejects to file includes/MediaYouTubeStreamWrapper.inc.rej
patching file themes/media_youtube.theme.inc

I was trying to apply it to 3.x instead of the dev. Testing now.

Update: #21 works great for me! Thanks!

ameymudras’s picture

StatusFileSize
new7.62 KB

The patch didnt work for me as the protocol was not set while adding playlist. Have included a fix for the same.

joseph.olstad’s picture

@steinmb , would you be able to request maintainer role for this module and take up the slack here?
or someone else? :)
seems like media_youtube could use a bit of TLC

steinmb’s picture

@joseph - Let me have a look/ponder, but your right. It is in dire need of TLC.

joseph.olstad’s picture

Status: Needs review » Fixed
joseph.olstad’s picture

in 7.x-3.x dev branch

brandonpost’s picture

After I updated this module to version 3.1, my site (which is served entirely over https) started throwing mixed content warnings on pages that have Youtube videos embedded. I tracked the problem down to the patch in #26 of this issue. In that patch, a change is made to the media_youtube_preprocess_media_youtube_video function that sets $protocol to http: whenever the nocookie option is not set.

I ended up creating a process function in a custom module that removes the http: from the url in order to eliminate the mixed content warnings.

I would re-roll another patch to correct this, but I don't have time at the moment to figure out the problem #26 was trying to solve by adding the line that sets $protocol to http:. I just wanted to put this out there in case anyone else is running into the same problem of mixed content warnings.

joseph.olstad’s picture

@brandonpost , thanks for the feedback. I've openned a new issue for this. If you could review the patch I made, that'd be great, or if you have a better patch, let me know. As for your process function in your custom module, could you show us the code for that? Just paste it in so we can see which hook you used and what the code is.

Here is the related issue, post your responses here:
#2883877: http forced when nocookie is disabled

Status: Fixed » Closed (fixed)

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