Hello

This was working for me a few days ago but now the first video that you get is always a Youtube error video:

https://www.youtube.com/watch?v=UKY3scPIMd8

It tells you to go to:

http://youtube.com/devicesupport where they explain that API 2 will no longer be used and to move on to API 3 and that almost all functionality for API 2 will be disabled as of April 20 2015.

This is a great module, very simple and very useful.

Will you be upgrading to API 3?

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

flamez-b’s picture

Hi,
The Youtube API 2 has totally stopped working. The module is now useless.
Anybody found solution to make it work with the API 3?
Or we just have to move to another module?

jkealy’s picture

Yes, we can confirm this is not working. Anyone considering else working on a fix? We might boil something up...

ckng’s picture

Not using the module myself at the moment, feel free to make a patch.

widukind’s picture

a few things to consider when re-implementing this module to work with youtube api v3:

1. it may make sense to leverage the API Client libs that Google provides: https://developers.google.com/api-client-library/php/. However, they are currently not whitelisted for inclusion with modules hosted on d.o https://www.drupal.org/project/drupalorg_whitelist. So this may have to be green-lit first.

2. Another option would be to cobble something together from various existing building blocks (contrib modules). I'm looking at https://www.drupal.org/project/oauth2_client handling authn and a JSON parser for processing the payload (PHP's JSON extension should do here).

sothish’s picture

I have a patch for this, please find it attached. below the list of items
- Upgrading to Youtube API V3
- Adding admin form
- Handling uninstall

sothish’s picture

Status: Active » Needs review
leolandotan’s picture

Assigned: Unassigned » leolandotan
Status: Needs review » Needs work

I have tested the provided patch above and can see that it is indeed able to connect using Youtube's V3 API but I made a little fix for it specifically in this module's admin configuration form. I'll try to post my patch also.

  1. +++ b/youtube_pull.admin.inc
    @@ -0,0 +1,40 @@
    +  $form['youtube_pull']['youtubechannel_video_limit'] = array(
    ...
    +    '#default_value' => variable_get('youtube_pull_video_limit', 5),
    

    Change the form array key "youtubechannel_video_limit" to "youtube_pull_video_limit" so that it matched the variable being set.

  2. +++ b/youtube_pull.admin.inc
    @@ -0,0 +1,40 @@
    +  ¶
    

    Remove the additional spaces or special character(s).

  3. +++ b/youtube_pull.module
    @@ -1,12 +1,78 @@
    + * Based on codes YouTube Data API v3
    

    Please add a period after the docblock sentence.

  4. +++ b/youtube_pull.module
    @@ -1,12 +1,78 @@
    +  $blocks[0] = array(
    

    I think this should be named/keyed better. What are your thoughts on this?

  5. +++ b/youtube_pull.module
    @@ -25,34 +91,46 @@ function youtube_pull_theme() {
    +    // let's look at the results and check there are any videos.
    

    Please start the comment sentence with a capital letter.

  6. +++ b/youtube_pull.module
    @@ -25,34 +91,46 @@ function youtube_pull_theme() {
    +      // parse video entry
    

    Please start the comment with a capital letter and end it with a period.

Hope everything is in order.

Thanks!

leolandotan’s picture

Status: Needs work » Needs review
FileSize
4.33 KB
10.26 KB

Here is a patch where I:

  1. Fixed some coding standard issues
  2. Fixed some errors specifically on passing the `$options` variable into `youtube_pull_render()`
  3. Added some improvements where Youtube Data API search type is used by default to get Youtube Data while being able to change this as well

Usage of the `$options` variable can now look like this:

/**
 * Implements hook_block_view().
 */
function foo_block_view($delta = '') {
  switch ($delta) {
    case 'foo_block':
      $options = array(
        'api_type' => 'playlistItems',
        'playlistId' => 'SOME-PLAYLIST-ID',
        'max-results' => 1,
      );
      $block['content'] = youtube_pull_render($options);
      break;
  }

  return $block;
}

Hope everything is in order.

Thanks!

leolandotan’s picture

Apologies for my previous comment and patch. In this patch I did the following:

  1. Removed the `api_type` option because different Youtube Data API calls has different result structure and would conflict with the current implementation of the youtube_pull_parse_entry() function.
  2. Fixed the patch numbering.

Hope everything is in order.

Thanks!