Index: /extensions/gvideo/admin/add.php
===================================================================
--- /extensions/gvideo/admin/add.php	(revision 19212)
+++ /extensions/gvideo/admin/add.php	(revision 19213)
@@ -12,7 +12,16 @@
     array_push($page['errors'], l10n('Please fill the video URL'));
   }
-  if ( !empty($_POST['url']) and ($video = parse_video_url($_POST['url'])) === false )
+  if ( !empty($_POST['url']) and ($video = parse_video_url($_POST['url'], isset($_POST['safe_mode']))) === false )
   {
-    array_push($page['errors'], l10n('Unable to contact host server'));
+    if (isset($_POST['safe_mode']))
+    {
+      array_push($page['errors'], l10n('an error happened'));
+    }
+    else
+    {
+      array_push($page['errors'], l10n('Unable to contact host server'));
+      array_push($page['errors'], l10n('Try in safe-mode'));
+    }
+    $_POST['safe_mode'] = true;
   }
   
@@ -20,7 +29,8 @@
   {
     // download thumbnail
-    $thumb_name = $video['type'].'-'.$video['video_id'].'-'.uniqid().'.'.get_extension($video['thumbnail']);
+    $thumb_ext = empty($video['thumbnail']) ? 'jpg' : get_extension($video['thumbnail']);
+    $thumb_name = $video['type'].'-'.$video['video_id'].'-'.uniqid().'.'.$thumb_ext;
     $thumb_source = $conf['data_location'].$thumb_name;
-    if (download_remote_file($video['thumbnail'], $thumb_source) !== true)
+    if ( empty($video['thumbnail']) or download_remote_file($video['thumbnail'], $thumb_source) !== true )
     {
       $thumb_source = $conf['data_location'].get_filename_wo_extension($thumb_name).'.jpg';
Index: /extensions/gvideo/admin/photo.php
===================================================================
--- /extensions/gvideo/admin/photo.php	(revision 19212)
+++ /extensions/gvideo/admin/photo.php	(revision 19213)
@@ -72,7 +72,15 @@
   else if ($gvideo['url']!=$_POST['url'])
   {
-    if( ($video = parse_video_url($_POST['url'])) === false )
-    {
-      array_push($page['errors'], l10n('Unable to contact host server'));
+    if( ($video = parse_video_url($_POST['url'], isset($_POST['safe_mode']))) === false )
+    {
+      if (isset($_POST['safe_mode']))
+      {
+        array_push($page['errors'], l10n('an error happened'));
+      }
+      else
+      {
+        array_push($page['errors'], l10n('Unable to contact host server'));
+        array_push($page['errors'], l10n('Try in safe-mode'));
+      }
     }
   }
@@ -89,7 +97,8 @@
     {
       // download thumbnail
-      $thumb_name = $video['type'].'-'.$video['video_id'].'-'.uniqid().'.'.get_extension($video['thumbnail']);
+      $thumb_ext = empty($video['thumbnail']) ? 'jpg' : get_extension($video['thumbnail']);
+      $thumb_name = $video['type'].'-'.$video['video_id'].'-'.uniqid().'.'.$thumb_ext;
       $thumb_source = $conf['data_location'].$thumb_name;
-      if (download_remote_file($video['thumbnail'], $thumb_source) !== true)
+      if ( empty($video['thumbnail']) or download_remote_file($video['thumbnail'], $thumb_source) !== true )
       {
         $thumb_source = $conf['data_location'].get_filename_wo_extension($thumb_name).'.jpg';
Index: /extensions/gvideo/admin/template/add.tpl
===================================================================
--- /extensions/gvideo/admin/template/add.tpl	(revision 19212)
+++ /extensions/gvideo/admin/template/add.tpl	(revision 19213)
@@ -88,5 +88,10 @@
 
 
-<p style="text-align:left;"><input type="submit" name="add_video" value="{'Add'|@translate}"></p>
+<p style="text-align:left;">
+  <label style="font-weight:bold;"><input type="checkbox" name="safe_mode" {if $POST.safe_mode}checked="checked"{/if}> {'Safe-mode'|@translate}</label>
+  <a class="showInfo" title="{'In safe-mode, the plugin does\'t try to contact the video host, usefull on some websites where remote connections are blocked.'|@translate}">i</a>
+  <br>
+  <input type="submit" name="add_video" value="{'Add'|@translate}">
+</p>
 
 <fieldset>
Index: /extensions/gvideo/admin/template/photo.tpl
===================================================================
--- /extensions/gvideo/admin/template/photo.tpl	(revision 19212)
+++ /extensions/gvideo/admin/template/photo.tpl	(revision 19213)
@@ -98,4 +98,6 @@
 
     <p style="margin:0;">
+      <label style="font-weight:bold;"><input type="checkbox" name="safe_mode"> {'Safe-mode'|@translate}</label>
+      <br>
       <input class="submit" type="submit" value="{'Save Settings'|@translate}" name="save_properties">
     </p>
Index: /extensions/gvideo/include/functions.inc.php
===================================================================
--- /extensions/gvideo/include/functions.inc.php	(revision 19212)
+++ /extensions/gvideo/include/functions.inc.php	(revision 19213)
@@ -2,5 +2,5 @@
 if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!');
 
-function parse_video_url($source_url)
+function parse_video_url($source_url, $safe_mode=false)
 {
   $source_url = 'http://'.preg_replace('#^http(s?)://#', null, $source_url);
@@ -10,5 +10,15 @@
   $url['host'] = explode('.', $url['host']);
   
-  $video = array();
+  $video = array(
+    'type' => null,
+    'video_id' => null,
+    'url' => null,
+    'title' => null,
+    'description' => null,
+    'thumbnail' => null,
+    'author' => null,
+    'tags' => null,
+  );
+  
   switch ($url['host'][0])
   {
@@ -26,5 +36,5 @@
     case 'youtu': // youtu.be (short-url service)
     {
-      if (empty($video))
+      if (empty($video['video_id']))
       {
         $video['type'] = 'youtube';
@@ -34,17 +44,25 @@
       }
       
-      $api_url = 'http://gdata.youtube.com/feeds/api/videos/'.$video['video_id'].'?v=2&alt=json';
-      $json = download_remote_file($api_url, true);
-      if ($json === false or $json == 'file_error') return false;
-      
-      $json = json_decode($json, true);
-      $video = array_merge($video, array(
-        'url' => 'http://youtube.com/watch?v='.$video['video_id'],
-        'title' => $json['entry']['title']['$t'],
-        'description' => $json['entry']['media$group']['media$description']['$t'],
-        'thumbnail' => $json['entry']['media$group']['media$thumbnail'][2]['url'],
-        'author' => $json['entry']['author'][0]['name']['$t'],
-        'tags' => null,
-        ));
+      $video['url'] = 'http://youtube.com/watch?v='.$video['video_id'];
+      
+      if (!$safe_mode)
+      {
+        $api_url = 'http://gdata.youtube.com/feeds/api/videos/'.$video['video_id'].'?v=2&alt=json';
+        $json = download_remote_file($api_url, true);
+        if ($json === false or $json == 'file_error') return false;
+        
+        $json = json_decode($json, true);
+        $video = array_merge($video, array(
+          'title' => $json['entry']['title']['$t'],
+          'description' => $json['entry']['media$group']['media$description']['$t'],
+          'thumbnail' => $json['entry']['media$group']['media$thumbnail'][2]['url'],
+          'author' => $json['entry']['author'][0]['name']['$t'],
+          ));
+      }
+      else
+      {
+        $video['title'] = 'YouTube #'.$video['video_id'];
+      }
+      
       break;
     }
@@ -58,17 +76,26 @@
       $video['video_id'] = $url['path'][1];
       
-      $api_url = 'http://vimeo.com/api/v2/video/'.$video['video_id'].'.json';
-      $json = download_remote_file($api_url, true);
-      if ($json === false or $json == 'file_error') return false;
-      
-      $json = json_decode($json, true);
-      $video = array_merge($video, array(
-        'url' => 'http://vimeo.com/'.$video['video_id'],
-        'title' => $json[0]['title'],
-        'description' => $json[0]['description'],
-        'thumbnail' => $json[0]['thumbnail_large'],
-        'author' => $json[0]['user_name'],
-        'tags' => array_map('trim', explode(',', $json[0]['tags'])),
-        ));
+      $video['url'] = 'http://vimeo.com/'.$video['video_id'];
+      
+      if (!$safe_mode)
+      {
+        $api_url = 'http://vimeo.com/api/v2/video/'.$video['video_id'].'.json';
+        $json = download_remote_file($api_url, true);
+        if ($json === false or $json == 'file_error') return false;
+        
+        $json = json_decode($json, true);
+        $video = array_merge($video, array(
+          'title' => $json[0]['title'],
+          'description' => $json[0]['description'],
+          'thumbnail' => $json[0]['thumbnail_large'],
+          'author' => $json[0]['user_name'],
+          'tags' => array_map('trim', explode(',', $json[0]['tags'])),
+          ));
+      }
+      else
+      {
+        $video['title'] = 'Vimeo #'.$video['video_id'];
+      }
+      
       break;
     }
@@ -83,19 +110,28 @@
       $video['video_id'] = $url['path'][2];
       
-      $api_url = 'https://api.dailymotion.com/video/'.$video['video_id'].'?fields=description,thumbnail_large_url,title,owner.username,tags'; // DM doesn't accept non secure connection
-      $json = download_remote_file($api_url, true);
-      if ($json === false or $json == 'file_error') return false;
-      
-      $json = json_decode($json, true);
-      $json['thumbnail_large_url'] = preg_replace('#\?([0-9]+)$#', null, $json['thumbnail_large_url']);
-      
-      $video = array_merge($video, array(
-        'url' => 'http://dailymotion.com/video/'.$video['video_id'],
-        'title' => $json['title'],
-        'description' => $json['description'],
-        'thumbnail' => $json['thumbnail_large_url'],
-        'author' => $json['owner.username'],
-        'tags' => $json['tags'],
-        ));
+      $video['url'] = 'http://dailymotion.com/video/'.$video['video_id'];
+      
+      if (!$safe_mode)
+      {
+        $api_url = 'https://api.dailymotion.com/video/'.$video['video_id'].'?fields=description,thumbnail_large_url,title,owner.username,tags'; // DM doesn't accept non secure connection
+        $json = download_remote_file($api_url, true);
+        if ($json === false or $json == 'file_error') return false;
+        
+        $json = json_decode($json, true);
+        $json['thumbnail_large_url'] = preg_replace('#\?([0-9]+)$#', null, $json['thumbnail_large_url']);
+        
+        $video = array_merge($video, array(
+          'title' => $json['title'],
+          'description' => $json['description'],
+          'thumbnail' => $json['thumbnail_large_url'],
+          'author' => $json['owner.username'],
+          'tags' => $json['tags'],
+          ));
+      }
+      else
+      {
+        $video['title'] = $video['video_id'];
+      }
+      
       break;
     }
@@ -106,4 +142,5 @@
       $video['type'] = 'wat';
       
+      // no safe_mode for wat.tv
       $html = download_remote_file($source_url, true);
       if ($html === false or $html == 'file_error') return false;
@@ -139,23 +176,31 @@
       $video['video_id'] = rtrim($url['path'][2], '.html');
       
-      $html = download_remote_file($source_url, true);
-      if ($html === false or $html == 'file_error') return false;
-      
       $video['url'] = 'http://wideo.fr/video/'.$video['video_id'].'.html';
       
-      preg_match('#<meta property="og:title" content="([^">]*)" />#', $html, $matches);
-      $video['title'] = $matches[1];
-      
-      preg_match('#<meta property="og:description" content="([^">]*)" />#', $html, $matches);
-      $video['description'] = $matches[1];
-      
-      preg_match('#<meta property="og:image" content="([^">]+)" />#', $html, $matches);
-      $video['thumbnail'] = $matches[1];
-      
-      preg_match('#<li id="li_author">Auteur :  <a href=(?:[^>]*)><span>(.*?)</span></a>#', $html, $matches);
-      $video['author'] = $matches[1];
-      
-      preg_match('#<meta name="keywords" content="([^">]+)" />#', $html, $matches);
-      $video['tags'] = array_map('trim', explode(',', $matches[1]));
+      if (!$safe_mode)
+      {
+        $html = download_remote_file($source_url, true);
+        if ($html === false or $html == 'file_error') return false;
+        
+        preg_match('#<meta property="og:title" content="([^">]*)" />#', $html, $matches);
+        $video['title'] = $matches[1];
+        
+        preg_match('#<meta property="og:description" content="([^">]*)" />#', $html, $matches);
+        $video['description'] = $matches[1];
+        
+        preg_match('#<meta property="og:image" content="([^">]+)" />#', $html, $matches);
+        $video['thumbnail'] = $matches[1];
+        
+        preg_match('#<li id="li_author">Auteur :  <a href=(?:[^>]*)><span>(.*?)</span></a>#', $html, $matches);
+        $video['author'] = $matches[1];
+        
+        preg_match('#<meta name="keywords" content="([^">]+)" />#', $html, $matches);
+        $video['tags'] = array_map('trim', explode(',', $matches[1]));
+      }
+      else
+      {
+        $video['title'] = $video['video_id'];
+      }
+      
       break;
     }
Index: /extensions/gvideo/include/install.inc.php
===================================================================
--- /extensions/gvideo/include/install.inc.php	(revision 19212)
+++ /extensions/gvideo/include/install.inc.php	(revision 19213)
@@ -65,5 +65,5 @@
   `url` varchar(255) DEFAULT NULL,
   `type` varchar(64) NOT NULL,
-  `video_id` varchar(64) NOT NULL,
+  `video_id` varchar(128) NOT NULL,
   `width` smallint(9) DEFAULT NULL,
   `height` smallint(9) DEFAULT NULL,
@@ -73,8 +73,12 @@
   pwg_query($query);
   
+  // update video_id lenght
+  $query = 'ALTER TABLE `'.gvideo_table.'` CHANGE `video_id` `video_id` VARCHAR(128) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL;';
+  pwg_query($query);
+  
   // new collumn in images table
   $result = pwg_query('SHOW COLUMNS FROM '.IMAGES_TABLE.' LIKE "is_gvideo";');
   if (!pwg_db_num_rows($result))
-  {      
+  {
     pwg_query('ALTER TABLE `' . IMAGES_TABLE . '` ADD `is_gvideo` TINYINT(1) NOT NULL DEFAULT 0;');
     
Index: /extensions/gvideo/language/en_UK/plugin.lang.php
===================================================================
--- /extensions/gvideo/language/en_UK/plugin.lang.php	(revision 19212)
+++ /extensions/gvideo/language/en_UK/plugin.lang.php	(revision 19213)
@@ -26,4 +26,8 @@
 $lang['Vimeo player'] = 'Vimeo player';
 $lang['Dailymotion player'] = 'Dailymotion player';
+$lang['Try in safe-mode'] = 'Try in safe-mode';
+$lang['Safe-mode'] = 'Safe-mode';
+$lang['In safe-mode, the plugin does\'t try to contact the video host, usefull on some websites where remote connections are blocked.'] = 'In safe-mode, the plugin does\'t try to contact the video host, usefull on some websites where remote connections are blocked.';
+$lang['Video properties'] = 'Video properties';
 
 ?>
Index: /extensions/gvideo/language/fr_FR/plugin.lang.php
===================================================================
--- /extensions/gvideo/language/fr_FR/plugin.lang.php	(revision 19212)
+++ /extensions/gvideo/language/fr_FR/plugin.lang.php	(revision 19213)
@@ -26,4 +26,8 @@
 $lang['Vimeo player'] = 'Lecteur Vimeo';
 $lang['Dailymotion player'] = 'Lecteur Dailymotion';
+$lang['Try in safe-mode'] = 'Essayez en mode sans échec';
+$lang['Safe-mode'] = 'Mode sans échec';
+$lang['In safe-mode, the plugin does\'t try to contact the video host, usefull on some websites where remote connections are blocked.'] = 'En mode sans échec, le plugin n\'essaye pas de contacter l\'hébergeur de la vidéo, utile sur certains sites où les connexions externes sont bloquées.';
+$lang['Video properties'] = 'Propriétés vidéo';
 
 ?>
