Through YouTube API (i don't know that about Vimeo) u can retrieve video duration:

  echo 'Duration: ' . $videoEntry->getVideoDuration() . "\n";

Can u also integrate this feature? it can be very useful!

P.D. there are a lot of info that u can get through api.

for example:

  echo 'Video: ' . $videoEntry->getVideoTitle() . "\n";
  echo 'Video ID: ' . $videoEntry->getVideoId() . "\n";
  echo 'Updated: ' . $videoEntry->getUpdated() . "\n";
  echo 'Description: ' . $videoEntry->getVideoDescription() . "\n";
  echo 'Category: ' . $videoEntry->getVideoCategory() . "\n";
  echo 'Tags: ' . implode(", ", $videoEntry->getVideoTags()) . "\n";
  echo 'Watch page: ' . $videoEntry->getVideoWatchPageUrl() . "\n";
  echo 'Flash Player Url: ' . $videoEntry->getFlashPlayerUrl() . "\n";
  echo 'Duration: ' . $videoEntry->getVideoDuration() . "\n";
  echo 'View count: ' . $videoEntry->getVideoViewCount() . "\n";
  echo 'Rating: ' . $videoEntry->getVideoRatingInfo() . "\n";
  echo 'Geo Location: ' . $videoEntry->getVideoGeoLocation() . "\n";
  echo 'Recorded on: ' . $videoEntry->getVideoRecorded() . "\n";

http://code.google.com/intl/en-EN/apis/youtube/2.0/developers_guide_php....

CommentFileSizeAuthor
#3 patch_commit_ab48ad911670.patch19.57 KBjdelaune
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

rhache’s picture

yeah, that would be really useful. Doesn't have to be displayed by default. As long as the information was in the field items array you could then easily display what you want with a simple field template override.

Thanks,
Rene

jdelaune’s picture

jec006 any ideas how we would tackle this? Add another serialised column in the database to hold a data array, then add a callback hook which fetches additional video data for that specific type and stores it in the database?

We would only be able expose this additional data in theme functions though. What do you think, have any better ideas for implementing this?

I'm happy to do the dirty work just wanted to see if you had any bright ideas.

Cheers

jdelaune’s picture

Nearly there I think.

- Adds a data database column.
- Provides a template file that can be overridden in your theme so you can use the data to display what you want.
- Other bits cleaned up here and there.

Example overridden template file:

<?php
/**
 * @file
 * Default theme implementation to display a video embed field.
 *
 * Variables available:
 * - $url: The URL of the video to display embed code for
 * - $style: The style name of the embed code to use
 * - $style_settings: The style settings for the embed code
 * - $handler: The name of the video handler
 * - $embed_code: The embed code
 * - $data: Additional video data
 *
 * @see template_preprocess_video_embed()
 */
?>

<div class="embedded-video">
  <div class="player">
    <?php print $embed_code; ?>
  </div>
  <?php if ($handler == 'vimeo') print t('Video uploaded by !user', array('!user' => l($data['user_name'], $data['user_url']))); ?>
</div>

Might need to re-work things for the colorbox side of things as well?

jdelaune’s picture

Version: 7.x-1.x-dev » 7.x-2.x-dev
Assigned: Unassigned » jdelaune
Status: Active » Needs review
jec006’s picture

Hey, I'm sorry for the delay

Was thinking about it, but will review your patch and let you know if I have something better.

thanks again :)

theshanergy’s picture

This is awesome - any chance this data could be exposed to views as well?

jec006’s picture

Status: Needs review » Fixed

Thanks as always jdelaune

Committed here: http://drupal.org/commitlog/commit/25834/3c2fbc23b0922b3c37eda8452831c6d...
and added a bit of stuff here: http://drupal.org/commitlog/commit/25834/080a6062a8dac586e2664839e3cc3af...

if you wouldn't mind checking that first commit, I had to do some hand merging because I updated a few things before reading your patch. I tested things and it all seems good, but let me know if I missed something.

As far as views integration: that would be sweet, however, right now the data is serialized and we don't really know what will be in it (as the providers can have different data) so I'm not sure how we'd go about showing views that data in a useful way.

It might be nice (though this is really ambitious) to add stuff to the settings to let you expose some of it. We'll have to see. Would you mind moving that to a new issue deckfifty?

Thanks everyone

Status: Fixed » Closed (fixed)

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

ksiar’s picture

Status: Active » Closed (fixed)

Doing that to display duration? Did anyone looked what data array contain?

$data['media$group']['media$content'][0]['duration']

ksiar’s picture

Status: Closed (fixed) » Active

+ An idea to put description value out of $embed_code. Now if I want to print description value before video, I have to modify field.tpl.php (or node template) and from there I can get the youtube values, so what is the point of this template file? Or am I doing smt wrong?

jdelaune’s picture

Status: Closed (fixed) » Active

The description field is different because it's user modifiable. The description you get from YouTube or Vimeo etc isn't.

jec006’s picture

Status: Active » Closed (works as designed)
jec006’s picture

Issue summary: View changes

link added.