Projet

Général

Profil

Révision 5e632cae

Ajouté par Assos Assos il y a plus de 3 ans

Weekly update of contrib modules

Voir les différences:

drupal7/sites/all/modules/media_youtube/includes/MediaInternetYouTubeHandler.inc
111 111
    $uri = file_stream_wrapper_uri_normalize('youtube://' . $type . '/' . check_plain($id));
112 112
    $external_url = file_create_url($uri);
113 113
    $oembed_url = url('https://www.youtube.com/oembed', array('query' => array('url' => $external_url, 'format' => 'json')));
114
    $response = drupal_http_request($oembed_url, array('method' => 'HEAD'));
114
    $response = drupal_http_request($oembed_url);
115 115

  
116
    if ($response->code == 401) {
117
      throw new MediaInternetValidationException('Embedding has been disabled for this YouTube video.');
116
    if (!isset($response->error)) {
117
      $data = drupal_json_decode($response->data);
118
      if (!empty($data)) {
119
        return TRUE;
120
      }
121
      else {
122
        $error_data = t('Unspecific');
123
        if (is_string($response->data)) {
124
          $error_data = $response->data;
125
        }
126
        throw new MediaInternetValidationException("The YouTube video ID is invalid, video was deleted or is disabled for embedding. Error: {$error_data}");
127
        return;
128
      }
118 129
    }
119
    elseif ($response->code != 200) {
120
      throw new MediaInternetValidationException('The YouTube video ID is invalid or the video was deleted.');
130
    else {
131
      throw new Exception("Error Processing Request. (Error: {$response->code}, {$response->error})");
132
      return;
121 133
    }
122

  
123
    return TRUE;
124 134
  }
125 135
}

Formats disponibles : Unified diff