? video_filter.patch
Index: video_filter.codecs.inc
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/video_filter/video_filter.codecs.inc,v
retrieving revision 1.3.2.18
diff -u -p -r1.3.2.18 video_filter.codecs.inc
--- video_filter.codecs.inc	22 Oct 2009 20:45:29 -0000	1.3.2.18
+++ video_filter.codecs.inc	26 Nov 2009 19:11:28 -0000
@@ -9,7 +9,8 @@ function video_filter_codec_info() {
     'sample_url' => 'http://www.youtube.com/watch?v=uN1qUeId',
     'callback' => 'video_filter_youtube',
     'regexp' => '/youtube\.com\/watch\?v=([a-z0-9\-_]+)/i',
-    'ratio' => 425 / 355,
+    'ratio' => 16 / 9,
+    'control_bar_height' => 25,
   );
   $codecs['google'] = array(
     'name' => t('Google Video'),
@@ -33,7 +34,8 @@ function video_filter_codec_info() {
     'sample_url' => 'http://www.dailymotion.com/xxxxx_some_title',
     'callback' => 'video_filter_dailymotion',
     'regexp' => '/dailymotion\.com\/.*video\/([a-z0-9]+)/i',
-    'ratio' => 420 / 336,
+    'ratio' => 4 / 3,
+    'control_bar_height' => 20,
   );
   $codecs['eyespot'] = array(
     'name' => t('Eyespot'),
@@ -54,21 +56,24 @@ function video_filter_codec_info() {
     'sample_url' => 'http://www.vimeo.com/123456',
     'callback' => 'video_filter_vimeo',
     'regexp' => '/vimeo\.com\/([0-9]+)/',
-    'ratio' => 400 / 225,
+    'ratio' => 16 / 9,
+    'control_bar_height' => 0,
   );
   $codecs['flickr_slideshows'] = array(
     'name' => t('Flickr Slideshows'),
     'sample_url' => 'http://www.flickr.com/photos/username/sets/1234567890/show/',
     'callback' => 'video_filter_flickr_slideshows',
     'regexp' => '/flickr\.com\/photos\/([a-zA-Z0-9@_\-]+)\/sets\/([0-9]+)\/?[show]?\/?/i',
-    'ratio' => 400 / 300,
+    'ratio' => 4 / 3,
+    'control_bar_height' => 0,
   );
   $codecs['flickr_video'] = array(
     'name' => t('Flickr Video'),
     'sample_url' => 'http://www.flickr.com/photos/hansnilsson/1234567890/',
     'callback' => 'video_filter_flickr_video',
     'regexp' => '/flickr\.com\/photos\/([a-zA-Z0-9@_\-]+)\/([0-9]+)/',
-    'ratio' => 400 / 226,
+    'ratio' => 4 / 3,
+    'control_bar_height' => 0,
   );
   $codecs['gamevideos'] = array(
     'name' => t('Game Videos'),
@@ -82,7 +87,8 @@ function video_filter_codec_info() {
     'sample_url' => 'http://www.metacafe.com/watch/1234567890/some_title/',
     'callback' => 'video_filter_metacafe',
     'regexp' => '/metacafe\.com\/watch\/([a-z0-9\-_]+)\/([a-z0-9\-_]+)/i',
-    'ratio' => 400 / 345,
+    'ratio' => 400 / 313,
+    'control_bar_height' => 32,
   );
   $codecs['gametrailers'] = array(
     'name' => t('Game Trailers'),
@@ -99,14 +105,16 @@ function video_filter_codec_info() {
     'sample_url' => 'http://www.collegehumor.com/video:1234567890',
     'callback' => 'video_filter_collegehumor',
     'regexp' => '/collegehumor\.com\/video\:([0-9]+)/',
-    'ratio' => 480 / 360,
+    'ratio' => 16 / 9,
+    'control_bar_height' => 0,
   );
   $codecs['myspace'] = array(
     'name' => t('MySpace'),
     'sample_url' => 'http://vids.myspace.com/index.cfm?fuseaction=vids.individual&VideoID=1234567890',
     'callback' => 'video_filter_myspace',
     'regexp' => '/vids\.myspace\.com\/.*VideoID=([0-9]+)/i',
-    'ratio' => 425 / 360,
+    'ratio' => 425 / 320,
+    'control_bar_height' => 40,
   );
   $codecs['capped'] = array(
     'name' => t('Capped'),
@@ -125,7 +133,8 @@ function video_filter_codec_info() {
                   '@blip\.tv/file/([^"\&\?/]+)@i',
                   '@blip\.tv/play/([^"\&\?/]+)@i',
                 ),
-    'ratio' => 480 / 335,
+    'ratio' => 16 / 9,
+    'control_bar_height' => 30,
   );
   $codecs['slideshare'] = array(
     'name' => t('Slideshare'),
@@ -133,7 +142,8 @@ function video_filter_codec_info() {
     'callback' => 'video_filter_slideshare',
     'instructions' => t('You need to construct your own URL, using the "Wordpress Embed" code from Slideshare, extract the "id" and "doc" parts, and form the URL like this: slideshare.net/?id=1759622&amp;doc=usingdrupal-090723103440-phpapp01.'),
     'regexp' => '/slideshare\.net\/\?id=([a-z0-9]+).*doc=([a-z0-9-]+)/',
-    'ratio' => 500 / 410,
+    'ratio' => 425 / 320,
+    'control_bar_height' => 38,
   );
   $codecs['picasa_slideshows'] = array(
     'name' => t('Picasa Slideshows'),
@@ -150,6 +160,15 @@ function video_filter_codec_info() {
     'regexp' => '/picasaweb\.google\.com\/data\/feed\/base\/user\/([a-zA-Z0-9@_\-]+)\/albumid\/([a-z0-9]+)/i',
     'ratio' => 800 / 600,
   );
+  $codecs['pornotube'] = array(
+    'name' => t('PornoTube'),
+    'sample_url' => 'http://www.pornotube.com/media.php?m=1696036',
+    'callback' => 'video_filter_pornotube',
+    'regexp' => '/pornotube\.com\/media\.php\?m=([0-9]+)/i',
+    'instructions' => t('PornoTube only supports a fix size of width: 480px and height: 400px'),
+    'ratio' => 4 / 3,
+    'control_bar_height' => 40,
+  );
 
   return $codecs;
 }
@@ -323,3 +342,11 @@ function video_filter_picasa_slideshows(
 
   return video_filter_flash($video, $params);
 }
+
+function video_filter_pornotube($video) {
+  $video['source'] = 'http://www.pornotube.com/player/v.swf?v=' . base64_encode($video['codec']['matches'][1]);
+  $video['height'] = 400;
+  $video['width'] = 480;
+
+  return video_filter_flash($video);
+}
\ No newline at end of file
Index: video_filter.module
===================================================================
RCS file: /cvs/drupal-contrib/contributions/modules/video_filter/video_filter.module,v
retrieving revision 1.12.2.10
diff -u -p -r1.12.2.10 video_filter.module
--- video_filter.module	22 Oct 2009 19:40:44 -0000	1.12.2.10
+++ video_filter.module	26 Nov 2009 19:11:28 -0000
@@ -109,27 +109,10 @@ function video_filter_process($text, $fo
 
         // Resize within width and height to given ratio
         if ($video['codec']['ratio']) {
-          // @todo - make this section prettier?
-          if (variable_get('video_filter_priority_'.$format, 'height') == 'height') {
-            if ($video['width'] * $video['codec']['ratio'] > $video['height']) {
-              $video['width'] = round($video['height'] * $video['codec']['ratio']);
-              $video['height'] = round($video['width'] / $video['codec']['ratio']);
-            }
-            else {
-              $video['height'] = round($video['width'] / $video['codec']['ratio']);
-              $video['width'] = round($video['height'] * $video['codec']['ratio']);
-            }
-          }
-          else {
-            if ($video['height'] * $video['codec']['ratio'] > $video['width']) {
-              $video['height'] = round($video['width'] / $video['codec']['ratio']);
-              $video['width'] = round($video['height'] * $video['codec']['ratio']);
-            }
-            else {
-              $video['width'] = round($video['height'] * $video['codec']['ratio']);
-              $video['height'] = round($video['width'] / $video['codec']['ratio']);
-            }
-          }
+          $control_bar_height = $video['codec']['control_bar_height'] ? $video['codec']['control_bar_height'] : 0;
+          $scale_factor = min(array(($video['height']-$control_bar_height), $video['width']/$video['codec']['ratio']));
+          $video['height'] = round($scale_factor + $control_bar_height);
+          $video['width'] = round($scale_factor * $video['codec']['ratio']);
         }
 
         $video['autoplay'] = (bool) $video['autoplay'];
@@ -177,16 +160,6 @@ function video_filter_settings($format) 
       1 => t('Yes'),
     ),
   );
-  $form['video_filter']['video_filter_priority_'.$format] = array(
-    '#type' => 'radios',
-    '#title' => t('Default priority setting'),
-    '#description' => t('Should height or width take priority when videos are re-sized to fit?'),
-    '#default_value' => variable_get('video_filter_priority_'.$format, 'height'),
-    '#options' => array(
-      height => t('Height'),
-      width => t('Width'),
-    ),
-  );
   $form['video_filter']['video_filter_related_'.$format] = array(
     '#type' => 'radios',
     '#title' => t('Related videos setting'),
