You are here

function _media_browser_plus_metadata in Media Browser Plus 7.2

Same name and namespace in other branches
  1. 7 media_browser_plus.module \_media_browser_plus_metadata()

Helper function to return metadata from a 3rd party media provider.

Support for 3rd party metadata such as YouTube.

Parameters

object $provider: A provider object as returned by media_internet_get_provider().

Return value

array An array of media metadata available from the provider, keyed on field name.

See also

http://video.search.yahoo.com/mrss

media_internet_get_provider()

MediaInternetYouTubeHandler::getMRSS()

1 call to _media_browser_plus_metadata()
media_browser_plus_submit in ./media_browser_plus.module
Submit handler for the media browser forms that create new media entities.

File

./media_browser_plus.module, line 478
Adds fields to the media browser forms for better UX

Code

function _media_browser_plus_metadata($provider) {

  // @todo This is early, experimental code, still subject to much change. For
  //   now, we assume $provider->getMRSS() returns a SimpleXML element. We'll
  //   want to change this assumption and have it return an array instead, but
  //   that requires fixing media_retrieve_xml() to handle XML namespaces
  //   properly.
  $data = array();
  if (is_callable(array(
    $provider,
    'getMRSS',
  )) && ($rss = $provider
    ->getMRSS())) {

    // MRSS is an extension of RSS, so the title field is available in the
    // default (ATOM) namespace.
    $data['media_title'] = (string) $rss->title;

    // The MRSS extensions are in their own namespace.
    $mrss = $rss
      ->children('http://search.yahoo.com/mrss/');
    $data['media_description'] = (string) $mrss->group->description;
  }
  $data = array_filter($data, 'strlen');
  return $data;
}