As described here (http://drupal.org/node/1312906#comment-5871140), a lot of the video provider data is serialized and cannot be exposed to Views currently. For my site, users would like to be able to sort by video length, and currently, that can't be done with Views.

jec006 recommended putting that request into another issue, so here it is. Anybody have any idea how to pull this off?

Comments

jodym’s picture

I would really like to know if this is possible as well.... trevorkjorlien did you manage to find a solution?

trevorkjorlien’s picture

@jody.mcbride No, it's beyond my skill set at the moment.

wbobeirne’s picture

Hey guys,

I've put some work in to implementing this, but I'm thinking that it could use a lot more work/feedback. Attached a patch for 7.x-2.x.

Things the patch does:

  • Adds a column for video_length on vef fields
  • Updates all existing fields with the length (This may take a long time, depending on how many videos you have)
  • Adds sort and filter for video length (Automatically handled by views)
  • Adds a parameter for video handlers to have a function determine the length of the video based on the data retrieved by the data_function parameter

Things this patch does NOT do:

  • Provide any display of the length in field or view formatter form
  • Provide robust filters. It's the basic views filters, and it only takes input as seconds. Exposing this to users may be problematic without fleshing the filters out.
  • Add the function to determine the length to any handler except vimeo and youtube. Facebook isn't getting any metadata right now, so I can't pull the length out. Custom handlers will have to implement this themselves.

So, do you guys have any requests or ideas on how to improve on what I've got so far?

wbobeirne’s picture

Status:Active» Needs review
trevorkjorlien’s picture

Hey, I finally got around to trying this patch out. It mostly worked, save for this error that I got:

patching file video_embed_field.field.inc
Hunk #1 succeeded at 166 (offset -12 lines).
patching file video_embed_field.handlers.inc
patching file video_embed_field.install
patching file video_embed_field.module
Hunk #1 succeeded at 452 (offset -3 lines).
Hunk #2 FAILED at 575.
1 out of 2 hunks FAILED -- saving rejects to file video_embed_field.module.rej

Looks like hunk #2 was this:

/**
*  Creates a hash for storing or looking up a video in the store table
*/
function _video_embed_field_hash($video_url, $video_style){
  return md5('vef' . $video_url . $video_style);
}