You are here

function zoomapi_download_meeting_recordings_to_entity in Zoom API 7.2

Download meeting recordings for entity.

Given an entity, lookup any meetings and download any recordings to a specified location.

1 call to zoomapi_download_meeting_recordings_to_entity()
zoomapi_download_meeting_recordings_from_tracker in ./zoomapi.module
Download meeting recordings.

File

./zoomapi.module, line 894
Main file for the Zoom API module.

Code

function zoomapi_download_meeting_recordings_to_entity($entity, $entity_type, $field_name, array $zoom_meeting_recordings = []) {
  if (is_numeric($entity)) {
    $entity = entity_load_single($entity_type, $entity);
  }
  list($entity_id, , ) = entity_extract_ids($entity_type, $entity);
  $destination_directory = zoomapi_get_entity_field_location($entity, $entity_type, $field_name);
  $zoom_meeting_recordings = $zoom_meeting_recordings ?: zoomapi_get_meeting_recordings_for_entity($entity_type, $entity);
  if (!zoomapi_get_recording_download_tracking_info($zoom_meeting_recordings['uuid'])) {
    $destination_info = "{$entity_type}:{$entity_id}:{$field_name}";
    zoomapi_start_recording_download_tracking($zoom_meeting_recordings, $destination_info, 'entity');
  }
  $context = [
    'entity' => $entity,
    'entity_id' => $entity_id,
    'entity_type' => $entity_type,
    'field_name' => $field_name,
  ];
  $files = $zoom_meeting_recordings ? zoomapi_download_meeting_recordings($zoom_meeting_recordings, $destination_directory, $context) : [];
  $success = count($files) == count(array_filter($files));
  zoomapi_update_recording_download_tracking($zoom_meeting_recordings['uuid'], $success);
  zoomapi_attach_recording_files_to_entity_field($entity, $entity_type, $field_name, $files, $success);
  return $success;
}