Changeset 19213
- Timestamp:
- Nov 28, 2012, 12:49:06 PM (11 years ago)
- Location:
- extensions/gvideo
- Files:
-
- 1 deleted
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/gvideo/admin/add.php
r19056 r19213 12 12 array_push($page['errors'], l10n('Please fill the video URL')); 13 13 } 14 if ( !empty($_POST['url']) and ($video = parse_video_url($_POST['url'] )) === false )14 if ( !empty($_POST['url']) and ($video = parse_video_url($_POST['url'], isset($_POST['safe_mode']))) === false ) 15 15 { 16 array_push($page['errors'], l10n('Unable to contact host server')); 16 if (isset($_POST['safe_mode'])) 17 { 18 array_push($page['errors'], l10n('an error happened')); 19 } 20 else 21 { 22 array_push($page['errors'], l10n('Unable to contact host server')); 23 array_push($page['errors'], l10n('Try in safe-mode')); 24 } 25 $_POST['safe_mode'] = true; 17 26 } 18 27 … … 20 29 { 21 30 // download thumbnail 22 $thumb_name = $video['type'].'-'.$video['video_id'].'-'.uniqid().'.'.get_extension($video['thumbnail']); 31 $thumb_ext = empty($video['thumbnail']) ? 'jpg' : get_extension($video['thumbnail']); 32 $thumb_name = $video['type'].'-'.$video['video_id'].'-'.uniqid().'.'.$thumb_ext; 23 33 $thumb_source = $conf['data_location'].$thumb_name; 24 if ( download_remote_file($video['thumbnail'], $thumb_source) !== true)34 if ( empty($video['thumbnail']) or download_remote_file($video['thumbnail'], $thumb_source) !== true ) 25 35 { 26 36 $thumb_source = $conf['data_location'].get_filename_wo_extension($thumb_name).'.jpg'; -
extensions/gvideo/admin/photo.php
r19056 r19213 72 72 else if ($gvideo['url']!=$_POST['url']) 73 73 { 74 if( ($video = parse_video_url($_POST['url'])) === false ) 75 { 76 array_push($page['errors'], l10n('Unable to contact host server')); 74 if( ($video = parse_video_url($_POST['url'], isset($_POST['safe_mode']))) === false ) 75 { 76 if (isset($_POST['safe_mode'])) 77 { 78 array_push($page['errors'], l10n('an error happened')); 79 } 80 else 81 { 82 array_push($page['errors'], l10n('Unable to contact host server')); 83 array_push($page['errors'], l10n('Try in safe-mode')); 84 } 77 85 } 78 86 } … … 89 97 { 90 98 // download thumbnail 91 $thumb_name = $video['type'].'-'.$video['video_id'].'-'.uniqid().'.'.get_extension($video['thumbnail']); 99 $thumb_ext = empty($video['thumbnail']) ? 'jpg' : get_extension($video['thumbnail']); 100 $thumb_name = $video['type'].'-'.$video['video_id'].'-'.uniqid().'.'.$thumb_ext; 92 101 $thumb_source = $conf['data_location'].$thumb_name; 93 if ( download_remote_file($video['thumbnail'], $thumb_source) !== true)102 if ( empty($video['thumbnail']) or download_remote_file($video['thumbnail'], $thumb_source) !== true ) 94 103 { 95 104 $thumb_source = $conf['data_location'].get_filename_wo_extension($thumb_name).'.jpg'; -
extensions/gvideo/admin/template/add.tpl
r19056 r19213 88 88 89 89 90 <p style="text-align:left;"><input type="submit" name="add_video" value="{'Add'|@translate}"></p> 90 <p style="text-align:left;"> 91 <label style="font-weight:bold;"><input type="checkbox" name="safe_mode" {if $POST.safe_mode}checked="checked"{/if}> {'Safe-mode'|@translate}</label> 92 <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> 93 <br> 94 <input type="submit" name="add_video" value="{'Add'|@translate}"> 95 </p> 91 96 92 97 <fieldset> -
extensions/gvideo/admin/template/photo.tpl
r19056 r19213 98 98 99 99 <p style="margin:0;"> 100 <label style="font-weight:bold;"><input type="checkbox" name="safe_mode"> {'Safe-mode'|@translate}</label> 101 <br> 100 102 <input class="submit" type="submit" value="{'Save Settings'|@translate}" name="save_properties"> 101 103 </p> -
extensions/gvideo/include/functions.inc.php
r19056 r19213 2 2 if (!defined('PHPWG_ROOT_PATH')) die('Hacking attempt!'); 3 3 4 function parse_video_url($source_url )4 function parse_video_url($source_url, $safe_mode=false) 5 5 { 6 6 $source_url = 'http://'.preg_replace('#^http(s?)://#', null, $source_url); … … 10 10 $url['host'] = explode('.', $url['host']); 11 11 12 $video = array(); 12 $video = array( 13 'type' => null, 14 'video_id' => null, 15 'url' => null, 16 'title' => null, 17 'description' => null, 18 'thumbnail' => null, 19 'author' => null, 20 'tags' => null, 21 ); 22 13 23 switch ($url['host'][0]) 14 24 { … … 26 36 case 'youtu': // youtu.be (short-url service) 27 37 { 28 if (empty($video ))38 if (empty($video['video_id'])) 29 39 { 30 40 $video['type'] = 'youtube'; … … 34 44 } 35 45 36 $api_url = 'http://gdata.youtube.com/feeds/api/videos/'.$video['video_id'].'?v=2&alt=json'; 37 $json = download_remote_file($api_url, true); 38 if ($json === false or $json == 'file_error') return false; 39 40 $json = json_decode($json, true); 41 $video = array_merge($video, array( 42 'url' => 'http://youtube.com/watch?v='.$video['video_id'], 43 'title' => $json['entry']['title']['$t'], 44 'description' => $json['entry']['media$group']['media$description']['$t'], 45 'thumbnail' => $json['entry']['media$group']['media$thumbnail'][2]['url'], 46 'author' => $json['entry']['author'][0]['name']['$t'], 47 'tags' => null, 48 )); 46 $video['url'] = 'http://youtube.com/watch?v='.$video['video_id']; 47 48 if (!$safe_mode) 49 { 50 $api_url = 'http://gdata.youtube.com/feeds/api/videos/'.$video['video_id'].'?v=2&alt=json'; 51 $json = download_remote_file($api_url, true); 52 if ($json === false or $json == 'file_error') return false; 53 54 $json = json_decode($json, true); 55 $video = array_merge($video, array( 56 'title' => $json['entry']['title']['$t'], 57 'description' => $json['entry']['media$group']['media$description']['$t'], 58 'thumbnail' => $json['entry']['media$group']['media$thumbnail'][2]['url'], 59 'author' => $json['entry']['author'][0]['name']['$t'], 60 )); 61 } 62 else 63 { 64 $video['title'] = 'YouTube #'.$video['video_id']; 65 } 66 49 67 break; 50 68 } … … 58 76 $video['video_id'] = $url['path'][1]; 59 77 60 $api_url = 'http://vimeo.com/api/v2/video/'.$video['video_id'].'.json'; 61 $json = download_remote_file($api_url, true); 62 if ($json === false or $json == 'file_error') return false; 63 64 $json = json_decode($json, true); 65 $video = array_merge($video, array( 66 'url' => 'http://vimeo.com/'.$video['video_id'], 67 'title' => $json[0]['title'], 68 'description' => $json[0]['description'], 69 'thumbnail' => $json[0]['thumbnail_large'], 70 'author' => $json[0]['user_name'], 71 'tags' => array_map('trim', explode(',', $json[0]['tags'])), 72 )); 78 $video['url'] = 'http://vimeo.com/'.$video['video_id']; 79 80 if (!$safe_mode) 81 { 82 $api_url = 'http://vimeo.com/api/v2/video/'.$video['video_id'].'.json'; 83 $json = download_remote_file($api_url, true); 84 if ($json === false or $json == 'file_error') return false; 85 86 $json = json_decode($json, true); 87 $video = array_merge($video, array( 88 'title' => $json[0]['title'], 89 'description' => $json[0]['description'], 90 'thumbnail' => $json[0]['thumbnail_large'], 91 'author' => $json[0]['user_name'], 92 'tags' => array_map('trim', explode(',', $json[0]['tags'])), 93 )); 94 } 95 else 96 { 97 $video['title'] = 'Vimeo #'.$video['video_id']; 98 } 99 73 100 break; 74 101 } … … 83 110 $video['video_id'] = $url['path'][2]; 84 111 85 $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 86 $json = download_remote_file($api_url, true); 87 if ($json === false or $json == 'file_error') return false; 88 89 $json = json_decode($json, true); 90 $json['thumbnail_large_url'] = preg_replace('#\?([0-9]+)$#', null, $json['thumbnail_large_url']); 91 92 $video = array_merge($video, array( 93 'url' => 'http://dailymotion.com/video/'.$video['video_id'], 94 'title' => $json['title'], 95 'description' => $json['description'], 96 'thumbnail' => $json['thumbnail_large_url'], 97 'author' => $json['owner.username'], 98 'tags' => $json['tags'], 99 )); 112 $video['url'] = 'http://dailymotion.com/video/'.$video['video_id']; 113 114 if (!$safe_mode) 115 { 116 $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 117 $json = download_remote_file($api_url, true); 118 if ($json === false or $json == 'file_error') return false; 119 120 $json = json_decode($json, true); 121 $json['thumbnail_large_url'] = preg_replace('#\?([0-9]+)$#', null, $json['thumbnail_large_url']); 122 123 $video = array_merge($video, array( 124 'title' => $json['title'], 125 'description' => $json['description'], 126 'thumbnail' => $json['thumbnail_large_url'], 127 'author' => $json['owner.username'], 128 'tags' => $json['tags'], 129 )); 130 } 131 else 132 { 133 $video['title'] = $video['video_id']; 134 } 135 100 136 break; 101 137 } … … 106 142 $video['type'] = 'wat'; 107 143 144 // no safe_mode for wat.tv 108 145 $html = download_remote_file($source_url, true); 109 146 if ($html === false or $html == 'file_error') return false; … … 139 176 $video['video_id'] = rtrim($url['path'][2], '.html'); 140 177 141 $html = download_remote_file($source_url, true);142 if ($html === false or $html == 'file_error') return false;143 144 178 $video['url'] = 'http://wideo.fr/video/'.$video['video_id'].'.html'; 145 179 146 preg_match('#<meta property="og:title" content="([^">]*)" />#', $html, $matches); 147 $video['title'] = $matches[1]; 148 149 preg_match('#<meta property="og:description" content="([^">]*)" />#', $html, $matches); 150 $video['description'] = $matches[1]; 151 152 preg_match('#<meta property="og:image" content="([^">]+)" />#', $html, $matches); 153 $video['thumbnail'] = $matches[1]; 154 155 preg_match('#<li id="li_author">Auteur : <a href=(?:[^>]*)><span>(.*?)</span></a>#', $html, $matches); 156 $video['author'] = $matches[1]; 157 158 preg_match('#<meta name="keywords" content="([^">]+)" />#', $html, $matches); 159 $video['tags'] = array_map('trim', explode(',', $matches[1])); 180 if (!$safe_mode) 181 { 182 $html = download_remote_file($source_url, true); 183 if ($html === false or $html == 'file_error') return false; 184 185 preg_match('#<meta property="og:title" content="([^">]*)" />#', $html, $matches); 186 $video['title'] = $matches[1]; 187 188 preg_match('#<meta property="og:description" content="([^">]*)" />#', $html, $matches); 189 $video['description'] = $matches[1]; 190 191 preg_match('#<meta property="og:image" content="([^">]+)" />#', $html, $matches); 192 $video['thumbnail'] = $matches[1]; 193 194 preg_match('#<li id="li_author">Auteur : <a href=(?:[^>]*)><span>(.*?)</span></a>#', $html, $matches); 195 $video['author'] = $matches[1]; 196 197 preg_match('#<meta name="keywords" content="([^">]+)" />#', $html, $matches); 198 $video['tags'] = array_map('trim', explode(',', $matches[1])); 199 } 200 else 201 { 202 $video['title'] = $video['video_id']; 203 } 204 160 205 break; 161 206 } -
extensions/gvideo/include/install.inc.php
r19056 r19213 65 65 `url` varchar(255) DEFAULT NULL, 66 66 `type` varchar(64) NOT NULL, 67 `video_id` varchar( 64) NOT NULL,67 `video_id` varchar(128) NOT NULL, 68 68 `width` smallint(9) DEFAULT NULL, 69 69 `height` smallint(9) DEFAULT NULL, … … 73 73 pwg_query($query); 74 74 75 // update video_id lenght 76 $query = 'ALTER TABLE `'.gvideo_table.'` CHANGE `video_id` `video_id` VARCHAR(128) CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL;'; 77 pwg_query($query); 78 75 79 // new collumn in images table 76 80 $result = pwg_query('SHOW COLUMNS FROM '.IMAGES_TABLE.' LIKE "is_gvideo";'); 77 81 if (!pwg_db_num_rows($result)) 78 { 82 { 79 83 pwg_query('ALTER TABLE `' . IMAGES_TABLE . '` ADD `is_gvideo` TINYINT(1) NOT NULL DEFAULT 0;'); 80 84 -
extensions/gvideo/language/en_UK/plugin.lang.php
r19056 r19213 26 26 $lang['Vimeo player'] = 'Vimeo player'; 27 27 $lang['Dailymotion player'] = 'Dailymotion player'; 28 $lang['Try in safe-mode'] = 'Try in safe-mode'; 29 $lang['Safe-mode'] = 'Safe-mode'; 30 $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.'; 31 $lang['Video properties'] = 'Video properties'; 28 32 29 33 ?> -
extensions/gvideo/language/fr_FR/plugin.lang.php
r19056 r19213 26 26 $lang['Vimeo player'] = 'Lecteur Vimeo'; 27 27 $lang['Dailymotion player'] = 'Lecteur Dailymotion'; 28 $lang['Try in safe-mode'] = 'Essayez en mode sans échec'; 29 $lang['Safe-mode'] = 'Mode sans échec'; 30 $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.'; 31 $lang['Video properties'] = 'Propriétés vidéo'; 28 32 29 33 ?>
Note: See TracChangeset
for help on using the changeset viewer.