You are here

function emvideo_ina_emvideo_parse in Asset 7

Implements hook_emvideo_parse().

File

modules/emvideo/modules/emvideo_ina/emvideo_ina.module, line 10
Emvideo ina module.

Code

function emvideo_ina_emvideo_parse($data) {
  $video_id = $id_user = $hashcode = NULL;
  $ret = FALSE;
  if (preg_match('@/video/ticket/([a-zA-Z0-9\\/]*)@', $data, $matches)) {
    $embed = explode('/', $matches[1]);
    $video_id = $embed[0];
    $id_user = $embed[1];
    $hashcode = $embed[2];
    $ret = array(
      'source' => "id_notice/{$video_id}/id_utilisateur/{$id_user}/hash/{$hashcode}",
      'provider' => 'ina',
    );
  }
  elseif (preg_match('@http://www.ina.fr(?:.*?)/video/([^/]*)@', $data, $matches)) {
    $video_id = $matches[1];
    $id_user = variable_get('emvideo_ina_id_user');
    $hashcode = variable_get('emvideo_ina_hashcode');
    $ret = array(
      'source' => "id_notice/{$video_id}/id_utilisateur/{$id_user}/hash/{$hashcode}",
      'provider' => 'ina',
    );
  }
  elseif (preg_match('@<iframe(?:.*?)src=\'(.*?)\'@i', $data, $matches)) {
    $source = $matches[1];
    $matches = array();
    $ret = array(
      'source' => $source,
      'provider' => 'ina',
    );
    if (preg_match('@http://player\\.ina\\.fr/player/embed/([0-9]+)/@i', $source, $matches)) {
      $video_id = $matches[1];
    }
  }
  elseif (preg_match('@<embed(?:.*?)src=\'(.*?)\'@i', $data, $matches)) {
    $source = $matches[1];
    $matches = array();
    $ret = array(
      'source' => $source,
      'provider' => 'ina',
    );
    if (preg_match('@http://player\\.ina\\.fr/player/ticket/([0-9]+)/@i', $source, $matches)) {
      $video_id = $matches[1];
    }
  }
  if ($video_id) {
    $ret['snapshot'] = 'http://www.ina.fr/images_v2/320x240/' . $video_id . '.jpeg';
  }
  return $ret;
}