I had a need to do something with the data coming back from a Ooyala ping request. There weren't any good hooks that I could implement, other than completely overriding the hook_menu() page callback for the ping URL with my own, and so I got to thinking that this sort of event-based processing was well-suited to rules.

So, I've put together an initial patch providing Rules integration with a couple of basic events, and some data types (see below). I haven't introduced a hard dependency on Rules, in that all of the rules_invoke_event_by_args() calls are wrapped by a check that module_exists('rules'). All the rules hooks are implemented in ooyala.rules.inc.

There are probably more events that it would be useful to have rules integration for, but these are the ones I had an immediate need for, so I thought I'd contribute them now.

Events

  • After a ping request is processed for a video node.
  • After an image is fetched for a video node.
  • After a ping request is received with an embed code not used by any nodes.

Data types

Based on the data structure returned from the Ooyala Backlot API for an Ooyala asset.

  • Ooyala asset
  • Ooyala preview image
  • Ooyala image size
  • Ooyala time restriction

Actions

  • Import from Backlot

I'll be attaching the patch shortly. Let me know if there are any issues with this patch. I'd love to get it committed.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

jamesharv’s picture

Status: Needs work » Needs review
FileSize
8.88 KB

Patch attached.

jamesharv’s picture

Here's an updated version of the patch, which converts the date fields in the Ooyala response to unix time stamps, so that they are more usable by Rules. I also corrected a few mistakes with the time_restrictions property.

jamesharv’s picture

Apologies, the last patch was missing some important code. Please use this one instead.

jamesharv’s picture

I found another use case for Rules integration. Here's an updated patch which adds the event:

  • After a ping request is received with an embed code not used by any nodes.

And it adds the action:

  • Import from Backlot

The use case would be: automatically import assets uploaded directly to Backlot.

jamesharv’s picture

Issue summary: View changes
jamesharv’s picture

Issue summary: View changes
jamesharv’s picture

Here's another improvement.

The ooyala_import action now provides the node that it creates, and it also fetch's the node's preview image.

quicksketch’s picture

Hi @jamesharv, thanks for your contribution! Unfortunately I have a severe aversion to Rules. Considering the amount of complexity we already have to maintain in this module, I'd like to avoid additional integrations, especially ones that I wouldn't use or be willing to maintain. However, the popularity of Rules module is uncontested, so I'd encourage you to make an add-on module with its own namespace to share your code with others (i.e. an ooyala_rules module). If you haven't already gone through the process of Git application to make official projects on drupal.org, I'd be happy to help sponsor your application.

jamesharv’s picture

Hi @quicksketch, fair enough. I'd be interested in breaking this out into an ooyala_rules module, but there are some key places in the ooyala project codebase where the Rule's events need to be triggered. Would you be open to a separate patch, adding integration points for an ooyala_rules module?

These integration points could probably just be module_invoke_all() / drupal_alter() calls to avoid any hard dependency.

quicksketch’s picture

These integration points could probably just be module_invoke_all() / drupal_alter() calls to avoid any hard dependency.

That sounds perfect! I'd be happy to add such hooks. Thanks for all your help on this module.

quicksketch’s picture

Status: Needs review » Postponed

@jamesharv If you ever got around to this, please let me know. I'm moving this to postponed in the mean time.