You are here

function _media_youtube_fetch_metadata_batch_set in Media: YouTube 6

2 calls to _media_youtube_fetch_metadata_batch_set()
media_youtube_update_6012 in ./media_youtube.install
Rebuild youtube data to account for not saving raw by default.
media_youtube_update_6014 in ./media_youtube.install
Self-correct for missing thumbnails from a previous mistake.

File

./media_youtube.install, line 245
This is Media: YouTube's installation, configuration, and removal file.

Code

function _media_youtube_fetch_metadata_batch_set($batch_function, $title = '', $query_string = '') {
  $ret = array();

  // Build a list of fields that need metadata updating.
  $fields = array();
  module_load_install('install', 'content');
  foreach (content_types_install() as $type_name => $type_fields) {
    foreach ($type_fields as $field) {
      if ($field['module'] == 'emvideo') {

        // We only process a given field once.
        $fields[$field['field_name']] = $field;
      }
    }
  }

  // Build a batch that grabs the YouTube metadata for each video.
  $batch = array(
    'title' => $title,
    'operations' => array(),
    'file' => drupal_get_path('module', 'media_youtube') . '/media_youtube.install',
  );
  foreach ($fields as $field_name => $field) {
    $batch['operations'][] = array(
      $batch_function,
      array(
        $field,
      ),
    );
    $ret[] = array(
      'query' => t($query_string, array(
        '%field' => $field['field_name'],
      )),
      'success' => TRUE,
    );
  }
  batch_set($batch);
  return $ret;
}