A nice feature would be that a form does not get past validation when a user submits a video link that doesn't exist.

Right now when i add youtube.com/no_video as an video link, a youtube player gets embedded on the node without any content.

Comments

wbobeirne’s picture

Version: 7.x-1.x-dev » 7.x-2.0-beta4
StatusFileSize
new2.11 KB

Issue still exists in latest version, attached a patch for a fix. However, I think someone could probably do better. I had to use a custom error handler that throws an error for warnings because the validation method I used was plugging the video ID in to http://gdata.youtube.com/feeds/api/videos/%VIDEO_ID_HERE% which gives you a 400 error page if it's an invalid video ID. file_get_contents throws a warning at 400 pages which can't be caught in a regular try/catch block. So if anyone wants to make this patch better, be my guest.

wbobeirne’s picture

Status: Active » Needs review
jec006’s picture

Status: Needs review » Needs work
+++ b/video_embed_field.field.incundefined
@@ -125,11 +125,52 @@ function video_embed_field_field_validate($entity_type, $entity, $field, $instan
+      if(stristr($item['video_url'], 'youtube.com')){

We should check this for both vimeo and youtube.

+++ b/video_embed_field.field.incundefined
@@ -125,11 +125,52 @@ function video_embed_field_field_validate($entity_type, $entity, $field, $instan
+          $checkurl = 'http://gdata.youtube.com/feeds/api/videos/' . $urlparams['v'];

Both vimeo and youtube return 404's on the actual video page if the video doesn't exist. It would be better to just check that.

+++ b/video_embed_field.field.incundefined
@@ -125,11 +125,52 @@ function video_embed_field_field_validate($entity_type, $entity, $field, $instan
+            file_get_contents($checkurl);

We should use drupal_http_request which will return the http response code which can tell us whether it is there or not. file_get_contents doesn't always work on remote urls.

vedpareek’s picture

Assigned: Unassigned » vedpareek
StatusFileSize
new2.54 KB
vedpareek’s picture

StatusFileSize
new828 bytes

Please use new version of patch..
Issue still exists in latest version, attached a patch for a fix. I think someone could probably do better. I had to use a custom error handler Please check this patch.
please check this updated patch.
THanks

indigoxela’s picture

Hi,
is somebody still working on this?

Probably it would be a good idea to make the 404 check applicable for all providers, not only for youtube and/or vimeo.
It is easy to add custom providers in additional (custom) modules and validation should work for all of them.

I see no problem in either using get_headers() or drupal_http_request() as last check inside video_embed_field_field_validate() to get the http response code for $item['video_url'] as it is common to all providers. Or am I missing something?

An example for a check (works with 7.x-2.0-beta5 as last check in field validation):

      $remote_obj = drupal_http_request($item['video_url']);
      if (isset($remote_obj->error)) {
        $message = t('The given video URL @videourl has an error. Error: @error',
                     array(
                       '@videourl' => $item['video_url'],
                       '@error' => $remote_obj->code . ' - ' . $remote_obj->error,
                       )
                     );
        $errors[$field['field_name']][$langcode][$delta][] = array(
          'error' => 'video_embed_field_http_error', 
          'message' => $message,
        );
      }
anybody’s picture

Issue summary: View changes

Sadly the patch format in #5 is wrong. Should be a unified DIFF please.