Index: video/FILE_TYPES.txt
===================================================================
--- video.orig/FILE_TYPES.txt	2007-06-28 13:35:25.000000000 -0700
+++ video/FILE_TYPES.txt	2007-06-28 13:35:39.000000000 -0700
@@ -42,7 +42,7 @@
   Then set the Flash player file name to use on the Flash settings in video module configuration page.
 
 .ogg
- Ogg Theora videos, video.module uses the java applet cortado to display Ogg Theora files, 
+ Ogg Theora videos, video.module uses the java applet cortado to display Ogg Theora files,
  you can find the latest version of cortado at http://www.flumotion.net//jar/cortado/
  get http://www.flumotion.net//jar/cortado/cortado-ovt-stripped-0.2.0.jar
  and put it into your Drupal folder as cortado.jar
Index: video/hooks.php
===================================================================
--- video.orig/hooks.php	2007-06-28 13:35:25.000000000 -0700
+++ video/hooks.php	2007-06-28 13:35:39.000000000 -0700
@@ -3,8 +3,8 @@
 
 /**
  * @file
- * The video module has some hooks which should make the adding
- * of new features to the video module easier.
+ * The video module has some hooks which should make adding
+ * new features to the video module easier.
  *
  * This file contains example of implementation and documentation for
  * all the available hooks defined in the video module.
@@ -16,12 +16,25 @@
  * Although each active module which implement a video module hooks
  * will be executed when that hook is called, if you are developing a
  * video module specific addition (a plug in) I suggest you to call your
- * module video_something and place it under your video module folder.
+ * module video_something and place it under your video module plugins folder.
  *
  * @author Fabio Varesano <fvaresano at yahoo dot it>
  */
 
 
+
+
+function hook_v_info() {};
+
+
+/**
+ * This hook is called by the video_image plugins once
+ * TODO: better documentation
+*/
+function hook_v_autothumbnail($node) {
+  ;
+}
+
 /**
 The hook_v_get_params is used by plugins to write an html param inside
 inside video generated object tag during the play.
@@ -33,3 +46,6 @@
 function hook_v_get_params(&$node) {
   return array('flashVars' => 'autostart=true&url=false');
 }
+
+
+
Index: video/includes/apiclient.inc
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ video/includes/apiclient.inc	2007-06-28 13:35:39.000000000 -0700
@@ -0,0 +1,186 @@
+<?php
+/**
+ * @file
+ * Some functions for using video hosting providers api (Youtube, Google Video, etc..)
+ * Part of this code has been inspired by the video_cck module and adapted
+ * for the video module by jyamada1
+ *
+ * @author Fabio Varesano <fvaresano at yahoo dot it>
+ */
+
+
+/**
+* When an include file requires to read an xml to receive information, such as for thumbnails,
+* this script can be used to request the xml and return it as an array.
+* Note that this is a modified function from the flickr.module, made to handle this type of
+* call more generically. also, i suspect it could be done easier (and more quickly) in php 5.
+*   @param $provider
+*     the string of the third party provider, such as 'youtube' or 'google'
+*   @param $url
+*     the url for the xml request
+*   @param $args
+*     an array of args to pass to the xml url
+*   @param $cacheable
+*     optional; if true, the result of this xml request will be cached. good to play nice w/
+*     the third party folks so they don't stop providing service to your site...
+*   @return
+*     the xml results returned as an array
+*/
+function _video_apiclient_request_xml($provider, $url, $args = array(), $cacheable = true) {
+ ksort($args);
+
+ // build an argument hash that we'll use for the cache id and api signing
+ $arghash = $provider . ':';
+ foreach($args as $k => $v){
+   $arghash .= $k . $v;
+ }
+
+ // build the url
+ foreach ($args as $k => $v){
+   $encoded_params[] = urlencode($k).'='.urlencode($v);
+ }
+ $url .= '?'. implode('&', $encoded_params);
+
+ // if it's a cachable request, try to load a cached value
+ if ($cacheable) {
+   if ($cache = cache_get($arghash, 'cache')) {
+     return unserialize($cache->data);
+   }
+ }
+
+ // connect and fetch a value
+ $result = drupal_http_request($url);
+
+ if ($result->code == 200) {
+   $parser = drupal_xml_parser_create($result->data);
+   $vals = array();
+   $index = array();
+   xml_parse_into_struct($parser, $result->data, $vals, $index);
+   xml_parser_free($parser);
+
+   $params = array();
+   $level = array();
+   $start_level = 1;
+   foreach ($vals as $xml_elem) {
+     if ($xml_elem['type'] == 'open') {
+       if (array_key_exists('attributes',$xml_elem)) {
+         list($level[$xml_elem['level']],$extra) = array_values($xml_elem['attributes']);
+       } else {
+         $level[$xml_elem['level']] = $xml_elem['tag'];
+       }
+     }
+     if ($xml_elem['type'] == 'complete') {
+       $php_stmt = '$params';
+       while($start_level < $xml_elem['level']) {
+         $php_stmt .= '[$level['.$start_level.']]';
+         $start_level ++;
+      }
+      $php_stmt .= '[$xml_elem[\'tag\']][] = $xml_elem[\'value\'];';
+      eval($php_stmt);
+      $start_level--;
+    }
+  }
+
+  // save a cacheable result for future use
+   if ($cacheable) {
+     cache_set($arghash, 'cache', serialize($params), time() + 3600);
+   }
+   return $params;
+ }
+ return array();
+}
+
+
+/**
+* this is a wrapper for _video_apiclient_request_xml that includes youtube's api key
+*/
+function _video_apiclient_youtube_request($method, $args = array(), $cacheable = TRUE) {
+ $args['dev_id'] = trim(variable_get('video_youtube_api_key', ''));
+ $args['method'] = $method;
+
+ // if we've got a secret sign the arguments
+ // TODO: doesn't seem to matter
+//  if ($secret = trim(variable_get('video_image_youtube_api_secret', ''))) {
+//    $args['api_sig'] = md5($secret . $arghash);
+//  }
+
+ return _video_apiclient_request_xml('youtube', VIDEO_IMAGE_YOUTUBE_REST_ENDPOINT, $args, $cacheable);
+}
+
+/**
+* returns the external url for a thumbnail of a specific video
+*  @param $id
+*    the youtube id of the specific video
+*  @return
+*    a URL pointing to the thumbnail
+*/
+function _video_apiclient_youtube_thumbnail($id) {
+ $request = _video_apiclient_youtube_request('youtube.videos.get_details', array('video_id' => $id));
+ $tn = $request['THUMBNAIL_URL'][0];
+ return $tn;
+}
+
+
+/** Google **/
+
+define('VIDEO_IMAGE_GOOGLE_XML', 'http://video.google.com/videofeed');
+
+function _video_apiclient_google_request($embed, $cacheable = TRUE) {
+ $args = array('docid' => $embed);
+ return _video_apiclient_request_xml('google', VIDEO_IMAGE_GOOGLE_XML, $args, $cacheable);
+}
+
+function _video_apiclient_google_thumbnail($id) {
+ // strip "google:" prefix
+ $id = substr($id, 7);
+ $xml = _video_apiclient_google_request($id);
+
+ // we *should* be able to use media:thumbnail
+ // but unfortunately, that is stripped out from the request hook
+ // so instead, we'll parse it from the description, where it's repeated.
+ // TODO: look into how to fix this...
+ $desc = $xml['ITEM']['DESCRIPTION'][0];
+ $regex = '@<img src="([^"]*)"@';
+ if (preg_match($regex, $desc, $matches)) {
+   return $matches[1];
+ }
+ return NULL;
+}
+
+
+/**
+* Create a file object from thumbnail images from providers
+*  to allow for automatic thumbnailing of videos from providers
+*  @param $node
+*    the video node being called
+*  @return
+*    a file object containing the thumbnail file
+*/
+function _video_apiclient_provider_auto_thumbnail($node) {
+ // get thumbnail url
+ if(_video_get_filetype($node->vidfile) == 'youtube') {
+   $thumbnail = _video_apiclient_youtube_thumbnail($node->vidfile);
+ }
+ else {
+   $thumbnail = _video_apiclient_google_thumbnail($node->vidfile);
+ }
+
+ // save image to temp directory for processing
+ $image = image_gd_open($thumbnail, 'jpeg');
+ $location = file_directory_temp() .'/'. $node->vidfile .'.jpg';
+ image_gd_close($image, $location, 'jpeg');
+
+
+ // get info and build a file object
+ $filepath = file_create_path($location, file_directory_temp());
+ $info = image_get_info($filepath);
+
+ $file = new stdClass();
+ $file->filepath = realpath($filepath);
+ $file->filename = basename($file->filepath);
+ $file->filesize = $info['file_size'];
+ $file->filemime = $info['mime_type'];
+
+ return $file;
+}
+
Index: video/includes/common.inc
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ video/includes/common.inc	2007-06-28 13:35:39.000000000 -0700
@@ -0,0 +1,420 @@
+<?php
+// $Id:  $
+
+/**
+ * @file
+ * Add some common functions for the various video types supported
+ *
+ * @author Fabio Varesano <fvaresano at yahoo dot it>
+ */
+
+
+
+
+
+/**
+ * Get the object for the suitable player for the parameter resource
+*/
+function _video_common_get_player($node) {
+  switch (_video_get_filetype($node->vidfile)) {
+    case 'divx':
+      return theme('video_play_divx', $node);
+    case 'mov':
+    case 'mp4':
+    case '3gp':
+    case '3g2':
+      return theme('video_play_quicktime', $node);
+    case 'rm':
+      return theme('video_play_realmedia', $node);
+    case 'flv':
+      return theme('video_play_flash', $node);
+    case 'swf':
+      return theme('video_play_swf', $node);
+    case 'dir':
+    case 'dcr':
+      return theme('video_play_dcr', $node);
+    case 'asf':
+    case 'wmv':
+      return theme('video_play_windowsmedia', $node);
+    case 'ogg':
+      return theme('video_play_ogg_theora', $node);
+    case 'youtube':
+      return theme('video_play_youtube', $node);
+    case 'googlevideo':
+      return theme('video_play_googlevideo', $node);
+    default:
+      drupal_set_message('Video type not supported', 'error');
+      if(!variable_get('video_playinbody', 1)) {
+        drupal_goto("node/$node->nid");
+      }
+      break;
+  }
+}
+
+/*********************************************************************
+ * Themeable functions for playing videos. They print a page with a player embedded.
+ *********************************************************************/
+
+ /**
+ * Play videos from in FLV Flash video format
+ *
+ * @param $node
+ *   object with node information
+ *
+ * @return
+ *   string of content to display
+ */
+function theme_video_play_flash($node) {
+  $loader_location = variable_get('video_flvplayerloader', 'FlowPlayer.swf');
+
+  $url = _video_get_fileurl($node->vidfile);
+  $file = basename($url);
+  $base_url = substr($url, 0, strrpos($url, '/'));
+
+  $height = $node->videoy + 24; // add commands height
+
+  // this will be executed by not Internet Explorer browsers
+  $output = '<!--[if !IE]> <-->
+<object type="application/x-shockwave-flash" width="'. $node->videox .'" height="'. $height .'"
+data="'. url() . check_plain($loader_location) .'">
+<!--> <![endif]-->' . "\n";
+
+  // this will be executed by Internet Explorer
+  $output .= '<!--[if IE]>
+<object type="application/x-shockwave-flash" width="'. $node->videox .'" height="'. $height .'"
+classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
+codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0">
+<![endif]-->' . "\n";
+
+  // params will be passed to both IE or not IE browsers
+  $output .= '<param name="movie" value="' . url() . check_plain($loader_location) . '" />
+               <param name="allowScriptAccess" value="sameDomain" />
+               <param name="quality" value="high" />
+               <param name="flashvars" value="config={baseURL:\''. $base_url .'\',videoFile:\''. $file .'\',autoPlay:true,bufferLength:5}" />' . "\n"
+  . _video_get_parameters($node) .
+  '<p>'. t('Your browser is not able to display this multimedia content.') .'</p>
+</object>';
+
+  $output = _theme_video_format_play($output, t('http://www.macromedia.com/go/getflashplayer'),
+                                      t('Link to Macromedia Flash Player Download Page'),
+                                      t('Download latest Flash Player'));
+   return $output;
+}
+
+/**
+ * Play Flash .swf files.
+ *
+ * @param $node
+ *   object with node information
+ *
+ * @return
+ *   string of content to display
+ */
+function theme_video_play_swf($node) {
+
+  $url = _video_get_fileurl($node->vidfile);
+
+  // this will be executed by not Internet Explorer browsers
+  $output = '<!--[if !IE]> <-->
+<object type="application/x-shockwave-flash" width="'. $node->videox .'" height="'. $node->videoy .'"
+data="'. $url .'">
+<!--> <![endif]-->' . "\n";
+
+  // this will be executed by Internet Explorer
+  $output .= '<!--[if IE]>
+<object type="application/x-shockwave-flash" width="'. $node->videox .'" height="'. $node->videoy .'"
+classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
+codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0">
+<![endif]-->' . "\n";
+
+  // params will be passed to both IE or not IE browsers
+  $output .= '<param name="movie" value="'. $url .'" />' . "\n"
+  . _video_get_parameters($node) .
+  '<p>'. t('Your browser is not able to display this multimedia content.') .'</p>
+</object>';
+
+  $output = _theme_video_format_play($output, t('http://www.macromedia.com/go/getflashplayer'), t('Link to Flash player download'), t('Download the latest Flash player'));
+  return $output;
+}
+
+
+
+/**
+ * Play Director .dcr/.dir files.
+ *
+ * @param $node
+ *   object with node information
+ *
+ * @return
+ *   string of content to display
+ */
+
+function theme_video_play_dcr($node) {
+
+  $url = _video_get_fileurl($node->vidfile);
+
+  // this will be executed by not Internet Explorer browsers
+  $output = '<!--[if !IE]> <-->
+<object type="application/x-director" width="'. $node->videox .'" height="'. $node->videoy .'"
+data="'. $url .'">
+<!--> <![endif]-->' . "\n";
+
+  // this will be executed by Internet Explorer
+  $output .= '<!--[if IE]>
+<object type="application/x-director" width="'. $node->videox .'" height="'. $node->videoy .'"
+classid="clsid:166B1BCA-3F9C-11CF-8075-444553540000"
+codebase="http://download.macromedia.com/pub/shockwave/cabs/director/sw.cab#version=10,0,0,0">
+<![endif]-->' . "\n";
+
+// params will be passed to both IE or not IE browsers
+  $output .= '<param name="src" value="'. $url .'" />' . "\n"
+  . _video_get_parameters($node) .
+  '<p>'. t('Your browser is not able to display this multimedia content.') .'</p>
+</object>';
+
+  $output = _theme_video_format_play($output, t('http://www.macromedia.com/shockwave/download/'),
+                                      t('Link to Macromedia Shockwave Player Download Page'),
+                                      t('Download latest Shockwave Player'));
+   return $output;
+}
+
+/**
+ * Play videos from in DivX format
+ *
+ * @see http://developer.apple.com/internet/ieembedprep.html
+ * @param $node
+ *   object with node information
+ *
+ * @return
+ *   string of content to display
+ */
+function theme_video_play_divx($node) {
+  //Increase the height to accommodate the player controls on the bottom.
+  $height = $node->videoy + 20;
+
+  $url = _video_get_fileurl($node->vidfile);
+
+  $output = '<!-- [if IE] -->
+<object classid="clsid:67DABFBF-D0AB-41fa-9C46-CC0F21721616" width="'.$node->videox.'" height="'.$height.'" codebase="http://go.divx.com/plugin/DivXBrowserPlugin.cab">
+<!--> <![endif]-->'. "\n";
+  // this will be executed by not Internet Explorer browsers
+  $output = '<!-- [if !IE] -->
+<object type="video/divx" data="'.$url.'" width="'.$node->videox.'" height="'.$height.'" mode="zero">
+<!--> <![endif]-->'."\n";
+
+   $output .= '<param name="src" value="'.$url.'"/>'."\n";
+  $output .= '<param name="mode" value="zero"/>'."\n";
+  $output .= '</object>';
+  $output = _theme_video_format_play($output,t('http://www.divx.com/divx/webplayer/'),
+                                     t('Link to DivX Download Page'),
+                                     t('Download latest DivX Web Player'));
+  return $output;
+}
+
+/**
+ * Play videos from in Quicktime format
+ *
+ * @see http://developer.apple.com/internet/ieembedprep.html
+ * @param $node
+ *   object with node information
+ *
+ * @return
+ *   string of content to display
+ */
+function theme_video_play_quicktime($node) {
+  //Increase the height to accommodate the player controls on the bottom.
+  $height = $node->videoy + 16;
+
+  $url = _video_get_fileurl($node->vidfile);
+
+
+  // this will be executed by not Internet Explorer browsers
+  $output = '<!--[if !IE]> <-->
+<object type="video/quicktime" width="'. $node->videox .'" height="'. $height .'"
+data="'. $url .'">
+<!--> <![endif]-->' . "\n";
+
+  // this will be executed by Internet Explorer
+  $output .= '<!--[if IE]>
+<object classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" codebase="http://www.apple.com/qtactivex/qtplugin.cab" width="'. $node->videox .'" height="'. $height .'" scale="tofit" >
+<![endif]-->' . "\n";
+
+  // params will be passed to both IE or not IE browsers
+   $output .= '<param name="src" value="'. $url .'" />
+              <param name="AUTOPLAY" value="true" />
+              <param name="KIOSKMODE" value="false" />' . "\n"
+   . _video_get_parameters($node) .
+   '<p>'. t('Your browser is not able to display this multimedia content.') .'</p>
+</object>'; // only one </object> needed becouse only one opening tag has been parsed by browsers
+
+
+  /*
+  $output = '<script language="JavaScript" type="text/javascript">';
+  $output .= "InsertQuicktimeVideo('{$node->vidfile}','$height','{$node->videox}');";
+  $output .= '</script>';
+  */
+
+
+  $output = _theme_video_format_play($output, t('http://www.apple.com/quicktime/download'),
+                                      t('Link to QuickTime Download Page'),
+                                      t('Download latest Quicktime Player'));
+  return $output;
+}
+
+/**
+ * Play videos from in Realmedia format
+ *
+ * @param $node
+ *   object with node information
+ *
+ * @return
+ *   string of content to display
+ */
+function theme_video_play_realmedia($node) {
+  // Real's embeded player includes the controls
+  // in the height
+  $node->videoy += 40;
+
+  $url = _video_get_fileurl($node->vidfile);
+
+  // this will be executed by not Internet Explorer browsers
+  $output = '<!--[if !IE]> <-->
+<object type="audio/x-pn-realaudio-plugin" width="'. $node->videox .'" height="'. $node->videoy .'"
+data="'. $url .'">
+<!--> <![endif]-->' . "\n";
+
+  // this will be executed by Internet Explorer
+  $output .= '<!--[if IE]>
+<object type="audio/x-pn-realaudio-plugin" width="'. $node->videox .'" height="'. $node->videoy .'"
+classid="clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA" >
+<![endif]-->' . "\n";
+
+  // params will be passed to both IE or not IE browsers
+   $output .= '<param name="src" value="'. $url .'" />
+              <param name="_ExtentX" value="7276" />
+              <param name="" value="3307" />
+              <param name="AUTOSTART" value="true" />
+              <param name="SHUFFLE" value="0" />
+              <param name="PREFETCH" value="0" />
+              <param name="NOLABELS" value="0" />
+              <param name="CONTROLS" value="All" />
+              <param name="CONSOLE" value="Clip1" />
+              <param name="LOOP" value="0" />
+              <param name="NUMLOOP" value="0" />
+              <param name="CENTER" value="0" />
+              <param name="MAINTAINASPECT" value="1" />
+              <param name="BACKGROUNDCOLOR" value="#000000" />'
+   . _video_get_parameters($node) .
+   '<p>'. t('Your browser is not able to display this multimedia content.') .'</p>
+</object>'; // only one </object> needed becouse only one opening tag has been parsed by browsers
+
+
+  $output = _theme_video_format_play($output, t('http://www.real.com/'),
+                                      t('Link to Real'),
+                                      t('Download latest Realmedia Player'));
+  return $output;
+}
+
+/**
+ * Play videos from in WindowsMediaVideo format
+ *
+ * @param $node
+ *   object with node information
+ *
+ * @return
+ *   string of content to display
+ */
+function theme_video_play_windowsmedia($node) {
+  // Windows Media's embeded player includes the controls in the height
+  $node->videoy += 68;
+  $url = _video_get_fileurl($node->vidfile);
+
+  // this will be executed by not Internet Explorer browsers
+  $output = '<!--[if !IE]> <-->
+<object type="application/x-mplayer2" width="'. $node->videox .'" height="'. $node->videoy .'"
+data="'. $url .'">
+<!--> <![endif]-->' . "\n";
+
+  // this will be executed by Internet Explorer
+  $output .= '<!--[if IE]>
+<object type="application/x-oleobject" width="'. $node->videox .'" height="'. $node->videoy .'"
+classid="clsid:6BF52A52-394A-11d3-B153-00C04F79FAA6" >
+<![endif]-->' . "\n";
+
+  // params will be passed to both IE or not IE browsers
+   $output .= '<param name="src" value="'. $url .'" />
+              <param name="URL" value="'.$url.'" />
+              <param name="animationatStart" value="true" />
+              <param name="transparentatStart" value="true" />
+              <param name="autoStart" value="true" />
+              <param name="showControls" value="true" />
+              <param name="loop" value="true" />'
+   . _video_get_parameters($node) .
+   '<p>'. t('Your browser is not able to display this multimedia content.') .'</p>
+</object>'; // only one </object> needed becouse only one opening tag has been parsed by browsers
+
+
+  $output = _theme_video_format_play($output, t('http://windowsupdate.microsoft.com/'),
+                                      t('Link to Windows Update'),
+                                      t('Download latest Windows Media Player'));
+  return $output;
+}
+
+
+
+
+/**
+ * Play Ogg Theora videos with Cortado Applet
+ *
+ * @param $node
+ *   object with node information
+ *
+ * @return
+ *   string of content to display
+ */
+function theme_video_play_ogg_theora($node) {
+  global $base_url;
+  $cortado_location = variable_get('video_cortado', $base_url . '/cortado.jar');
+  $url = _video_get_fileurl($node->vidfile);
+
+  $width = ($node->videox ? $node->videox : '425');
+  $height = ($node->videoy ? $node->videoy : '350');
+
+  $output = '
+  <!--[if !IE]>-->
+  <object classid="java:com.fluendo.player.Cortado.class"
+          type="application/x-java-applet"
+          archive="' . $cortado_location . '"
+          width="' . $width . '" height="' . $height . '" >
+  <!--<![endif]-->
+    <object classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93"
+              codebase="http://java.sun.com/update/1.5.0/jinstall-1_5_0-windows-i586.cab"
+              width="' . $width . '" height="' . $height . '" >
+        <param name="code" value="com.fluendo.player.Cortado" />
+    <!--[if !IE]>-->
+    </object>
+    <!--<![endif]-->
+      <!-- IE and Konqueror browser need the archive param -->
+      <param name="archive" value="' . $cortado_location . '" />
+      <param name="url" value="' . $url . '"/>
+      <param name="local" value="false" />
+      <param name="keepaspect" value="true" />
+      <param name="video" value="true" />
+      <param name="audio" value="true" />
+      <param name="seekable" value="true" />
+      <param name="duration" value="' . $node->playtime_seconds . '" />
+      <param name="bufferSize" value="200" />
+      <strong>
+          This browser does not have a Java Plug-in.<br />
+          <a href="http://java.com/download/">
+            Get the latest Java Plug-in here.
+          </a>
+      </strong>
+  </object>
+  ';
+
+  $output = _theme_video_format_play($output,
+    t('http://java.com/download/'), t('Link to java.com'), t('Download Java'));
+  return $output;
+}
+
Index: video/plugins/video_customfields/video_customfields.module
===================================================================
--- video.orig/plugins/video_customfields/video_customfields.module	2007-06-28 13:35:25.000000000 -0700
+++ video/plugins/video_customfields/video_customfields.module	2007-06-28 13:35:39.000000000 -0700
@@ -117,19 +117,19 @@
  * Fields will be displayed only if field title is set on settings page.
  */
 function video_customfields_form_alter($form_id, &$form) {
-  
+
   if($form_id == 'video_node_form' && isset($form['video']) && user_access('insert custom fields')) {
 
     //get node object from form
     $node = $form['#node'];
-    
+
     $title1 = variable_get('video_customfield1', '');
     $title2 = variable_get('video_customfield2', '');
     $title3 = variable_get('video_customfield3', '');
     $title4 = variable_get('video_customfield4', '');
     $title5 = variable_get('video_customfield5', '');
     $title6 = variable_get('video_customfield6', '');
-   
+
     //Only display the custom fields group if atleast one field has a title.
     if ($title1 . $title2 . $title3 . $title4 . $title5 . $title6 != '') {
       $form['customfields'] = array('#type' => 'fieldset', '#title' => variable_get('video_customfieldtitle', 'Custom Fields'), '#collapsible' => TRUE, '#collapsed' => variable_get('video_customgroupcollapsed', FALSE), '#weight' => -17);
Index: video/plugins/video_ffmpeg_helper/video_ffmpeg_helper.module
===================================================================
--- video.orig/plugins/video_ffmpeg_helper/video_ffmpeg_helper.module	2007-06-28 13:35:25.000000000 -0700
+++ video/plugins/video_ffmpeg_helper/video_ffmpeg_helper.module	2007-06-28 13:35:39.000000000 -0700
@@ -56,15 +56,15 @@
       $test = 'file_exists';
     }
     if (!$test($form_values['video_ffmpeg_helper_ffmpeg_path'])) {
-      form_set_error('video_image_ffmpeg_path', t('Set correct path for thumbnailer'));
+      form_set_error('video_ffmpeg_helper_ffmpeg_path', t('Set correct path for ffmpeg'));
     }
     if (!is_numeric($form_values['video_ffmpeg_helper_auto_thumbnail_seek'])) {
       form_set_error('video_ffmpeg_helper_auto_thumbnail_seek', t('Seek time must be an integer'));
     }
-	$options = $form_values['video_ffmpeg_helper_thumbnailer_options'];
-	if (!strstr($options, '%videofile') || !strstr($options, '%thumbfile')) {
-	  form_set_error('video_ffmpeg_helper_thumbnailer_options', t('Thumbnail options must contain mandatory arguments %videofile and %thumbfile'));
-	}
+  $options = $form_values['video_ffmpeg_helper_thumbnailer_options'];
+  if (!strstr($options, '%videofile') || !strstr($options, '%thumbfile')) {
+    form_set_error('video_ffmpeg_helper_thumbnailer_options', t('Thumbnail options must contain mandatory arguments %videofile and %thumbfile'));
+  }
   }
 }
 
@@ -80,29 +80,29 @@
       db_query("UPDATE {system} SET weight=".($upload_weight+1)." WHERE name='video_ffmpeg_helper'");
     }
   }
-  
+
   $form['video_ffmpeg_helper_ffmpeg_path'] = array(
     '#type' => 'textfield',
     '#title' => t('FFmpeg executable path'),
     '#description' => t('Set the full path to the ffmpeg executable here.'),
     '#default_value' => variable_get('video_ffmpeg_helper_ffmpeg_path', '/usr/bin/ffmpeg'),
   );
-  
-  
+
+
   $form['video_ffmpeg_helper_auto_resolution'] = array(
     '#type' => 'checkbox',
     '#title' => t('Enable resolution helper'),
     '#description' => t('Use ffmpeg Helper to automaticcally get the resolution from the video.'),
     '#default_value' => variable_get('video_ffmpeg_helper_auto_resolution', false),
   );
-  
+
   $form['video_ffmpeg_helper_auto_playtime'] = array(
     '#type' => 'checkbox',
     '#title' => t('Enable playtime helper'),
     '#description' => t('Use ffmpeg Helper to automaticcally get the playtime from the video.'),
     '#default_value' => variable_get('video_ffmpeg_helper_auto_playtime', false),
   );
-  
+
   $form['autothumb'] = array(
           '#type' => 'fieldset',
           '#title' => t('Automatic video thumbnailing'),
@@ -139,7 +139,7 @@
       '#title' => t('Debug auto-thumbnail process'),
       '#default_value' => variable_get('video_ffmpeg_helper_auto_thumbnail_debug', false),
     );
-  
+
   // automatic video conversion settings
   $form['autoconv'] = array(
           '#type' => 'fieldset',
@@ -221,12 +221,12 @@
         $form['image'] = NULL;
       }
     }
-    
+
     if(variable_get('video_ffmpeg_helper_auto_resolution', false) || variable_get('video_ffmpeg_helper_auto_convert', false)) {
       $form['video']['videox'] = NULL;
       $form['video']['videoy'] = NULL;
     }
-    
+
     if(variable_get('video_ffmpeg_helper_auto_playtime', false)) {
       $form['video']['playtime'] = NULL;
     }
@@ -240,27 +240,27 @@
  */
 function video_ffmpeg_helper_nodeapi(&$node, $op, $teaser) {
   if($node->type == 'video') {
-    
+
     switch ($op) {
-      case 'load': 
+      case 'load':
         ; // for future uses
         break;
-        
+
       case 'submit':
         if(variable_get('video_ffmpeg_helper_auto_resolution', false) || variable_get('video_ffmpeg_helper_auto_playtime', false)) {
           _video_ffmpeg_helper_get_video_info($node);
         }
-        
+
         break;
-        
+
       case 'insert':
         if(variable_get('video_ffmpeg_helper_auto_conversion', false)) {
           // add rendering job to queue
           _video_ffmpeg_helper_add_rendering($node);
         }
-        
+
         break;
-        
+
       case 'prepare':
         ; // for future uses
       break;
@@ -268,11 +268,11 @@
       case 'view':
         ; // for future uses
         break;
-        
+
       case 'delete':
         db_query('DELETE FROM {video_rendering} WHERE vid = %d AND nid = %d', $node->vid, $node->nid);
         break;
-        
+
     }
   }
 }
@@ -285,11 +285,11 @@
   $file = $_SESSION['video_upload_file_stored']->filepath;
   //print_r($node); die;
   db_query('INSERT INTO {video_rendering} (vid, nid, origfile, pid, status, started, completed) VALUES (%d, %d, "%s", %d, %d, %d, %d)', $node->vid, $node->nid, $file, 0, VIDEO_RENDERING_PENDING, 0, 0);
-  
+
   // let's add the rendering in progress video
   $node->vidfile = variable_get('video_ffmpeg_helper_auto_cvr_busy_video_path', 'busy.flv');
   db_query('UPDATE {video} SET vidfile = "%s" WHERE nid=%d AND vid=%d', $node->vidfile, $node->nid, $node->vid);
-  
+
 }
 
 
@@ -299,55 +299,59 @@
 */
 function _video_ffmpeg_helper_get_video_info(&$node) {
 
-  // escape file name for safety
-  $file = escapeshellarg($_SESSION['video_upload_file']->filepath);
-  // create the full command to execute
-  $command = variable_get('video_ffmpeg_helper_ffmpeg_path', '/usr/bin/ffmpeg') . ' -i ' . $file;
-  
-  drupal_set_message('executing' . $command);
-  
-  //execute the command
-  ob_start();
-  passthru($command." 2>&1", $command_return);
-  $command_output = ob_get_contents();
-  ob_end_clean();
-  
-  // print $command_output;
-  
-  if(variable_get('video_ffmpeg_helper_auto_resolution', false)) {
-    // get resolution
-    $pattern = '/[0-9]{2,4}x[0-9]{2,4}/';
-    preg_match_all($pattern, $command_output, $matches, PREG_PATTERN_ORDER);
-    $resolution = $matches[0][0];
-    $xy = explode("x", $resolution);
-    
-    // store resolution information to the node object
-    $node->videox = $xy[0];
-    $node->videoy = $xy[1];
-  }
-  
-  
-  if(variable_get('video_ffmpeg_helper_auto_playtime', false)) {
-    // get playtime
-    $pattern = '/[0-9]{2}:[0-9]{2}:[0-9]{2}\.[0-9]/';
-    preg_match_all($pattern, $command_output, $matches, PREG_PATTERN_ORDER);
-    $playtime = $matches[0][0];
-    
-    // ffmpge return lenght as 00:00:31.1 Let's get playtime from that
-    $hmsmm = explode(":", $playtime);
-    
-    $tmp = explode(".", $hmsmm[2]);
-    $seconds = $tmp[0];
-    
-    $hours = $hmsmm[0];
-    $minutes = $hmsmm[1];
-    
-    $node->playtime_seconds = $seconds + ($hours * 3600) + ($minutes * 60);
+  //print_r($node); die;
+  if($node->new_video_upload_file_fid && (variable_get('video_ffmpeg_helper_auto_resolution', false) || variable_get('video_ffmpeg_helper_auto_playtime', false))) { // we have a new file
+
+    $fileobj = _video_upload_get_file($node->new_video_upload_file_fid);
+
+    // escape file name for safety
+    $file = escapeshellarg($fileobj->filepath);
+    // create the full command to execute
+    $command = variable_get('video_ffmpeg_helper_ffmpeg_path', '/usr/bin/ffmpeg') . ' -i ' . $file;
+
+    drupal_set_message('executing' . $command);
+
+    //execute the command
+    ob_start();
+    passthru($command." 2>&1", $command_return);
+    $command_output = ob_get_contents();
+    ob_end_clean();
+
+    // print $command_output;
+
+    if(variable_get('video_ffmpeg_helper_auto_resolution', false)) {
+      // get resolution
+      $pattern = '/[0-9]{2,4}x[0-9]{2,4}/';
+      preg_match_all($pattern, $command_output, $matches, PREG_PATTERN_ORDER);
+      $resolution = $matches[0][0];
+      $xy = explode("x", $resolution);
+
+      // store resolution information to the node object
+      $node->videox = $xy[0];
+      $node->videoy = $xy[1];
+    }
+
 
+    if(variable_get('video_ffmpeg_helper_auto_playtime', false)) {
+      // get playtime
+      $pattern = '/[0-9]{2}:[0-9]{2}:[0-9]{2}\.[0-9]/';
+      preg_match_all($pattern, $command_output, $matches, PREG_PATTERN_ORDER);
+      $playtime = $matches[0][0];
+
+      // ffmpge return lenght as 00:00:31.1 Let's get playtime from that
+      $hmsmm = explode(":", $playtime);
+
+      $tmp = explode(".", $hmsmm[2]);
+      $seconds = $tmp[0];
+
+      $hours = $hmsmm[0];
+      $minutes = $hmsmm[1];
+
+      $node->playtime_seconds = $seconds + ($hours * 3600) + ($minutes * 60);
+
+    }
   }
-  
-  //print_r($node); die;
-  
+
 }
 
 
Index: video/plugins/video_ffmpeg_helper/video_render.php
===================================================================
--- video.orig/plugins/video_ffmpeg_helper/video_render.php	2007-06-28 13:35:25.000000000 -0700
+++ video/plugins/video_ffmpeg_helper/video_render.php	2007-06-28 13:35:39.000000000 -0700
@@ -19,7 +19,7 @@
 
 // set to the temp file path.
 //IMPORTANT: the user who runs this script must have permissions to create files there. If this is not the case the default php temporary folder will be used.
-define('VIDEO_RENDERING_TEMP_PATH', '/tmp/video'); 
+define('VIDEO_RENDERING_TEMP_PATH', '/tmp/video');
 
 // number of conversion jobs active at the same time
 define('VIDEO_RENDERING_FFMPEG_INSTANCES', 5);
@@ -68,7 +68,7 @@
 print("\n");
 
 function video_render_main() {
-  
+
   // set the status to active
   _video_render_job_change_status($_SERVER['argv'][1], $_SERVER['argv'][2], VIDEO_RENDERING_ACTIVE);
   $job = _video_render_load_job($_SERVER['argv'][1], $_SERVER['argv'][2], VIDEO_RENDERING_ACTIVE);
@@ -78,18 +78,18 @@
     die;
   }
   $command = _video_render_get_command($job);
-  
+
   //print('executing ' . $command);
   watchdog('video_render', t('executing: ') . $command);
-  
+
   //execute the command
   ob_start();
   passthru($command." 2>&1", $command_return);
   $command_output = ob_get_contents();
   ob_end_clean();
-  
+
   //print $command_output;
-  
+
   if (!file_exists($job->convfile)) {
     watchdog('video_render', t('video conversion failed. ffmpeg reported the following output: ' . $command_output, WATCHDOG_ERROR));
   }
@@ -112,14 +112,14 @@
       $file->fid = db_next_id('{files}_fid');
       //print_r($file);
       db_query("INSERT INTO {files} (fid, nid, filename, filepath, filemime, filesize) VALUES (%d, %d, '%s', '%s', '%s', %d)", $file->fid, $job->nid, $file->filename, $file->filepath, $file->filemime, $file->filesize);
-      
+
       db_query("INSERT INTO {file_revisions} (fid, vid, list, description) VALUES (%d, %d, %d, '%s')", $file->fid, $job->vid, $file->list, $file->description);
-      
+
       // set vidfile to "" to let video_upload overwrite it with the latest uploaded file
       db_query('UPDATE {video} SET vidfile = "%s", videox = %d, videoy = %d WHERE nid=%d AND vid=%d', "", $job->calculatedx, $job->calculatedy, $job->nid, $job->vid);
-      
+
       _video_render_job_change_status($job->nid, $job->vid, VIDEO_RENDERING_COMPLETE);
-      
+
       // delete the vile
       unlink($job->convfile);
     }
@@ -140,14 +140,14 @@
   $audiobitrate = variable_get('video_ffmpeg_helper_auto_cvr_audio_bitrate', 64);
   $videobitrate = variable_get('video_ffmpeg_helper_auto_cvr_video_bitrate', 200);
   $size = _video_render_get_size($job);
-  
+
 
   $converter = VIDEO_RENDERING_FFMPEG_PATH;
   $options = preg_replace(array('/%videofile/', '/%convertfile/', '/%audiobitrate/', '/%size/', '/%videobitrate/'), array($videofile, $convfile, $audiobitrate, $size, $videobitrate), variable_get('video_ffmpeg_helper_auto_cvr_options', '-y -i %videofile -f flv -ar 22050 -ab %audiobitrate -s %size -b %videobitrate %convertfile'));
-  
+
   // set to the converted file output
   $job->convfile = $convfile;
-  
+
   return VIDEO_RENDERING_NICE . " $converter $options";
 }
 
@@ -162,7 +162,7 @@
 
   $height = $def_width * ($job->videoy / $job->videox); // do you remember proportions?? :-)
 
-    
+
   $height = round($height);
   // add one if odd
   if($height % 2) {
@@ -181,7 +181,7 @@
 */
 function _video_render_load_job($nid, $vid, $status) {
   $result = db_query('SELECT * FROM {video_rendering} vr INNER JOIN {node} n ON vr.vid = n.vid INNER JOIN {video} v ON n.vid = v.vid WHERE n.nid = v.nid AND vr.nid = n.nid AND vr.status = %d AND n.nid = %d AND n.vid = %d', $status, $nid, $vid);
-  
+
   return db_fetch_object($result);
 }
 
Index: video/plugins/video_ffmpeg_helper/video_scheduler.php
===================================================================
--- video.orig/plugins/video_ffmpeg_helper/video_scheduler.php	2007-06-28 13:35:25.000000000 -0700
+++ video/plugins/video_ffmpeg_helper/video_scheduler.php	2007-06-28 13:35:39.000000000 -0700
@@ -7,8 +7,8 @@
  *
  * @author Fabio Varesano <fvaresano at yahoo dot it>
  */
- 
- 
+
+
 /**
  * video_scheduler.php configuration
 */
@@ -18,7 +18,7 @@
 
 // set to the temp file path.
 //IMPORTANT: the user who runs this script must have permissions to create files there. If this is not the case the default php temporary folder will be used.
-define('VIDEO_RENDERING_TEMP_PATH', '/tmp/video'); 
+define('VIDEO_RENDERING_TEMP_PATH', '/tmp/video');
 
 // number of conversion jobs active at the same time
 define('VIDEO_RENDERING_FFMPEG_INSTANCES', 5);
@@ -60,7 +60,7 @@
  * Main for video_scheduler.php
 */
 function video_scheduler_main() {
-  
+
   if($jobs = video_scheduler_select()) {
     foreach ($jobs as $job) {
       video_scheduler_start($job);
@@ -88,9 +88,9 @@
 function video_scheduler_select() {
 
   $result = db_query('SELECT * FROM {video_rendering} vr INNER JOIN {node} n ON vr.vid = n.vid INNER JOIN {video} v ON n.vid = v.vid WHERE n.nid = v.nid AND vr.nid = n.nid AND vr.status = %d ORDER BY n.created', VIDEO_RENDERING_PENDING);
-  
+
   // TODO: order jobs by priority
-  
+
   $jobs = array();
   $i = 0;
   $count = db_num_rows($result);
@@ -98,7 +98,7 @@
     $jobs[] = db_fetch_object($result);
     $i++;
   }
-  
+
   return $jobs;
 }
 
Index: video/plugins/video_image/video_image.module
===================================================================
--- video.orig/plugins/video_image/video_image.module	2007-06-28 13:35:25.000000000 -0700
+++ video/plugins/video_image/video_image.module	2007-06-28 13:35:39.000000000 -0700
@@ -61,7 +61,7 @@
       '#title' => t('Promote the thumbnails to the front page'),
       '#default_value' => _video_image_promote_thumbnails(),
     );
-    
+
   return system_settings_form($form);
 }
 
@@ -80,9 +80,9 @@
       _image_check_settings();
       $form['#attributes'] = array("enctype" => "multipart/form-data");
 
-     
+
       $form['image'] = array('#type' => 'fieldset', '#title' => t('Image thumbnails'), '#collapsible' => TRUE, '#collapsed' => TRUE, '#weight' => -17, '#description' => t('Use this form to upload an image.'));
-      
+
       $form['image']['image'] = array('#type' => 'file', '#title' => t('Image'));
       $form['image']['image_title'] = array('#type' => 'textfield', '#title' => t('Image title'), '#default_value' => $node->image->image_title);
     }
@@ -97,7 +97,7 @@
 function video_image_nodeapi(&$node, $op, $teaser) {
   if($node->type == 'video') {
     switch ($op) {
-      case 'load': 
+      case 'load':
         $output['iid'] = $node->serial_data['iid'];
         return $output;
       case 'submit':
@@ -125,10 +125,10 @@
           if (!form_get_errors()) {
             $image = node_submit($image);
             node_save($image);
-            
+
             // needed to set the correct status and promote values if the user does not have enought permissions. Is there a better solution???
-            db_query('UPDATE {node} SET status = %d, promote = %d WHERE nid = %d AND vid = %d', _video_image_publish_thumbnails(), _video_image_promote_thumbnails(), $image->nid, $image->vid); 
-            
+            db_query('UPDATE {node} SET status = %d, promote = %d WHERE nid = %d AND vid = %d', _video_image_publish_thumbnails(), _video_image_promote_thumbnails(), $image->nid, $image->vid);
+
             $node->iid = $node->serial_data['iid'] = $image->nid;
             $_SESSION['video_upload_file']->iid = $image->nid;
             $node->new_image = TRUE;
@@ -137,7 +137,7 @@
         else if (isset($_SESSION['video_upload_file']->iid)) {
           $node->iid = $_SESSION['video_upload_file']->iid;
         }
-      
+
         $node->serial_data['iid'] = $node->iid;
       break;
       case 'prepare':
Index: video/plugins/video_multidownload/video_multidownload.module
===================================================================
--- video.orig/plugins/video_multidownload/video_multidownload.module	2007-06-28 13:35:25.000000000 -0700
+++ video/plugins/video_multidownload/video_multidownload.module	2007-06-28 13:35:39.000000000 -0700
@@ -47,8 +47,8 @@
       if ($node = node_load(arg(1)) and $node->type == 'video') {
         if(isset($node->disable_multidownload) &&
            !$node->disable_multidownload &&
-			  ($node->use_play_folder || $node->download_folder!='')
-	        ) {
+        ($node->use_play_folder || $node->download_folder!='')
+          ) {
           $items[] = array('path' => 'node/'.arg(1).'/multidownload',
             'title' => t('download other formats'),
             'callback' => 'video_multidownload_download',
@@ -78,7 +78,7 @@
   $form = array();
 
   $options = array(1 => 'Yes', 0 => 'No');
-  
+
   $form['multifile'] = array('#type' => 'fieldset', '#title' => t('Multi-file download options'), '#description' => t('Allows a list of files to be shown on the download page. The list is usually gotten from a specified folder. This ability is useful for providing different sizes and video types for download.'));
   $form['multifile']['video_multidownload'] = array(
     '#type' => 'radios',
@@ -91,7 +91,7 @@
     '#title' => t('File extensions to show'),
     '#default_value' => variable_get('video_download_ext', 'mov,wmv,rm,flv,avi,divx,mpg,mpeg,mp4,zip'),
     '#description' => t('The extensions of files to list from the multi-file download folder on the download page. Extensions should be comma seperated with no spaces, for example (mov,wmv,rm).'));
-  
+
   return system_settings_form($form);
 }
 
@@ -141,7 +141,7 @@
 function video_multidownload_nodeapi(&$node, $op, $teaser) {
   if($node->type == 'video') {
     switch ($op) {
-  
+
       case 'validate':
         //Validate multi-file download values.
         if (user_access('create multi-file downloads')) { //Make sure the user has permission.
Index: video/plugins/video_upload/broken.patch
===================================================================
--- video.orig/plugins/video_upload/broken.patch	2007-06-28 13:35:25.000000000 -0700
+++ /dev/null	1970-01-01 00:00:00.000000000 +0000
@@ -1,49 +0,0 @@
---- video_upload.module.orig	2007-06-06 20:53:15.000000000 -0700
-+++ video_upload.module	2007-06-06 20:53:28.000000000 -0700
-@@ -158,7 +158,10 @@
-     }
-     else {
-       // vidfile field is no more required while upload is enabled.
--      $form['video']['vidfile']['#required'] = FALSE;
-+      if ($node->video_fid) {
-+        $form['video']['vidfile']['#required'] = FALSE;
-+        $form['video']['vidfile']['#default_value'] = '';
-+      }
- 
-       $form['video']['vidfile']['#description'] .= '<p>' . t('If you want to upload a video simply ignore this field and select your video file at the "Upload video file" field.') . '</p>';
-       $form['video']['video_upload'] = array(
-@@ -186,8 +189,14 @@
- 
- function _video_upload_load_file(&$node) {
-   if ($node->serial_data['video_fid']) {
--    $result = db_query('SELECT * FROM {files} WHERE fid = %d', $node->serial_data['video_fid']);
--    return db_fetch_object($result);
-+    $fid = $node->serial_data['video_fid'];
-+  } else if ($node->video_fid) {
-+    $fid = $node->video_fid;
-+  }
-+  if ($fid) {
-+    $result = db_query('SELECT * FROM {files} WHERE fid = %d', $fid);
-+    $file = db_fetch_object($result);
-+    return $file;
-   }
- }
- 
-@@ -200,10 +209,15 @@
- 
- 
- function _video_upload_submit(&$node) {
--  $video_upload_file = _video_upload_load_file($node);
--  if ($video_upload_file && $node->video_fid != $video_upload_file->fid) {
-+dump_msg($node, __FUNCTION__);
-+  $file = _video_upload_load_file($node);
-+  if ($file && $node->video_fid != $file->fid) {
-+    here();
-     // reset vidfile: the real value gets loaded at nodeapi(load) time
-     $node->vidfile = '';
-+  } else if ($file && $node->vidfile != file_create_url($file->filepath)) {
-+    $node->video_fid = 0;
-+    here();
-   }
-   $node->serial_data['video_fid'] = $node->video_fid;
- }
Index: video/plugins/video_upload/video_upload.info
===================================================================
--- video.orig/plugins/video_upload/video_upload.info	2007-06-28 13:35:25.000000000 -0700
+++ /dev/null	1970-01-01 00:00:00.000000000 +0000
@@ -1,5 +0,0 @@
-; $Id: video_upload.info,v 1.2 2006/11/11 03:58:41 fax8 Exp $
-name = Video Upload
-description = Enable video files uploading in video module.
-dependencies = video
-package = "Video"
Index: video/plugins/video_upload/video_upload.js
===================================================================
--- video.orig/plugins/video_upload/video_upload.js	2007-06-28 13:35:25.000000000 -0700
+++ /dev/null	1970-01-01 00:00:00.000000000 +0000
@@ -1,38 +0,0 @@
-// $Id: video_upload.js,v 1.3 2007/01/14 17:30:40 fax8 Exp $
-/**
- * @file
- * Javascript functions for busy status on video uploads
- * 
- * TODO: Support AJAX Uploads :-)
- *
- * @author Fabio Varesano <fvaresano at yahoo dot it>
-*/
-
-/**
- * Hide the node form and show the busy div
-*/
-Drupal.video_upload_hide = function () {
-  $('#node-form').hide();
-  $("#sending").show();
-  $("#video_upload_cancel_link").click(Drupal.video_upload_show);
-}
-
-Drupal.video_upload_show = function() {
-  $('#node-form').show();
-  $("#sending").hide();
-  
-  //$("form").bind("submit", function() { return false; })
-  //window.location = window.location;
-}
-
-/**
- * Attaches the upload behaviour to the video upload form.
- */
-Drupal.video_upload = function() {
-  $('#node-form').submit(Drupal.video_upload_hide);
-}
-
-// Global killswitch
-if (Drupal.jsEnabled) {
-  $(document).ready(Drupal.video_upload);
-}
Index: video/plugins/video_upload/video_upload.module
===================================================================
--- video.orig/plugins/video_upload/video_upload.module	2007-06-28 13:35:25.000000000 -0700
+++ /dev/null	1970-01-01 00:00:00.000000000 +0000
@@ -1,379 +0,0 @@
-<?php
-// $Id: video_upload.module,v 1.16.2.2 2007/06/22 13:03:13 vhmauery Exp $
-
-/**
- * @file
- * Enable Video files uploading in video module
- *
- * @author Fabio Varesano <fvaresano at yahoo dot it>
- */
-
-
-/**
- * Implementation of hook_help().
- */
-function video_upload_help($section) {
-  switch ($section) {
-    case 'admin/settings/modules#description':
-      return t('Enable video files uploading in video module.');
-  }
-}
-
-
-/**
- * Implementation of hook_menu().
- */
-function video_upload_menu($may_cache) {
-  $items = array();
-  if ($may_cache) {
-    $items[] = array(
-      'path' => 'admin/content/video/upload',
-      'title' => t('Upload'),
-      'description' => t('Administer video_upload module settings'),
-      'callback' => 'drupal_get_form',
-      'callback arguments' => array('video_upload_settings_form'),
-      'access' => user_access('administer site configuration'),
-      'type' => MENU_NORMAL_ITEM,
-    );
-  }
-  return $items;
-}
-
-
-/**
- * Settings Hook
- *
- * @return
- *   string of form content or error message
- */
-function video_upload_settings_form() {
-  //Must have "administer site configuration" and "administer video" privilages.
-  if (!user_access('administer video')) {
-    drupal_access_denied();
-  }
-
-  $form = array();
-  $form['video_upload_override_vidfile'] =  array(
-    '#type' => 'checkbox',
-    '#title' => t('override video file'),
-    '#description' => t('Check this if your users must only submit videos through uploading. This disables path insertion.'),
-    '#default_value' => variable_get('video_upload_override_vidfile', false),
-  );
-
-  return system_settings_form($form);
-}
-
-
-/**
- * Implementation of hook_perm().
- */
-function video_upload_perm() {
-  return array('upload video files');
-}
-
-
-/**
- * Implementation of hook_nodeapi()
- */
-function video_upload_nodeapi(&$node, $op, $teaser) {
-  if($node->type == 'video') {
-    switch ($op) {
-  
-      case 'load':
-        $output['video_upload_file'] = _video_upload_load($node);
-        if($node->vidfile == '') { // we will disable uploaded file if a path is already live
-          $output['vidfile'] = file_create_url($output['video_upload_file']->filepath);
-          // set the filesize - this seems not to work.. why???
-          $output['size'] = $output['video_upload_file']->filesize;
-        }
-        return $output;
-      
-      case 'prepare':
-        _video_upload_prepare($node);
-        break;
-  
-      case 'validate':
-         _video_upload_validate($node);
-        break;
-  
-  
-      case 'submit':
-        _video_upload_submit($node);
-        break;
-  
-      case 'insert':
-        _video_upload_store($node);
-        break;
-      case 'update':
-        // is there a better way ???
-        $node->video_upload_file = _video_upload_load($node);
-        _video_upload_delete($node);
-        _video_upload_store($node);
-        break;
-  
-      case 'delete':
-        _video_upload_delete($node);
-        break;
-  
-      case 'delete revision':
-        video_upload_delete_revision($node);
-        break;
-  
-  
-  
-    }
-  }
-}
-
-
-/**
- * Implementation of hook_form_alter()
- * We use this to add a file upload field to the video creation form.
- */
-function video_upload_form_alter($form_id, &$form) {
-
-  if($form_id == 'video_node_form' && isset($form['video']) && user_access('upload video files')) {
-    
-    theme('video_upload_get_script');
-    
-    $form['#suffix'] = theme('video_upload_busy');
-
-    //get node object from form
-    $node = $form['#node'];
-
-    // required for upload to work
-    $form['#attributes']['enctype'] = 'multipart/form-data';
-
-    if(variable_get('video_upload_override_vidfile', false)) {
-      // remove unnecessary fields
-      $form['video']['vidfile'] = NULL;
-      $form['video']['filesize'] = NULL;
-      $form['video'] += _video_upload_form($node);
-    }
-    else {
-      // vidfile field is no more required while upload is enabled.
-      $form['video']['vidfile']['#required'] = FALSE;
-
-      $form['video']['vidfile']['#description'] .= '<p>' . t('If you want to upload a video simply ignore this field and select your video file at the "Upload video file" field.') . '</p>';
-      $form['video']['video_upload'] = array(
-        '#type' => 'fieldset',
-        '#title' => t('Upload video'),
-        '#weight' => -19,
-        '#collapsible' => TRUE,
-        '#collapsed' => (isset($node->video_upload_file) ? TRUE : FALSE ),
-      );
-
-      $form['video']['video_upload'] += _video_upload_form($node);
-    }
-  }
-}
-
-
-function _video_upload_load(&$node) {
-  if ($node->vid) {
-    $result = db_query('SELECT * FROM {files} f INNER JOIN {file_revisions} r ON f.fid = r.fid WHERE r.vid = %d ORDER BY f.fid DESC', $node->vid);
-    //while($item =  db_fetch_object($result)) {
-    //  print_r($item); 
-    //}
-    return db_fetch_object($result);
-  }
-}
-
-
-/**
- * Validate video file
- */
-function _video_upload_validate(&$node) {
-  // if we override the default video module vidfile field and we don't have a file uploaded set error
-  if (user_access('upload video files') && variable_get('video_upload_override_vidfile', false) && !isset($node->video_upload_file) && !isset($_SESSION['video_upload_file'])) {
-    form_set_error('video_upload_file', t('A file must be provided.'));
-    return;
-  }
-}
-
-
-function _video_upload_submit(&$node) {
-  ;
-}
-
-
-function _video_upload_prepare(&$node) {
-  // clear video file informations
-  if(count($_POST) == 0) {
-    if (!empty($_SESSION['video_upload_file'])) {
-      file_delete($_SESSION['video_upload_file']->filepath);
-    }
-    unset($_SESSION['video_upload_file']);
-  }
-
-
-  if ($file = file_check_upload('video_upload_file')) {
-    $temppath = file_directory_temp() . '/video/';
-    file_check_directory($temppath, TRUE);
-    $node->video_upload_file = file_save_upload($file, $temppath .'/'. $file->filename, FILE_EXISTS_REPLACE);
-    $node->video_upload_file->newfile = TRUE;
-    
-    // set video size
-    $node->size = $node->video_upload_file->filesize;
-
-    $_SESSION['video_upload_file'] = $node->video_upload_file;
-  }
-  else if (!empty($_SESSION['video_upload_file'])) {
-    $node->video_upload_file = $_SESSION['video_upload_file'];
-    // set video size
-    $node->size = $node->video_upload_file->filesize;
-
-  } else {
-    $_SESSION['video_upload_file'] = $node->video_upload_file;
-  }
-}
-
-
-function _video_upload_store(&$node) {
-  if(!empty($_SESSION['video_upload_file'])) {
-    $file = $_SESSION['video_upload_file'];
-    $dest_dir = variable_get('video_upload_default_path', 'videos') .'/';
-    if ($file = file_save_upload($file, $dest_dir . $file->filename)) {
-      $file->fid = db_next_id('{files}_fid');
-      db_query("INSERT INTO {files} (fid, nid, filename, filepath, filemime, filesize) VALUES (%d, %d, '%s', '%s', '%s', %d)", $file->fid, $node->nid, $file->filename, $file->filepath, $file->filemime, $file->filesize);
-      db_query("INSERT INTO {file_revisions} (fid, vid, list, description) VALUES (%d, %d, %d, '%s')", $file->fid, $node->vid, $file->list, $file->description);
-      $_SESSION['video_upload_file_stored'] = $file;
-      unset($_SESSION['video_upload_file']);
-    }
-    else {
-      drupal_set_message(t('An error occurred during file saving. Your video file has not been stored.'), 'error');
-    }
-  }
-}
-
-
-/**
- * Delete files associated to this video node
- */
-function _video_upload_delete(&$node) {
-
-  // delete file
-  file_delete($node->video_upload_file->path);
-  
-  // delete file information from database
-  db_query('DELETE FROM {file_revisions} WHERE fid = %d', $node->video_upload_file->fid);
-  db_query('DELETE FROM {files} WHERE fid = %d', $node->video_upload_file->fid);
-}
-
-
-/**
-* Create video upload specific form fields
-*/
-function _video_upload_form($node) {
-  _video_upload_check_settings();
-
-  $form = array();
-
-  $form['video_upload_file'] = array(
-    '#type' => 'file',
-    '#title' => t('Upload video file'),
-    '#size' => 40,
-    '#weight' => -19,
-    '#description' => t('The uploaded file will be used as video file for this node.<br /><b>NOTE:</b> The max upload size is') . ' ' . format_size(_video_upload_get_max_upload_size()) . '.',
-  );
-
-  if (isset($node->video_upload_file)) {
-    $form['video_upload_file']['#prefix'] = theme('video_upload_file_info_form', $node);
-    $form['video_upload_file']['#title'] = t('Replace with');
-  }
-
-  return $form;
-}
-
-
-/**
- * Display informations about already uploaded file
- */
-function theme_video_upload_file_info_form(&$node) {
-  $output = '<p>' . t('A video file has been already uploaded.') . '</p>';
-
-  // create array containing uploaded file informations
-  $items = array(
-  '<b>'. t('file name') .':</b> ' . $node->video_upload_file->filename,
-  '<b>'. t('file path') .':</b> ' . $node->video_upload_file->filepath,
-  '<b>'. t('file size') .':</b> ' . format_size($node->video_upload_file->filesize),
-  '<b>'. t('file mime') .':</b> ' . $node->video_upload_file->filemime,
-  );
-
-  // create information list
-  $output .= theme_item_list($items, t('uploaded video informations:'));
-
-  return $output;
-}
-
-
-/**
- * Check PHP's post_max_size and upload_max_filesize settings and determine
- * the maximum size of a file upload.
- * (code from audio.module)
- * @return an integer number of bytes
- */
-function _video_upload_get_max_upload_size() {
-  $limits = array();
-  foreach (array('upload_max_filesize', 'post_max_size') as $setting) {
-    // the post_max_size and upload_max_filesize settings could be a string
-    // ('2m', '1G') or an integer (2097152 or 1073741824).
-    $val = ini_get($setting);
-    if (!is_numeric($val)) {
-      // separate the numeric and alpha parts, then get to multiplying
-      $val = trim($val);
-      $last = strtolower($val{strlen($val)-1});
-      switch($last) {
-        case 'g':
-          $val *= 1024;
-        case 'm':
-          $val *= 1024;
-        case 'k':
-          $val *= 1024;
-      }
-    }
-    $limits[] = $val;
-  }
-  // the smallest value will be the limiting factor so retun it.
-  return min($limits);
-}
-
-
-/**
- * Verify the video_upload module settings.
- */
-function _video_upload_check_settings() {
-  // File paths
-  $video_path = file_create_path(variable_get('video_upload_default_path', 'videos'));
-  $temp_path = rtrim($video_path, '/') . '/temp';
-
-  if (!file_check_directory($video_path, FILE_CREATE_DIRECTORY, 'video_upload_default_path')) {
-    return false;
-  }
-  if (!file_check_directory($temp_path, FILE_CREATE_DIRECTORY, 'video_upload_default_path')) {
-    return false;
-  }
-
-  return true;
-}
-
-
-
-/**
- * Import the video_upload.js script
- */
-function theme_video_upload_get_script() {
-  drupal_add_js(drupal_get_path('module', 'video_upload') . '/video_upload.js');
-}
-
-
-function theme_video_upload_busy() {
-  return '<div id="sending" style="display: none;">
-				 <h3>' . t('Sending video... please wait.') . '</h3>
-						<img src="'. url() . drupal_get_path('module', 'video_upload') . '/busy.gif" alt="' . t('Sending video... please wait.') . '"/>
-            <p>'. t('Video upload could take some minutes.') . '<br /><a href="#" id="video_upload_cancel_link">abort upload.</a></p>
-						</div>';
-}
-
-
-
Index: video/types/video_google/video_google.info
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ video/types/video_google/video_google.info	2007-06-28 13:35:39.000000000 -0700
@@ -0,0 +1,5 @@
+; $Id:  $
+name = Google Video
+description = Enable Google video support for Video module.
+dependencies = video
+package = "Video"
Index: video/types/video_google/video_google.module
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ video/types/video_google/video_google.module	2007-06-28 13:35:39.000000000 -0700
@@ -0,0 +1,146 @@
+<?php
+// $Id:  $
+
+/**
+ * @file
+ * Enable Google Video support for video module.
+ *
+ * @author Fabio Varesano <fvaresano at yahoo dot it>
+ */
+
+
+/**
+ * Implementation of hook_menu
+*/
+function video_google_menu($maycache) {
+  $items = array();
+  if($maycache) {
+    $items[] = array(
+      'path' => 'node/add/video/google',
+      'title' => t('Google Video'),
+      'access' => user_access('create video')
+    );
+  }
+  return $items;
+}
+
+
+/**
+ * Implementation of hook_v_help
+*/
+function video_google_v_help() {
+
+  $help = array();
+  $help['google']['data'] = '<b><a href="http://video.google.com" name="video_google">' . t('Google Video support') . '</a></b>';
+  $help['google']['children'] = array(t('You can host videos on video.google.com and put them on your site.
+  To do this, after you upload the video on Google video you just have to get the URL of the video.'));
+
+  return $help;
+}
+
+
+/**
+ * Implementation of hook_v_info()
+*/
+function video_google_v_info() {
+  $info['google'] = array(
+    '#name' => 'Google Video',
+    '#description' => t('Post a video available on !link to this website.', array('!link' => l(t('Google Video'), 'http://video.google.com'), NULL, NULL, NULL, TRUE))
+  );
+
+  return $info;
+}
+
+
+/**
+ * Implementation of hook_v_form()
+*/
+function video_google_v_form(&$node, &$form) {
+
+  $form['video']['vidfile'] = array(
+    '#type' => 'textfield',
+    '#title' => t('Google Video URL'),
+    '#default_value' => $node->vidfile,
+    '#maxlength' => 700,
+    '#required' => TRUE,
+    '#weight' => -20,
+    '#description' => t('Insert the URL to the google video. ') . l(t('More information.'), 'video/help', NULL, NULL, 'videofile'));
+
+  return $form;
+}
+
+
+/**
+ * Implementation of hook_v_play
+*/
+function video_google_v_play($node) {
+  return theme('video_google_play', $node);
+}
+
+
+/** THEMEABLE FUNCTIONS */
+
+/**
+ * Play videos hosted on video.google.com
+ * Allows users to host videos on video.google.com and then use the video ID to post it in the module.
+ *
+ * @param $node
+ *   object with node information
+ *
+ * @return
+ *   string of content to display
+ */
+function theme_video_google_play($node) {
+  $width = ($node->videox ? $node->videox : '425');
+  $height = ($node->videoy ? $node->videoy : '350');
+  // Strip heading "google:"
+  $videoid = _video_google_get_id(check_plain($node->vidfile));
+  //$videoid = substr($node->vidfile, 7);
+
+  // this will be executed by not Internet Explorer browsers
+  $output = '<!--[if !IE]> <-->
+<object type="application/x-shockwave-flash" width="'. $width .'" height="'. $height .'"
+data="http://video.google.com/googleplayer.swf?docId='. check_plain($videoid) .'">
+<!--> <![endif]-->' . "\n";
+
+  // this will be executed by Internet Explorer
+  $output .= '<!--[if IE]>
+<object type="application/x-shockwave-flash" width="'. $width .'" height="'. $height .'"
+classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
+codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0">
+<![endif]-->' . "\n";
+
+  // params will be passed to both IE or not IE browsers
+  $output .= '<param name="movie" value="http://video.google.com/googleplayer.swf?docId=' . check_plain($videoid) . '" />' . "\n";
+  // following a list of params simply copied from old embed tag params. I don't know if this are really needed.
+  $output .= '<param name="quality" value="best" />
+  <param name="bgcolor" value="#ffffff" />
+  <param name="allowScriptAccess" value="sameDomain" />
+  <param name="scale" value="noScale" />
+  <param name="wmode" value="window" />
+  <param name="salign" value="TL" />
+  <param name="FlashVars" value="playerMode=embedded" />'
+  . _video_get_parameters($node) .
+  '<p>'. t('Your browser is not able to display this multimedia content.') .'</p>
+</object>';
+
+
+  $output = _theme_video_format_play($output, t('http://video.google.com/support'), t('Link to video.google.com'), t('video.google.com'));
+  return $output;
+}
+
+
+
+/** HELPER FUNCTIONS */
+
+/**
+ * Get the docid from an URL
+*/
+function _video_google_get_id($url) {
+  $pattern = '/[0-9]+/'; // maybe too weak?
+  preg_match_all($pattern, $url, $matches, PREG_PATTERN_ORDER);
+  return $matches[0][0];
+}
+
+
+
Index: video/types/video_link/video_link.info
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ video/types/video_link/video_link.info	2007-06-28 13:35:39.000000000 -0700
@@ -0,0 +1,5 @@
+; $Id:  $
+name = Web Link Video
+description = Enable weblink video support for Video module.
+dependencies = video
+package = "Video"
Index: video/types/video_link/video_link.module
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ video/types/video_link/video_link.module	2007-06-28 13:35:39.000000000 -0700
@@ -0,0 +1,89 @@
+<?php
+// $Id:  $
+
+/**
+ * @file
+ * Enable Path or URL support for video module.
+ *
+ * @author Fabio Varesano <fvaresano at yahoo dot it>
+ */
+
+
+/**
+ * Implementation of hook_menu
+*/
+function video_link_menu($maycache) {
+  $items = array();
+  if($maycache) {
+    $items[] = array(
+      'path' => 'node/add/video/upload',
+      'title' => t('Upload'),
+      'access' => user_access('create video')
+    );
+  }
+
+  return $items;
+}
+
+
+/**
+ * Implementation of hook_v_help
+*/
+function video_link_v_help() {
+
+  $help = array();
+  $help['link']['data'] = '<b>' . t('Url support') . '</b>';
+  $help['link']['children'] = array(t('INSERT HERE DOCUMENTATION'));
+
+  return $help;
+}
+
+
+/**
+ * Implementation of hook_v_info()
+*/
+function video_link_v_info() {
+  $info['upload'] = array(
+    '#name' => 'Upload Video',
+    '#description' => t('Post a video available on a web page to this website.')
+  );
+
+  return $info;
+}
+
+
+/**
+ * Implementation of hook_v_form()
+*/
+function video_link_v_form(&$node, &$form) {
+
+  $form['video']['vidfile'] = array(
+    '#type' => 'textfield',
+    '#title' => t('URL to the webpage'),
+    '#default_value' => $node->vidfile,
+    '#maxlength' => 700,
+    '#required' => TRUE,
+    '#weight' => -20,
+    '#description' => t('Insert the URL to the webpage which contains the video. ') . l(t('More information.'), 'video/help', NULL, NULL, 'videofile'));
+
+  return $form;
+}
+
+
+/**
+ * implementation of hook_v_validate
+*/
+function video_link_v_validate($node) {
+  //TODO: Validate link
+}
+
+/**
+ * Implementation of hook_v_play
+*/
+function video_link_v_play($node) {
+  include(drupal_get_path('module', 'video') .'/types/common.inc');
+  return _video_common_get_player($node->vidfile);
+}
+
+
+
Index: video/types/video_upload/video_upload.info
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ video/types/video_upload/video_upload.info	2007-06-28 13:35:39.000000000 -0700
@@ -0,0 +1,5 @@
+; $Id:  $
+name = Upload Video
+description = Enable Uploaded video support for Video module.
+dependencies = video token
+package = "Video"
Index: video/types/video_upload/video_upload.js
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ video/types/video_upload/video_upload.js	2007-06-28 13:35:39.000000000 -0700
@@ -0,0 +1,41 @@
+// $Id: video_upload.js,v 1.3 2007/01/14 17:30:40 fax8 Exp $
+/**
+ * @file
+ * Javascript functions for busy status on video uploads
+ *
+ * TODO: Support AJAX Uploads :-)
+ *
+ * @author Fabio Varesano <fvaresano at yahoo dot it>
+*/
+
+/**
+ * Hide the node form and show the busy div
+*/
+Drupal.video_upload_hide = function () {
+  // hiding the form (using display: none) makes its file values empty in Konqueror (Possibly also Safari). So let's move the form away of the view of the browser
+
+  $('#node-form').css({ position: "absolute", top: "-4000px" });
+
+  $("#sending").show();
+  $("#video_upload_cancel_link").click(Drupal.video_upload_show);
+}
+
+Drupal.video_upload_show = function() {
+  $('#node-form').show();
+  $("#sending").hide();
+
+  //$("form").bind("submit", function() { return false; })
+  window.location = window.location;
+}
+
+/**
+ * Attaches the upload behaviour to the video upload form.
+ */
+Drupal.video_upload = function() {
+  $('#node-form').submit(Drupal.video_upload_hide);
+}
+
+// Global killswitch
+if (Drupal.jsEnabled) {
+  $(document).ready(Drupal.video_upload);
+}
Index: video/types/video_upload/video_upload.module
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ video/types/video_upload/video_upload.module	2007-06-28 13:35:39.000000000 -0700
@@ -0,0 +1,523 @@
+<?php
+// $Id:  $
+
+/**
+ * @file
+ * Enable Uploaded videos support for video module.
+ *
+ * @author Fabio Varesano <fvaresano at yahoo dot it>
+ */
+
+
+/**
+ * Implementation of hook_menu
+*/
+function video_upload_menu($maycache) {
+  $items = array();
+  if($maycache) {
+    $items[] = array(
+      'path' => 'node/add/video/upload',
+      'title' => t('Upload'),
+      'access' => user_access('create video')
+    );
+    $items[] = array(
+      'path' => 'admin/settings/video/upload',
+      'title' => t('Video upload settings'),
+      'description' => t('Configure various settings of the video upload plugin.'),
+      'access' => user_access('administer site configuration'),
+      'callback' => 'drupal_get_form',
+      'callback arguments' => array('video_upload_admin_settings'),
+      'type' => MENU_NORMAL_ITEM,
+    );
+  }
+
+  return $items;
+}
+
+
+/**
+ * Setting form for video_upload
+*/
+function video_upload_admin_settings() {
+	$form = array();
+
+  $form['videouploadpath_prefix'] = array(
+    '#type' => 'textfield',
+    '#title' => t('Pattern for the file prefix'),
+    '#description' => t('Specify the pattern to prefix to file names uploaded with the video_upload module.  It will be appended after the site files directory (e.g., files) but before the file name itself.  Do not include a leading or trailing slash.  Spaces will be converted to underscores to avoid file system issues.'),
+    '#default_value' => variable_get('videouploadpath_prefix', 'videos'),
+  );
+
+  $form['token_help'] = array(
+    '#title' => t('Replacement patterns'),
+    '#type' => 'fieldset',
+    '#collapsible' => TRUE,
+    '#collapsed' => TRUE,
+    '#description' => t('Prefer raw-text replacements for text to avoid problems with HTML entities!'),
+  );
+  $form['token_help']['help'] = array(
+    '#value' => theme('token_help', 'node'),
+  );
+
+  return system_settings_form($form);
+}
+
+
+/**
+ * Implementation of hook_cron().
+ * Look for uploaded videos which have not been submitted (only previews) and
+ * delete them
+ */
+function video_upload_cron() {
+  /* look for crusty files */
+  $temppath = file_directory_temp() . '/video/';
+  $files = file_scan_directory(file_create_path($temppath), '.*');
+  foreach ($files as $file => $info) {
+    if (time() - filemtime($file) > 60*60*6) {
+      db_query("DELETE FROM {files} WHERE filename LIKE 'video_upload_temp.%' AND nid = 1 AND filepath = '%s'", $file);
+      file_delete($file);
+    }
+  }
+}
+
+
+
+
+/**
+ * Implementation of hook_v_help
+*/
+function video_upload_v_help() {
+
+  $help = array();
+  $help['upload']['data'] = '<b>' . t('Url support') . '</b>';
+  $help['upload']['children'] = array(t('You can link to any video file on the Internet.'));
+
+  return $help;
+}
+
+
+/**
+ * Implementation of hook_v_info()
+*/
+function video_upload_v_info() {
+  $info['upload'] = array(
+    '#name' => 'Upload Video',
+    '#description' => t('Post a video available on your computer as a file to this website.'),
+    '#downloadable' => 'true'
+  );
+
+  return $info;
+}
+
+
+/**
+ * Implementation of hook_v_form()
+*/
+function video_upload_v_form(&$node, &$form) {
+  print 'form';
+
+  // add js stuff for the 'upload in progess' message
+  theme('video_upload_get_script');
+  // add hidden html used for the 'upload in progess' message
+  $form['#suffix'] = theme('video_upload_busy');
+
+  // required for upload to work
+  $form['#attributes']['enctype'] = 'multipart/form-data';
+
+  $form['video'] += _video_upload_form($node);
+
+  return $form;
+}
+
+
+
+/**
+ * Implementation of hook_nodeapi()
+ */
+function video_upload_nodeapi(&$node, $op) {
+  if($node->type == 'video' && $node->vtype == 'upload') {
+    switch ($op) {
+
+      case 'load':
+        return _video_upload_load($node);
+
+      case 'prepare':
+        _video_upload_prepare($node);
+        break;
+
+      case 'validate':
+         _video_upload_validate($node);
+        break;
+
+      case 'submit':
+        _video_upload_submit($node);
+        break;
+
+      case 'insert':
+        _video_upload_insert($node);
+        break;
+
+      case 'update':
+        _video_upload_update($node);
+        break;
+
+      case 'delete':
+        _video_upload_delete($node);
+        break;
+
+      case 'delete revision':
+        video_upload_delete_revision($node);
+        break;
+
+      case 'view':
+        _video_upload_view($node);
+    }
+  }
+}
+
+
+
+function _video_upload_load(&$node) {
+  print 'load';
+
+  $output = array();
+  $output['video_fid'] = $node->serial_data['video_fid'];
+  $file = _video_upload_get_file($output['video_fid']);
+  $output['current_video_upload_file'] = $file;
+  $output['vidfile'] = file_create_url($file->filepath);
+  // set the filesize
+  $output['size'] = $file->filesize;
+
+  return $output;
+}
+
+
+
+function _video_upload_prepare(&$node) {
+  print 'prepare';
+
+  if (count($_POST) && $file = file_check_upload('video_upload_file')) { // a file has been uploaded
+
+    // this is the temp directory to store files
+    $temppath = file_directory_temp() . '/video/';
+    // let's check that the directory is good
+    file_check_directory($temppath, TRUE);
+    // let's save the uploaded file to the temp directory
+    $file = file_save_upload($file, $temppath . '/' . $file->filename, FILE_EXISTS_REPLACE);
+
+    // let's store the temp file into the DB
+    $file->fid = db_next_id('{files}_fid');
+    db_query("INSERT INTO {files} (fid, nid, filename, filepath, filemime, filesize) VALUES (%d, %d, '%s', '%s', '%s', %d)", $file->fid, 1, 'video_upload_temp.'.$file->filename, $file->filepath, $file->filemime, $file->filesize);
+
+    // TODO: delete here the previous $node->preview_video_upload_file
+
+    if($_POST['op'] == 'Preview') { // it's a preview
+      //$_SESSION['preview_video_upload_file'] = $file;
+      $node->preview_video_upload_file = $file;
+    }
+    else {
+      $node->new_video_upload_file = $file;
+    }
+  }
+  else if (($node->preview_video_upload_file_fid || $_POST['preview_video_upload_file_fid']) && $_POST['op'] == 'Submit') {
+    $node->new_video_upload_file = _video_upload_get_file($_POST['preview_video_upload_file_fid']);
+  }
+  else if (($node->preview_video_upload_file_fid || $_POST['preview_video_upload_file_fid']) && $_POST['op'] == 'Preview') {
+    $node->preview_video_upload_file = _video_upload_get_file($_POST['preview_video_upload_file_fid']);
+
+  }
+}
+
+
+
+/**
+* Create video upload specific form fields
+*/
+function _video_upload_form(&$node) {
+  _video_upload_check_settings();
+
+  $form = array();
+
+  if($node->new_video_upload_file) { // there is a newly uploaded file (this has been initialized by _prepare())
+    $form['new_video_upload_file_fid'] = array('#type' => 'hidden', '#value' => $node->new_video_upload_file->fid);
+    //print_r($node->new_video_upload_file); die;
+  }
+  if($node->preview_video_upload_file) { // a new file has been uploaded but we are executing a preview not a submit
+    $form['preview_video_upload_file_fid'] = array('#type' => 'hidden', '#value' => $node->preview_video_upload_file->fid);
+    $form['preview_video_upload_file_info'] = array('#type' => 'item', '#value' => theme('video_upload_file_info_form', $node->preview_video_upload_file, $node).'preview', '#weight' => -10);
+  }
+  else if($node->current_video_upload_file) { // we don't have a new file
+    $form['current_video_upload_file_fid'] = array('#type' => 'hidden', '#value' => $node->current_video_upload_file->fid);
+    $form['current_video_upload_file_info'] = array('#type' => 'item', '#value' => theme('video_upload_file_info_form', $node->current_video_upload_file, $node), '#weight' => -10);
+  }
+  $form['video_upload_file'] = array(
+    '#type' => 'file',
+    '#title' => t('Upload video file'),
+    '#size' => 40,
+    '#weight' => -9,
+    '#description' => t('The uploaded file will be used as video file for this node.<br /><b>NOTE:</b> The max upload size is') . ' ' . format_size(_video_upload_get_max_upload_size()) . '.',
+  );
+
+  return $form;
+}
+
+
+/**
+ * Validate video file
+ */
+function _video_upload_validate(&$node) {
+  //TODO: check that the file arrived.
+  print 'validate';
+
+  //print_r($node); die;
+  /*
+  if(!(isset($node->new_file_uploaded))) {
+    form_set_error('video_upload_file', t('You have not provided any video file. Please upload one.<br />If you uploaded a video but the system did not received it, please check that it is smaller than') . format_size(_video_upload_get_max_upload_size().'.'));
+  }
+  */
+}
+
+
+function _video_upload_submit(&$node) {
+  print 'submit';
+
+  //print_r($node); die;
+  if($node->new_video_upload_file_fid) {
+    $fid = $node->new_video_upload_file_fid;
+  }
+  else if($node->preview_video_upload_file_fid) {
+    $fid = $node->preview_video_upload_file_fid;
+  }
+  else {
+    $fid = $node->current_video_upload_file_fid;
+  }
+  $node->serial_data['video_fid'] = $fid;
+}
+
+function _video_upload_insert(&$node) {
+  print 'insert';
+
+  if($node->new_video_upload_file_fid && $file = _video_upload_get_file($node->new_video_upload_file_fid)) { // there is a new file uploaded (now stored on the temp path); need to store in the final directory
+    _video_upload_store_file($file, $node);
+  }
+}
+
+function _video_upload_update(&$node) {
+  print 'update';
+
+  if($node->new_video_upload_file_fid && $file = _video_upload_get_file($node->new_video_upload_file_fid)) { // there is a new file uploaded (now stored on the temp path)
+    //need to store in the final directory
+    _video_upload_store_file($file, $node);
+
+    if($node->current_video_upload_file) {
+      // let's delete the old video
+      _video_upload_delete_file($node->current_video_upload_file);
+    }
+  }
+
+}
+
+/**
+ * Delete files associated to this video node
+ */
+function _video_upload_delete(&$node) {
+  print 'delete';
+}
+
+
+/**
+ *
+*/
+function _video_upload_view(&$node) {
+  print 'view';
+}
+
+
+/**
+ * Move a temp file into the final directory associating it with the node
+*/
+function _video_upload_store_file(&$file, &$node) {
+	// $file->filename is video_upload_temp.realfile.ext : let's restore original filename
+  $file->filename = _video_get_original_filename($file->filename);
+
+  _video_upload_get_path(&$file, &$node);
+  if (file_move($file, '')) { // file moved successfully
+
+    // update the file db entry
+    db_query("UPDATE {files} SET nid = %d, filename = '%s', filepath = '%s', filemime = '%s', filesize = %d WHERE fid = %d", $node->nid, $file->filename, $file->filepath, $file->filemime, $file->filesize, $file->fid);
+    // add an entry in the file_revisions table
+    db_query("INSERT INTO {file_revisions} (fid, vid, list, description) VALUES (%d, %d, %d, '%s')", $file->fid, $node->vid, $file->list, $file->description);
+  }
+  else {
+    drupal_set_message(t('An error occurred during file saving. Your video file has not been stored.'), 'error');
+    $rep = array(
+      '!path' => $file,
+      '!dest' => $dest_path,
+    );
+    watchdog('video_upload', t('moving file !path to !dest failed', $rep));
+  }
+}
+
+
+/**
+ * Gets the definitive path for stored videos
+*/
+function _video_upload_get_path(&$file, &$node) {
+  // this code is from uploadpath.module
+  $file_name = str_replace(array(' ', "\n", "\t"), '_', token_replace(variable_get('videouploadpath_prefix', 'videos') . '/', 'node', $node)) . $file->filename;
+
+  // Create the directory if it doesn't exist yet.
+  $dirs = explode('/', dirname($file_name));
+  $directory = file_directory_path();
+  while (count($dirs)) {
+    $directory .= '/' . array_shift($dirs);
+    file_check_directory($directory, FILE_CREATE_DIRECTORY);
+  }
+	$file->filename = $file_name;
+}
+
+
+/**
+ * Get the file object with the given $fid. This function cache its results
+*/
+function _video_upload_get_file($fid) {
+  static $files = array();
+
+  if (!$fid) {
+    return null;
+  }
+  if (!isset($files[$fid])) {
+    $files[$fid] = db_fetch_object(db_query('SELECT * from {files} WHERE fid = %d', $fid));
+  }
+  return $files[$fid];
+}
+
+
+/**
+ * Delete a file
+*/
+function _video_upload_delete_file($file) {
+
+   // delete file
+  file_delete($file->path);
+
+  // delete file information from database
+  db_query('DELETE FROM {file_revisions} WHERE fid = %d', $file->fid);
+  db_query('DELETE FROM {files} WHERE fid = %d', $file->fid);
+}
+
+
+/**
+ * Display informations about already uploaded file
+ */
+function theme_video_upload_file_info_form($file, $node) {
+  // create array containing uploaded file informations
+  $items = array(
+  '<b>'. t('file name') .':</b> ' . _video_get_original_filename($file->filename),
+  '<b>'. t('file size') .':</b> ' . format_size($file->filesize),
+  );
+
+  // create information list
+  $output .= theme_item_list($items, t('uploaded video information:'));
+
+  return $output;
+}
+
+
+/**
+ * Return the original filename (without 'video_upload_temp.')
+*/
+function _video_get_original_filename($filename) {
+  if(strpos($filename, 'video_upload_temp.') === 0) {
+    return substr($filename, strlen('video_upload_temp.'));
+  }
+  return $filename;
+}
+
+
+
+/**
+ * Check PHP's post_max_size and upload_max_filesize settings and determine
+ * the maximum size of a file upload.
+ * (code from audio.module)
+ * @return an integer number of bytes
+ */
+function _video_upload_get_max_upload_size() {
+  $limits = array();
+  foreach (array('upload_max_filesize', 'post_max_size') as $setting) {
+    // the post_max_size and upload_max_filesize settings could be a string
+    // ('2m', '1G') or an integer (2097152 or 1073741824).
+    $val = ini_get($setting);
+    if (!is_numeric($val)) {
+      // separate the numeric and alpha parts, then get to multiplying
+      $val = trim($val);
+      $last = strtolower($val{strlen($val)-1});
+      switch($last) {
+        case 'g':
+          $val *= 1024;
+        case 'm':
+          $val *= 1024;
+        case 'k':
+          $val *= 1024;
+      }
+    }
+    $limits[] = $val;
+  }
+  // the smallest value will be the limiting factor so retun it.
+  return min($limits);
+}
+
+
+/**
+ * Verify the video_upload module settings.
+ */
+function _video_upload_check_settings() {
+
+  /*
+  // File paths
+  $video_path = file_create_path(variable_get('video_upload_default_path', 'videos'));
+  $temp_path = rtrim($video_path, '/') . '/temp';
+
+  if (!file_check_directory($video_path, FILE_CREATE_DIRECTORY, 'video_upload_default_path')) {
+    return false;
+  }
+  if (!file_check_directory($temp_path, FILE_CREATE_DIRECTORY, 'video_upload_default_path')) {
+    return false;
+  }
+  */
+  return true;
+
+}
+
+
+
+/**
+ * Import the video_upload.js script
+ */
+function theme_video_upload_get_script() {
+  drupal_add_js(drupal_get_path('module', 'video_upload') . '/video_upload.js');
+}
+
+
+/**
+ * Renders a 'upload in progress' message
+*/
+function theme_video_upload_busy() {
+  return '<div id="sending" style="display: none;">
+         <h3>' . t('Sending video... please wait.') . '</h3>
+            <img src="'. base_path() . drupal_get_path('module', 'video_upload') . '/busy.gif'.'" alt="' . t('Sending video... please wait.') . '"/>
+            <p>'. t('Video upload could take some minutes.') . '<br /><a href="#" id="video_upload_cancel_link">abort upload.</a></p>
+            </div>';
+}
+
+
+/**
+ * Implementation of hook_v_play
+*/
+function video_upload_v_play($node) {
+  include(drupal_get_path('module', 'video') .'/includes/common.inc');
+  return _video_common_get_player($node);
+}
+
+
+
Index: video/types/video_url/video_url.info
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ video/types/video_url/video_url.info	2007-06-28 13:35:39.000000000 -0700
@@ -0,0 +1,5 @@
+; $Id:  $
+name = URL Video
+description = Enable URL video support for Video module.
+dependencies = video
+package = "Video"
Index: video/types/video_url/video_url.module
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ video/types/video_url/video_url.module	2007-06-28 13:35:39.000000000 -0700
@@ -0,0 +1,90 @@
+<?php
+// $Id:  $
+
+/**
+ * @file
+ * Enable Path or URL support for video module.
+ *
+ * @author Fabio Varesano <fvaresano at yahoo dot it>
+ */
+
+
+/**
+ * Implementation of hook_menu
+*/
+function video_url_menu($maycache) {
+  $items = array();
+  if($maycache) {
+    $items[] = array(
+      'path' => 'node/add/video/url',
+      'title' => t('URL'),
+      'access' => user_access('create video')
+    );
+  }
+
+  return $items;
+}
+
+
+/**
+ * Implementation of hook_v_help
+*/
+function video_url_v_help() {
+
+  $help = array();
+  $help['url']['data'] = '<b>' . t('Url support') . '</b>';
+  $help['url']['children'] = array(t('You can link to any video file on the Internet.'));
+
+  return $help;
+}
+
+
+/**
+ * Implementation of hook_v_info()
+*/
+function video_url_v_info() {
+  $info['url'] = array(
+    '#name' => 'URL Video',
+    '#description' => t('Post a video available on the Internet to this website.')
+  );
+
+  return $info;
+}
+
+
+/**
+ * Implementation of hook_v_form()
+*/
+function video_url_v_form(&$node, &$form) {
+
+  $form['video']['vidfile'] = array(
+    '#type' => 'textfield',
+    '#title' => t('URL to the video'),
+    '#default_value' => $node->vidfile,
+    '#maxlength' => 700,
+    '#required' => TRUE,
+    '#weight' => -20,
+    '#description' => t('Insert the URL to the video file. ') . l(t('More information.'), 'video/help', NULL, NULL, 'videofile'));
+
+  return $form;
+}
+
+
+/**
+ * implementation of hook_v_validate
+*/
+function video_url_v_validate($node) {
+  // Can you suggest a validation?
+  // validation should allow URLs, relative paths but also streaming servers URLs
+}
+
+/**
+ * Implementation of hook_v_play
+*/
+function video_url_v_play($node) {
+  include_once(drupal_get_path('module', 'video') .'/includes/common.inc');
+  return _video_common_get_player($node->vidfile);
+}
+
+
+
Index: video/types/video_youtube/video_youtube.info
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ video/types/video_youtube/video_youtube.info	2007-06-28 13:35:39.000000000 -0700
@@ -0,0 +1,5 @@
+; $Id:  $
+name = Youtube Video
+description = Enable Youtube videos support for Video module.
+dependencies = video
+package = "Video"
Index: video/types/video_youtube/video_youtube.module
===================================================================
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
+++ video/types/video_youtube/video_youtube.module	2007-06-28 13:35:39.000000000 -0700
@@ -0,0 +1,160 @@
+<?php
+// $Id:  $
+
+/**
+ * @file
+ * Enable Youtube support for video module.
+ *
+ * @author Fabio Varesano <fvaresano at yahoo dot it>
+ */
+
+
+/**
+ * Implementation of hook_menu
+*/
+function video_youtube_menu($maycache) {
+  $items = array();
+  if($maycache) {
+    $items[] = array(
+      'path' => 'node/add/video/youtube',
+      'title' => t('Youtube'),
+      'access' => user_access('create video')
+    );
+  }
+
+  return $items;
+}
+
+
+/**
+ * Implementation of hook_v_help
+*/
+function video_youtube_v_help() {
+
+  $help = array();
+  $help['youtube']['data'] = '<b><a href="http://www.youtube.com">' . t('YouTube.com support') . '</a></b>';
+  $help['youtube']['children'] = array(t('You can host videos on youtube.com and put them on your site. To do this, after you upload the video on youtube.com enter the video URL.'));
+
+  return $help;
+}
+
+
+/**
+ * Implementation of hook_v_info()
+*/
+function video_youtube_v_info() {
+  $info['youtube'] = array(
+    '#name' => 'Youtube Video',
+    '#description' => t('Post a video available on !link to this website.', array('!link' => l(t('Youtube'), 'http://www.youtube.com'), NULL, NULL, NULL, TRUE))
+  );
+
+  return $info;
+}
+
+
+/**
+ * Implementation of hook_v_form()
+*/
+function video_youtube_v_form(&$node, &$form) {
+
+  $form['video']['vidfile'] = array(
+    '#type' => 'textfield',
+    '#title' => t('Youtube Video URL'),
+    '#default_value' => $node->vidfile,
+    '#maxlength' => 700,
+    '#required' => TRUE,
+    '#weight' => -20,
+    '#description' => t('Insert the URL to the youtube video. ') . l(t('More information.'), 'video/help', NULL, NULL, 'videofile'));
+
+  return $form;
+}
+
+
+/**
+ * implementation of hook_v_validate
+*/
+function video_youtube_v_validate($node) {
+  // TODO: use a regex for a deeper check on the url
+  // TODO: use youtube REST or XML-RPC to query youtube: check video available and embeddable
+  if(strpos($node->vidfile, "http://youtube.com/") != 0) {
+    form_set_error('vidfile', t('The Youtube Video URL field must be similar to <em>http://youtube.com/watch?v=IICWFx7sKmw</em>'));
+  }
+}
+
+/**
+ * Implementation of hook_v_play
+*/
+function video_youtube_v_play($node) {
+  return theme('video_youtube_play', $node);
+}
+
+
+/** AUTOTHUMBNAILING LOGIC */
+
+define('VIDEO_YOUTUBE_API_INFO', 'http://youtube.com/dev');
+define('VIDEO_YOUTUBE_API_APPLICATION_URL', 'http://www.youtube.com/my_profile_dev');
+define('VIDEO_YOUTUBE_REST_ENDPOINT', 'http://www.youtube.com/api2_rest');
+
+/**
+ * Implementation of hook_v_autothumbnail
+*/
+function video_youtube_v_autothumbnail($node) {
+
+}
+
+
+/** THEMEABLE FUNCTIONS */
+
+/**
+ * Play videos hosted on youtube.com
+ * Allows users to host videos on youtube.com and then use the video ID to post it in the module.
+ * In the future it could also use the youtube developer API to get info and comments of the video.
+ *
+ * @param $node
+ *   object with node information
+ *
+ * @return
+ *   string of content to display
+ */
+function theme_video_youtube_play($node) {
+  $width = ($node->videox ? $node->videox : '425');
+  $height = ($node->videoy ? $node->videoy : '350');
+
+  $id = _video_youtube_get_id(check_plain($node->vidfile));
+  // this will be executed by not Internet Explorer browsers
+  $output = '<!--[if !IE]> <-->
+<object type="application/x-shockwave-flash" width="'. $width .'" height="'. $height .'"
+data="http://www.youtube.com/v/' . $id . '">
+<!--> <![endif]-->' . "\n";
+
+  // this will be executed by Internet Explorer
+  $output .= '<!--[if IE]>
+<object type="application/x-shockwave-flash" width="'. $width .'" height="'. $height .'"
+classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
+codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0">
+<![endif]-->' . "\n";
+
+  // params will be passed to both IE or not IE browsers
+  $output .= '<param name="movie" value="http://www.youtube.com/v/' . $id . '" />' . "\n"
+  . _video_get_parameters($node) .
+  '<p>'. t('Your browser is not able to display this multimedia content.') .'</p>
+</object>';
+
+
+  $output = _theme_video_format_play($output, t('http://www.google.com/support/youtube'), t('Link to youtube.com'), t('youtube.com'));
+  return $output;
+}
+
+
+/** HELPER FUNCTIONS */
+
+/**
+ * Get the id from an URL
+*/
+function _video_youtube_get_id($url) {
+  $parsed_url = parse_url($url);
+  parse_str($parsed_url['query'], $parsed_query);
+  return $parsed_query['v'];
+}
+
+
Index: video/video.install
===================================================================
--- video.orig/video.install	2007-06-28 13:35:26.000000000 -0700
+++ video/video.install	2007-06-28 13:35:39.000000000 -0700
@@ -8,6 +8,7 @@
       db_query("CREATE TABLE {video} (
         vid int(10) unsigned NOT NULL default '0',
         nid int(10) unsigned NOT NULL default '0',
+        vtype varchar(32) NOT NULL default '',
         vidfile text NOT NULL default '',
         videox smallint(4) unsigned NOT NULL default '0',
         videoy smallint(4) unsigned NOT NULL default '0',
@@ -36,6 +37,7 @@
       db_query("CREATE TABLE {video} (
         vid integer NOT NULL default '0',
         nid integer NOT NULL default '0',
+        vtype varchar(32) NOT NULL default '',
         vidfile text NOT NULL default '',
         videox smallint NOT NULL default '0',
         videoy smallint NOT NULL default '0',
@@ -156,3 +158,23 @@
   }
   return $ret;
 }
+
+
+/**
+ * Add the vtype field for video module subtypes
+ *
+ * @return array
+ */
+function video_update_5() {
+  $ret = array();
+  switch ($GLOBALS['db_type']) {
+    case 'mysql':
+    case 'mysqli':
+    case 'pgsql':
+      $ret[] = update_sql("ALTER TABLE {video} ADD vtype varchar(32) NOT NULL default ''");
+      //TODO: set the appropriate value to the newly added vtype field of existing nodes
+  }
+  return $ret;
+}
+
+
Index: video/video.module
===================================================================
--- video.orig/video.module	2007-06-28 13:35:26.000000000 -0700
+++ video/video.module	2007-06-28 13:35:39.000000000 -0700
@@ -48,12 +48,16 @@
       $help .= '<p>' . t('This is the field where you enter the video file information. The Video module currently supports these file types:') . '</p>';
       $help .= '<ul><li><b>' . t('.mov, .wmv, .rm, .flv, .swf, .dir, .dcr') . '</b><ul><li>' . t('To play these file types you need to enter in the path to the file. If your video is on the same webserver as drupal, you can use a path relative to the drupal directory, like "downloads/video.mov". If your video is on another server you can enter the URI to the video like "http://www.example.com/videos/my-video.mov".') . '</li></ul><br /></li>';
       $help .= '<li><b><a href="http://www.youtube.com">' . t('YouTube.com support') . '</a></b><ul><li>' . t('You can host videos on youtube.com and put them on your site. To do this, after you upload the video on youtube.com enter the video ID into the "Video File" field. If the URI youtube.com gives you for the video is "http://www.youtube.com/watch.php?v=XM4QYXPf-s8" you would enter "XM4QYXPf-s8".') . '</li></ul><br /></li>';
-      $help .= '<li><b><a href="http://video.google.com">' . t('Google Video support') . '</a></b><ul><li>' . t('You can host videos on video.google.com and put them on your site.
-  To do this, after you upload the video on Google video enter get the
-  the embed code. In this code you will find an attribute like
-  src="http://video.google.com/googleplayer.swf?docId=-1591729516923874694" .
-  You will need the -1591729516923874694 like number just after docId= .
-  Then use "google:-1591729516923874694" as video file value.') . '</li></ul></li></ul>';
+
+      // Get the video-type-specific help contents
+      $help_items = array();
+      //$help_items = array_merge($help_items, (array) module_invoke_all('v_help'));
+      //$help_items[] = (array) module_invoke_all('v_help');
+
+      print_r($help_items); //die;
+      print_r(module_invoke_all('v_help'));
+      return theme('item_list',module_invoke_all('v_help')); //$help_items);
+
       $help .= '<a name="multi-download"></a><h3>' . t('Multi-file Dowload Help') . '</h3>';
       $help .= '<p>' . t('If enabled, this group holds all the settings for multi-file downloads. Multi-file downloads allows you to have a list of any number of files on the download page. These files are usually scanned from a folder. This allows the listing of multiple sizes and video types for visitors to choose from, you can even zip the files up.') . '</p>';
       $help .= '<ul><li><b>' . t('Disable multi-file downloads') . '</b><ul><li>' . t('This checkbox will disable multi-file downloads for this video. This means the download tab and link will send visitors straight to download the same video as is set to play. Use this option if you only have one version of your video.') . '</li></ul><br /></li>';
@@ -91,6 +95,7 @@
     $items[] = array(
       'path' => 'node/add/video',
       'title' => t('Video'),
+      'callback' => 'video_add',
       'access' => user_access('create video'));
     $items[] = array(
         'path' => 'admin/content/video',
@@ -107,9 +112,9 @@
       if ($node = node_load(arg(1)) and $node->type == 'video') {
         if (variable_get('video_displayplaymenutab', 1) == 1) {
           $menu_type = MENU_LOCAL_TASK;
-        } 
+        }
         else {
-          $menu_type = MENU_CALLBACK;	     	
+          $menu_type = MENU_CALLBACK;
         }
         $items[] = array('path' => 'node/'. arg(1) .'/play',
           'title' => t('play'),
@@ -119,7 +124,7 @@
           'type' => $menu_type);
 
         //If the video is of type youtube and multi-file downloads aren't turned on don't show the download tab.
-        if (_video_get_filetype($node->vidfile) != 'youtube' and _video_get_filetype($node->vidfile) != 'googlevideo') {
+        if (video_is_downloadable($node->vtype)) {
           if (variable_get('video_displayplaymenutab', 1) == 1) {
             $menu_type = MENU_LOCAL_TASK;
           }
@@ -142,7 +147,7 @@
 
 /**
  * Implementation of hook_init()
- * Currently just does a check for whether the views module exists and, 
+ * Currently just does a check for whether the views module exists and,
  * if it does loads the video views module.
  */
 function video_init() {
@@ -165,7 +170,7 @@
  */
 function video_link($type, $node = NULL) {
   $link = array();
-  
+
   // Node links for a video
   if ($type == 'node' && $node->type == 'video' && $node->vidfile && user_access('access video')) {
     //If the video is of type youtube and multi-file downloads aren't turned on don't show the download link.
@@ -192,14 +197,14 @@
         $text .= ' ' . t('or') . ' ';
         $text .= l(t('register'), "user/register", array('class' => 'outgoing', 'title' => t('create a new account')));
         $text .= t(' to play video');
-      
+
         $link['video_play'] = array(
             'title' => $text,
             'html' => TRUE,
           );
-        
+
       }
-	}
+  }
     if ($display_download_link == 1) {
       $link['video_download'] = array(
         'title' => t('download'),
@@ -297,8 +302,8 @@
  *   string of form content or error message
  */
 function video_settings_form() {
-  global $base_url; 
-  
+  global $base_url;
+
   //Must have "administer site configuration" and "administer video" privilages.
   if (!user_access('administer video')) {
     drupal_access_denied();
@@ -312,7 +317,7 @@
     '#title' => t('Play in node'),
     '#options' => $options,
     '#default_value' => variable_get('video_playinbody', 1),
-    '#description' => t('Toggle display of video in the body of the node.')); 
+    '#description' => t('Toggle display of video in the body of the node.'));
   $form['tabs']['video_displayplaymenutab'] = array(
     '#type' => 'radios',
     '#title' => t('Display play menu tab'),
@@ -440,6 +445,101 @@
   }
 }
 
+
+/**
+ * Create video submission page. Let the user select the actived video types
+ * or display the video form for the selected video type
+*/
+function video_add() {
+  global $user;
+
+  $edit = isset($_POST['edit']) ? $_POST['edit'] : '';
+
+  // If a video type has been specified, validate its existence.
+
+  $vtypes = video_get_types();
+
+  if (arg(3) && in_array(arg(3), array_keys($vtypes))) { // is a valid video type
+    $type = arg(3);
+
+    // Initialize settings:
+    $node = (object) array('uid' => $user->uid, 'name' => $user->name, 'type' => 'video', 'vtype' => $type);
+
+    $output = drupal_get_form('video_node_form', $node);
+    drupal_set_title(t('Submit %name video', array('%name' => $type)));
+  }
+  else {
+    $output = video_types_page();
+  }
+  return $output;
+}
+
+
+/**
+ * Display a video types selection page
+*/
+function video_types_page() {
+
+  drupal_set_title(t('Submit Video')); // we have to set a titl ebecause the node module will not do it for us as we are using a callback video_add()
+
+  $out = '';
+  foreach (video_get_types_infos() as $vtype => $infos) {
+    $out = '<dt>'. l($infos['#name'], "node/add/video/$vtype", array('title' => t('Add a !s.', array('!s' => $infos['#name'])))) .'</dt>';
+    $out .= '<dd>'. $infos['#description'] .'</dd>';
+    $item[$vtype] = $out;
+  }
+
+  if (isset($item)) { // we have video types available
+    ksort($item);
+    $output = t('Choose from the following available video types:') .'<dl>'. implode('', $item) .'</dl>';
+  }
+  else {
+    $output = t('There are no Video types enabled.');
+  }
+  return $output;
+
+}
+
+
+/**
+ *  Return an array containing enabled Video Types
+ */
+function video_get_types(){
+  return array_keys(video_get_types_infos());
+}
+
+
+/**
+ *  Return an array containing informations on enabled Video Types
+ */
+function video_get_types_infos(){
+  static $infos = NULL;
+
+  if(!is_array($infos)) {
+    $infos = module_invoke_all('v_info');
+  }
+  return $infos;
+}
+
+
+/**
+ * Return the informations for a given video type
+*/
+function video_get_type_info($type) {
+  return module_invoke('video_'.$type, 'v_info');
+}
+
+
+/**
+ * Return true if a given video type is downloadable
+*/
+function video_is_downloadable($node) {
+  $info = video_get_type_info($type);
+  return $info['#downloadable'];
+}
+
+
+
 /**
  * Hook, displays the contents of the node form page for creating and editing nodes.
  *
@@ -451,7 +551,9 @@
  */
 function video_form($node) {
   //We must unserialize the array for display in the forms.
-  $node->serial_data = unserialize($node->serialized_data);
+  if($node->serial_data) {
+    $node->serial_data = unserialize($node->serialized_data);
+  }
   $form = array();
   $form['title'] = array('#type' => 'textfield', '#title' => t('Title'),
     '#size' => 60, '#maxlength' => 128, '#required' => TRUE,
@@ -467,87 +569,32 @@
     '#description' => t('An explanation of the additions or updates being made to help other authors understand your motivations.')
   );
 
-  $form['video'] = array('#type' => 'fieldset', '#title' => t('Video File'), '#weight' => -19);
-  $form['video']['vidfile'] = array(
-    '#type' => 'textfield',
-    '#title' => t('Video File'),
-    '#default_value' => $node->vidfile,
-    '#maxlength' => 700,
-    '#required' => TRUE,
-    '#weight' => -20,
-    '#description' => t('Put here the video file path. You can use either relative to the drupal root directory (something/video.mov) or absolute (http://www.example.com/videos/videos.mov). Windows Media currently requires a fully qualified URL to function. Flash movies may not play with spaces in the path or filename. To add youtube.com videos enter the video ID. If your video was at (http://www.youtube.com/watch.php?v=aBM4QYXPf-s) you would enter (aBM4QYXPf-s). To add Google videos you will need the docId values available on the embed code google provide with "google:" as heading. ') . l(t('More information.'), 'video/help', NULL, NULL, 'videofile'));
-  $form['video']['videox'] = array(
-    '#type' => 'textfield',
-    '#title' => t('Video Size Width (x)'),
-    '#required' => TRUE,
-    '#length' => 4,
-    '#maxlength' => 4,
-    '#default_value' => $node->videox,
-    '#description' => t('Horizontal video pixel size.'));
-  $form['video']['videoy'] = array(
-    '#type' => 'textfield',
-    '#title' => t('Video Size Height (y)'),
-    '#required' => TRUE,
-    '#length' => 4,
-    '#maxlength' => 4,
-    '#default_value' => $node->videoy,
-    '#description' => t('Vertical video pixel size.'));
+  // set an hidden field to store vtype informations
+  $form['vtype'] = array(
+    '#type' => 'hidden',
+    '#value' => $node->vtype
+  );
 
-  $form['video']['filesize'] = array('#type' => 'fieldset', '#title' => t('Filesize'));
-  $form['video']['filesize']['size'] = array(
-    '#type' => 'textfield',
-    '#title' => t('Size'),
-    '#required' => FALSE,
-    '#length' => 12,
-    '#maxlength' => 12,
-    '#default_value' => $node->size,
-    '#description' => t('If the video is on the local server the size will be set automatically. Otherwise enter a value. Entering 0 will turn the display off. Must be less than 2GB.'));
-  $form['video']['filesize']['size_format'] = array(
-    '#type' => 'select',
-    '#title' => t('size units'),
-    '#options' => array('B' => t('bytes'), 'Kb' => t('Kilobits'), 'KB' => t('KiloBytes'), 'Mb' => t('Megabits'), 'MB' => t('MegaBytes'), 'Gb' => t('Gigabits'), 'GB' => t('GigaBytes')),
-    '#default_value' => 'B');
-
-  $form['video']['playtime'] = array('#type' => 'fieldset', '#title' => t('Playtime'), '#description' => t('Values may be entered in excess of their normal "clock maximum" (the seconds field may be 3600 to represent 1 hour), however each value will be summed for a total of all three.'));
-  $playtime = _video_sec2hms($node->playtime_seconds);
-  $form['video']['playtime']['playtime_hours'] = array(
-    '#type' => 'textfield',
-    '#title' => t('Hours'),
-    '#length' => 11,
-    '#maxlength' => 11,
-    '#default_value' => $playtime['hours'],
-    '#description' => t('Integer of hours.'));
-  $form['video']['playtime']['playtime_minutes'] = array(
-    '#type' => 'textfield',
-    '#title' => t('Minutes'),
-    '#length' => 11,
-    '#maxlength' => 11,
-    '#default_value' => $playtime['minutes'],
-    '#description' => t('Integer of minutes.'));
-  $form['video']['playtime']['playtime_seconds'] = array(
-    '#type' => 'textfield',
-    '#title' => t('Seconds'),
-    '#required' => TRUE,
-    '#length' => 11,
-    '#maxlength' => 11,
-    '#default_value' => $playtime['seconds'],
-    '#description' => t('Integer of seconds.'));
+  $form['video'] = array('#type' => 'fieldset', '#title' => t('Video Informations'), '#weight' => -19);
+
+  // Get the video-type-specific bits.
+  $form = module_invoke('video_' . $node->vtype, 'v_form', $node, $form);
 
   return $form;
 }
 
 /**
  * Form API callback to validate the upload settings form.
- * 
+ *
  * Keeps the use from showing the play tab or the play link
  * if they have chosen to display the video in the node body.
- * 
+ *
  * @param $form_id
  *   The identifier of the form
- * 
+ *
  * @param $form_values
  *   form values from the settings page
- * 
+ *
  */
 function video_settings_form_validate($form_id, $form_values){
   // If the user has selected to play videos in the body
@@ -583,8 +630,8 @@
 
   $node->serialized_data = serialize($node->serial_data); //Serialize the data for insertion into the database.
 
-  return db_query("INSERT INTO {video} (vid, nid, vidfile, size, videox, videoy, video_bitrate, audio_bitrate, audio_sampling_rate, audio_channels, playtime_seconds, disable_multidownload, download_folder, use_play_folder, custom_field_1, custom_field_2, custom_field_3, custom_field_4, custom_field_5, custom_field_6, serialized_data) VALUES (%d, %d, '%s', %d, %d, %d, %d, %d, %d, '%s', %d, %d, '%s', %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s')",
-    $node->vid, $node->nid, $node->vidfile, $node->size, $node->videox, $node->videoy, $node->video_bitrate, $node->audio_bitrate, $node->audio_sampling_rate, $node->audio_channels, $node->playtime_seconds, $node->disable_multidownload, $node->download_folder, $node->use_play_folder, $node->custom_field_1, $node->custom_field_2, $node->custom_field_3, $node->custom_field_4, $node->custom_field_5, $node->custom_field_6, $node->serialized_data);
+  return db_query("INSERT INTO {video} (vid, nid, vtype, vidfile, size, videox, videoy, video_bitrate, audio_bitrate, audio_sampling_rate, audio_channels, playtime_seconds, disable_multidownload, download_folder, use_play_folder, custom_field_1, custom_field_2, custom_field_3, custom_field_4, custom_field_5, custom_field_6, serialized_data) VALUES (%d, %d, '%s', '%s', %d, %d, %d, %d, %d, %d, '%s', %d, %d, '%s', %d, '%s', '%s', '%s', '%s', '%s', '%s', '%s')",
+    $node->vid, $node->nid, $node->vtype, $node->vidfile, $node->size, $node->videox, $node->videoy, $node->video_bitrate, $node->audio_bitrate, $node->audio_sampling_rate, $node->audio_channels, $node->playtime_seconds, $node->disable_multidownload, $node->download_folder, $node->use_play_folder, $node->custom_field_1, $node->custom_field_2, $node->custom_field_3, $node->custom_field_4, $node->custom_field_5, $node->custom_field_6, $node->serialized_data);
 }
 
 
@@ -653,7 +700,11 @@
  *   object
  */
 function video_validate($node) {
-  if (_video_get_filetype($node->vidfile) != 'youtube' and _video_get_filetype($node->vidfile) != 'googlevideo') { //If video is of type youtube don't check size.
+
+  module_invoke('video_'.$node->vtype, 'v_validate', $node);
+
+  /*
+  if ($node->vtype != 'youtube' and $node->vtype != 'google') { //If video is of type youtube don't check size.
     if (isset($node->videox) && $node->videox <= 0) {
       form_set_error('videox', t('You have to insert a valid horizontal pixel size for this video'));
     }
@@ -661,17 +712,22 @@
       form_set_error('videoy', t('You have to insert a valid vertical pixel size for this video'));
     }
   }
+
+  /*
   //Make sure file size is valid.
   $path = getcwd() . '/' . $node->vidfile; //Local path to video file.
   if ((!isset($node->size) || !is_numeric($node->size) || $node->size < 0) && !$_SESSION['video_upload_file']) { //If the file is not local or not a valid number then set error. $_SESSION check needed for video_upload functionality
     form_set_error('size', t('You have to insert a valid file size for this video.'));
   }
-  
+  */
+
+  /*
   //Makes sure the total playtime is greater than 0.
   $time = $node->playtime_seconds + $node->playtime_minutes + $node->playtime_hours;
   if ((isset($node->playtime_minutes) and isset($node->playtime_hours) and isset($node->playtime_seconds)) and $time == 0) {
     form_set_error('playtime_seconds', t('Please enter valid playtime information for this video.'));
   }
+  */
 }
 
 /**
@@ -701,11 +757,12 @@
  *   Nothing, modifies $node which is passed by reference.
  */
 function video_view(&$node, $teaser = FALSE, $page = FALSE) {
-  $node = node_prepare($node, $teaser); //Run the body through the standard filters.
 
   // include the video css file
   drupal_add_css(drupal_get_path('module', 'video').'/video.css');
-  $node->content['body'] = array('#value' => $node->body);
+
+  //Run the body through the standard filters.
+  $node = node_prepare($node, $teaser);
 
   // theme the teaser
   $node->teaser = theme('video_teaser', $node, $teaser, $page);
@@ -713,19 +770,19 @@
   // if we are viewing the page, run the body through the theme
   if ($page) {
     $output = '';
-	if (variable_get('video_playinbody', 0)) {
-	  if (user_access('play video')) {
-        $output .= theme('video_player', $node);
-      }
-	  else {
-	    $output .= l(t('login'), "user/login", array('class' => 'outgoing', 'title' => t('login to your account')));
+    if (variable_get('video_playinbody', 0)) {
+      if (user_access('play video')) {
+          $node->content['video_player'] = array('#value' => theme('video_player', $node), '#weight' => -1);
+        }
+      else {
+        $output .= l(t('login'), "user/login", array('class' => 'outgoing', 'title' => t('login to your account')));
         $output .= ' ' . t('or') . ' ';
         $output .= l(t('register'), "user/register", array('class' => 'outgoing', 'title' => t('create a new account')));
         $output .= t(' to play video');
+        $output .= theme('video_view', $node, $teaser, $page);
+        $node->content['body'] = array('#value' => $output);
       }
-	}
-    $output .= theme('video_view', $node, $teaser, $page);
-	$node->content['body'] = array('#value' => $output);
+    }
   }
 
   return $node;
@@ -882,8 +939,8 @@
 function video_play() {
   if ($node = node_load(arg(1))) {
     drupal_set_title(t('Playing') . ' ' . theme('placeholder', $node->title));
-	$output = theme('video_player', $node);
-    if($output == ''){
+  $output = theme('video_player', $node);
+    if($output == '' && !variable_get('video_playinbody', 1)){
       drupal_goto("node/$node->nid");
     }
     return $output;
@@ -895,17 +952,17 @@
 
 /**
  * Theme the teaser
- * 
+ *
  * This is just in place for site admins and theme developers
  * who need to adjust how the teaser is themed.
- * 
+ *
  * @param $node
  *   The node to be displayed.
- * @param $teaser 
+ * @param $teaser
  *   Whether we are to generate a "teaser" or summary of the node, rather than display the whole thing.
- * @param $page 
+ * @param $page
  *   Whether the node is being displayed as a standalone page. If this is TRUE, the node title should not be displayed, as it will be printed automatically by the theme system. Also, the module may choose to alter the default breadcrumb trail in this case.
- * 
+ *
  * @return
  *   html
  */
@@ -916,14 +973,14 @@
 /**
  * theme the view of the page to include the video
  * assumes that body was put through prepare in hook_view
- * 
+ *
  * @param $node
  *   The node to be displayed.
- * @param $teaser 
+ * @param $teaser
  *   Whether we are to generate a "teaser" or summary of the node, rather than display the whole thing.
- * @param $page 
+ * @param $page
  *   Whether the node is being displayed as a standalone page. If this is TRUE, the node title should not be displayed, as it will be printed automatically by the theme system. Also, the module may choose to alter the default breadcrumb trail in this case.
- * 
+ *
  * @return
  *   html
  */
@@ -933,10 +990,10 @@
 
 /**
 * theme function to control which player is presented
-* 
+*
 * @param $node
 *   node object
-* 
+*
 * @return
 *   html
 */
@@ -947,491 +1004,20 @@
   if (variable_get('video_playcounter', 1)) {
     db_query("UPDATE {video} SET play_counter = play_counter + 1 where vid = %d", $node->vid); //Increment play counter.
   }
-    
-  switch (_video_get_filetype($node->vidfile)) {
-    case 'divx':
-      return theme('video_play_divx', $node);
-    case 'mov':
-    case 'mp4':
-    case '3gp':
-    case '3g2':
-      return theme('video_play_quicktime', $node);
-    case 'rm':
-      return theme('video_play_realmedia', $node);
-    case 'flv':
-      return theme('video_play_flash', $node);
-    case 'swf':
-      return theme('video_play_swf', $node);
-    case 'dir':
-    case 'dcr':
-      return theme('video_play_dcr', $node);
-    case 'asf':
-    case 'wmv':
-      return theme('video_play_windowsmedia', $node);
-    case 'ogg':
-      return theme('video_play_ogg_theora', $node);
-    case 'youtube':
-      return theme('video_play_youtube', $node);
-    case 'googlevideo':
-      return theme('video_play_googlevideo', $node);
-    default:
-      drupal_set_message('Video type not supported', 'error');
+
+  $output = module_invoke('video_'.$node->vtype, 'v_play', $node);
+  if($output != '') {
+    return $output;
+  }
+  else {
+    drupal_set_message('Video type not supported', 'error');
+    if(!variable_get('video_playinbody', 1)) {
       drupal_goto("node/$node->nid");
-      break;
+      return;
+    }
   }
 }
 
-/*********************************************************************
- * Themeable functions for playing videos. They print a page with a player embedded.
- *********************************************************************/
-
-/**
- * Play videos from in FLV Flash video format
- *
- * @param $node
- *   object with node information
- *
- * @return
- *   string of content to display
- */
-function theme_video_play_flash($node) {
-  $loader_location = variable_get('video_flvplayerloader', 'FlowPlayer.swf');
-  
-  $url = _video_get_fileurl($node->vidfile);
-  $file = basename($url);
-  $base_url = substr($url, 0, strrpos($url, '/'));
-  
-  $height = $node->videoy + 24; // add commands height
-
-  // this will be executed by not Internet Explorer browsers
-  $output = '<!--[if !IE]> <-->
-<object type="application/x-shockwave-flash" width="'. $node->videox .'" height="'. $height .'"
-data="'. url() . check_plain($loader_location) .'">
-<!--> <![endif]-->' . "\n";
-
-  // this will be executed by Internet Explorer
-  $output .= '<!--[if IE]>
-<object type="application/x-shockwave-flash" width="'. $node->videox .'" height="'. $height .'"
-classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
-codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0">
-<![endif]-->' . "\n";
-
-  // params will be passed to both IE or not IE browsers
-  $output .= '<param name="movie" value="' . url() . check_plain($loader_location) . '" />
-               <param name="allowScriptAccess" value="sameDomain" />
-               <param name="quality" value="high" />
-               <param name="flashvars" value="config={baseURL:\''. $base_url .'\',videoFile:\''. $file .'\',autoPlay:true,bufferLength:5}" />' . "\n"
-  . _video_get_parameters($node) .
-  '<p>'. t('Your browser is not able to display this multimedia content.') .'</p>
-</object>';
-
-  $output = _theme_video_format_play($output, t('http://www.macromedia.com/go/getflashplayer'),
-                                      t('Link to Macromedia Flash Player Download Page'),
-                                      t('Download latest Flash Player'));
-   return $output;
-}
-
-/**
- * Play Flash .swf files.
- *
- * @param $node
- *   object with node information
- *
- * @return
- *   string of content to display
- */
-function theme_video_play_swf($node) {
-
-  $url = _video_get_fileurl($node->vidfile);
-  
-  // this will be executed by not Internet Explorer browsers
-  $output = '<!--[if !IE]> <-->
-<object type="application/x-shockwave-flash" width="'. $node->videox .'" height="'. $node->videoy .'"
-data="'. $url .'">
-<!--> <![endif]-->' . "\n";
-
-  // this will be executed by Internet Explorer
-  $output .= '<!--[if IE]>
-<object type="application/x-shockwave-flash" width="'. $node->videox .'" height="'. $node->videoy .'"
-classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
-codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0">
-<![endif]-->' . "\n";
-
-  // params will be passed to both IE or not IE browsers
-  $output .= '<param name="movie" value="'. $url .'" />' . "\n"
-  . _video_get_parameters($node) .
-  '<p>'. t('Your browser is not able to display this multimedia content.') .'</p>
-</object>';
-
-  $output = _theme_video_format_play($output, t('http://www.macromedia.com/go/getflashplayer'), t('Link to Flash player download'), t('Download the latest Flash player'));
-  return $output;
-}
-
-
-
-/**
- * Play Director .dcr/.dir files.
- *
- * @param $node
- *   object with node information
- *
- * @return
- *   string of content to display
- */
-
-function theme_video_play_dcr($node) {
-  
-  $url = _video_get_fileurl($node->vidfile);
-
-  // this will be executed by not Internet Explorer browsers
-  $output = '<!--[if !IE]> <-->
-<object type="application/x-director" width="'. $node->videox .'" height="'. $node->videoy .'"
-data="'. $url .'">
-<!--> <![endif]-->' . "\n";
-
-  // this will be executed by Internet Explorer
-  $output .= '<!--[if IE]>
-<object type="application/x-director" width="'. $node->videox .'" height="'. $node->videoy .'"
-classid="clsid:166B1BCA-3F9C-11CF-8075-444553540000"
-codebase="http://download.macromedia.com/pub/shockwave/cabs/director/sw.cab#version=10,0,0,0">
-<![endif]-->' . "\n";
-
-// params will be passed to both IE or not IE browsers
-  $output .= '<param name="src" value="'. $url .'" />' . "\n"
-  . _video_get_parameters($node) .
-  '<p>'. t('Your browser is not able to display this multimedia content.') .'</p>
-</object>';
-
-  $output = _theme_video_format_play($output, t('http://www.macromedia.com/shockwave/download/'),
-                                      t('Link to Macromedia Shockwave Player Download Page'),
-                                      t('Download latest Shockwave Player'));
-   return $output;
-}
-
-/**
- * Play videos from in DivX format
- *
- * @see http://developer.apple.com/internet/ieembedprep.html
- * @param $node
- *   object with node information
- *
- * @return
- *   string of content to display
- */
-function theme_video_play_divx($node) {
-  //Increase the height to accommodate the player controls on the bottom.
-  $height = $node->videoy + 20;
-  
-  $url = _video_get_fileurl($node->vidfile);
-  
-  $output = '<!-- [if IE] -->
-<object classid="clsid:67DABFBF-D0AB-41fa-9C46-CC0F21721616" width="'.$node->videox.'" height="'.$height.'" codebase="http://go.divx.com/plugin/DivXBrowserPlugin.cab">
-<!--> <![endif]-->'. "\n";
-	// this will be executed by not Internet Explorer browsers
-  $output = '<!-- [if !IE] --> 
-<object type="video/divx" data="'.$url.'" width="'.$node->videox.'" height="'.$height.'" mode="zero"> 
-<!--> <![endif]-->'."\n";
-  	
- 	$output .= '<param name="src" value="'.$url.'"/>'."\n";
-  $output .= '<param name="mode" value="zero"/>'."\n";
-  $output .= '</object>';
-  $output = _theme_video_format_play($output,t('http://www.divx.com/divx/webplayer/'),
-                                     t('Link to DivX Download Page'),
-                                     t('Download latest DivX Web Player'));
-  return $output;
-}
-
-/**
- * Play videos from in Quicktime format
- *
- * @see http://developer.apple.com/internet/ieembedprep.html
- * @param $node
- *   object with node information
- *
- * @return
- *   string of content to display
- */
-function theme_video_play_quicktime($node) {
-  //Increase the height to accommodate the player controls on the bottom.
-  $height = $node->videoy + 16;
-  
-  $url = _video_get_fileurl($node->vidfile);
-
-
-  // this will be executed by not Internet Explorer browsers
-  $output = '<!--[if !IE]> <-->
-<object type="video/quicktime" width="'. $node->videox .'" height="'. $height .'"
-data="'. $url .'">
-<!--> <![endif]-->' . "\n";
-
-  // this will be executed by Internet Explorer
-  $output .= '<!--[if IE]>
-<object classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B" codebase="http://www.apple.com/qtactivex/qtplugin.cab" width="'. $node->videox .'" height="'. $height .'" scale="tofit" >
-<![endif]-->' . "\n";
-
-  // params will be passed to both IE or not IE browsers
-   $output .= '<param name="src" value="'. $url .'" />
-              <param name="AUTOPLAY" value="true" />
-              <param name="KIOSKMODE" value="false" />' . "\n"
-   . _video_get_parameters($node) .
-   '<p>'. t('Your browser is not able to display this multimedia content.') .'</p>
-</object>'; // only one </object> needed becouse only one opening tag has been parsed by browsers
-
-
-  /*
-  $output = '<script language="JavaScript" type="text/javascript">';
-  $output .= "InsertQuicktimeVideo('{$node->vidfile}','$height','{$node->videox}');";
-  $output .= '</script>';
-  */
-
-
-  $output = _theme_video_format_play($output, t('http://www.apple.com/quicktime/download'),
-                                      t('Link to QuickTime Download Page'),
-                                      t('Download latest Quicktime Player'));
-  return $output;
-}
-
-/**
- * Play videos from in Realmedia format
- *
- * @param $node
- *   object with node information
- *
- * @return
- *   string of content to display
- */
-function theme_video_play_realmedia($node) {
-  // Real's embeded player includes the controls
-  // in the height
-  $node->videoy += 40;
-  
-  $url = _video_get_fileurl($node->vidfile);
-  
-  // this will be executed by not Internet Explorer browsers
-  $output = '<!--[if !IE]> <-->
-<object type="audio/x-pn-realaudio-plugin" width="'. $node->videox .'" height="'. $node->videoy .'"
-data="'. $url .'">
-<!--> <![endif]-->' . "\n";
-
-  // this will be executed by Internet Explorer
-  $output .= '<!--[if IE]>
-<object type="audio/x-pn-realaudio-plugin" width="'. $node->videox .'" height="'. $node->videoy .'"
-classid="clsid:CFCDAA03-8BE4-11cf-B84B-0020AFBBCCFA" >
-<![endif]-->' . "\n";
-
-  // params will be passed to both IE or not IE browsers
-   $output .= '<param name="src" value="'. $url .'" />
-              <param name="_ExtentX" value="7276" />
-              <param name="" value="3307" />
-              <param name="AUTOSTART" value="true" />
-              <param name="SHUFFLE" value="0" />
-              <param name="PREFETCH" value="0" />
-              <param name="NOLABELS" value="0" />
-              <param name="CONTROLS" value="All" />
-              <param name="CONSOLE" value="Clip1" />
-              <param name="LOOP" value="0" />
-              <param name="NUMLOOP" value="0" />
-              <param name="CENTER" value="0" />
-              <param name="MAINTAINASPECT" value="1" />
-              <param name="BACKGROUNDCOLOR" value="#000000" />'
-   . _video_get_parameters($node) .
-   '<p>'. t('Your browser is not able to display this multimedia content.') .'</p>
-</object>'; // only one </object> needed becouse only one opening tag has been parsed by browsers
-
-
-  $output = _theme_video_format_play($output, t('http://www.real.com/'),
-                                      t('Link to Real'),
-                                      t('Download latest Realmedia Player'));
-  return $output;
-}
-
-/**
- * Play videos from in WindowsMediaVideo format
- *
- * @param $node
- *   object with node information
- *
- * @return
- *   string of content to display
- */
-function theme_video_play_windowsmedia($node) {
-  // Windows Media's embeded player includes the controls in the height
-  $node->videoy += 68;
-  $url = _video_get_fileurl($node->vidfile);
-
-  // this will be executed by not Internet Explorer browsers
-  $output = '<!--[if !IE]> <-->
-<object type="application/x-mplayer2" width="'. $node->videox .'" height="'. $node->videoy .'"
-data="'. $url .'">
-<!--> <![endif]-->' . "\n";
-
-  // this will be executed by Internet Explorer
-  $output .= '<!--[if IE]>
-<object type="application/x-oleobject" width="'. $node->videox .'" height="'. $node->videoy .'"
-classid="clsid:6BF52A52-394A-11d3-B153-00C04F79FAA6" >
-<![endif]-->' . "\n";
-
-  // params will be passed to both IE or not IE browsers
-   $output .= '<param name="src" value="'. $url .'" />
-              <param name="URL" value="'.$url.'" />
-              <param name="animationatStart" value="true" />
-              <param name="transparentatStart" value="true" />
-              <param name="autoStart" value="true" />
-              <param name="showControls" value="true" />
-              <param name="loop" value="true" />'
-   . _video_get_parameters($node) .
-   '<p>'. t('Your browser is not able to display this multimedia content.') .'</p>
-</object>'; // only one </object> needed becouse only one opening tag has been parsed by browsers
-
-
-  $output = _theme_video_format_play($output, t('http://windowsupdate.microsoft.com/'),
-                                      t('Link to Windows Update'),
-                                      t('Download latest Windows Media Player'));
-  return $output;
-}
-
-/**
- * Play videos hosted on youtube.com
- * Allows users to host videos on youtube.com and then use the video ID to post it in the module.
- * In the future it could also use the youtube developer API to get info and comments of the video.
- *
- * @param $node
- *   object with node information
- *
- * @return
- *   string of content to display
- */
-function theme_video_play_youtube($node) {
-  $width = ($node->videox ? $node->videox : '425');
-  $height = ($node->videoy ? $node->videoy : '350');
-
-
-  // this will be executed by not Internet Explorer browsers
-  $output = '<!--[if !IE]> <-->
-<object type="application/x-shockwave-flash" width="'. $width .'" height="'. $height .'"
-data="http://www.youtube.com/v/' . check_plain($node->vidfile) . '">
-<!--> <![endif]-->' . "\n";
-
-  // this will be executed by Internet Explorer
-  $output .= '<!--[if IE]>
-<object type="application/x-shockwave-flash" width="'. $width .'" height="'. $height .'"
-classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
-codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0">
-<![endif]-->' . "\n";
-
-  // params will be passed to both IE or not IE browsers
-  $output .= '<param name="movie" value="http://www.youtube.com/v/' . check_plain($node->vidfile) . '" />' . "\n"
-  . _video_get_parameters($node) .
-  '<p>'. t('Your browser is not able to display this multimedia content.') .'</p>
-</object>';
-
-
-  $output = _theme_video_format_play($output, t('http://www.google.com/support/youtube'), t('Link to youtube.com'), t('youtube.com'));
-  return $output;
-}
-
-/**
- * Play videos hosted on video.google.com
- * Allows users to host videos on video.google.com and then use the video ID to post it in the module.
- *
- * @param $node
- *   object with node information
- *
- * @return
- *   string of content to display
- */
-function theme_video_play_googlevideo($node) {
-  $width = ($node->videox ? $node->videox : '425');
-  $height = ($node->videoy ? $node->videoy : '350');
-  // Strip heading "google:"
-  $videoid = substr($node->vidfile, 7);
-
-  // this will be executed by not Internet Explorer browsers
-  $output = '<!--[if !IE]> <-->
-<object type="application/x-shockwave-flash" width="'. $width .'" height="'. $height .'"
-data="http://video.google.com/googleplayer.swf?docId='. check_plain($videoid) .'">
-<!--> <![endif]-->' . "\n";
-
-  // this will be executed by Internet Explorer
-  $output .= '<!--[if IE]>
-<object type="application/x-shockwave-flash" width="'. $width .'" height="'. $height .'"
-classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000"
-codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0">
-<![endif]-->' . "\n";
-
-  // params will be passed to both IE or not IE browsers
-  $output .= '<param name="movie" value="http://video.google.com/googleplayer.swf?docId=' . check_plain($videoid) . '" />' . "\n";
-  // following a list of params simply copied from old embed tag params. I don't know if this are really needed.
-  $output .= '<param name="quality" value="best" />
-  <param name="bgcolor" value="#ffffff" />
-  <param name="allowScriptAccess" value="sameDomain" />
-  <param name="scale" value="noScale" />
-  <param name="wmode" value="window" />
-  <param name="salign" value="TL" />
-  <param name="FlashVars" value="playerMode=embedded" />'
-  . _video_get_parameters($node) .
-  '<p>'. t('Your browser is not able to display this multimedia content.') .'</p>
-</object>';
-
-
-  $output = _theme_video_format_play($output, t('http://video.google.com/support'), t('Link to video.google.com'), t('video.google.com'));
-  return $output;
-}
-
-/**
- * Play Ogg Theora videos with Cortado Applet
- *
- * @param $node
- *   object with node information
- *
- * @return
- *   string of content to display
- */
-function theme_video_play_ogg_theora($node) {
-  global $base_url;
-  $cortado_location = variable_get('video_cortado', $base_url . '/cortado.jar');  
-  $url = _video_get_fileurl($node->vidfile);
-  
-  $width = ($node->videox ? $node->videox : '425');
-  $height = ($node->videoy ? $node->videoy : '350');
-  
-  $output = '
-  <!--[if !IE]>-->
-  <object classid="java:com.fluendo.player.Cortado.class" 
-          type="application/x-java-applet"
-          archive="' . $cortado_location . '" 
-          width="' . $width . '" height="' . $height . '" >
-  <!--<![endif]-->
-    <object classid="clsid:8AD9C840-044E-11D1-B3E9-00805F499D93" 
-              codebase="http://java.sun.com/update/1.5.0/jinstall-1_5_0-windows-i586.cab"
-              width="' . $width . '" height="' . $height . '" > 
-        <param name="code" value="com.fluendo.player.Cortado" />
-    <!--[if !IE]>-->
-    </object> 
-    <!--<![endif]-->
-      <!-- IE and Konqueror browser need the archive param -->
-      <param name="archive" value="' . $cortado_location . '" />
-      <param name="url" value="' . $url . '"/>
-      <param name="local" value="false" />
-      <param name="keepaspect" value="true" />
-      <param name="video" value="true" />
-      <param name="audio" value="true" />
-      <param name="seekable" value="true" />
-      <param name="duration" value="' . $node->playtime_seconds . '" />
-      <param name="bufferSize" value="200" /> 
-      <strong>
-          This browser does not have a Java Plug-in.<br />
-          <a href="http://java.com/download/">
-            Get the latest Java Plug-in here.
-          </a>
-      </strong>       
-  </object>
-  ';
-
-  $output = _theme_video_format_play($output, 
-    t('http://java.com/download/'), t('Link to java.com'), t('Download Java'));
-  return $output;
-}
 
 /**
  * Cut down on redundant link text
@@ -1531,9 +1117,9 @@
  */
 function _video_download_goto($input_url, $vid) {
   if (user_access('download video')) {
-    
+
     $url = _video_get_fileurl($input_url);
-    
+
     if (variable_get('video_downloadcounter', 1)) {
       db_query("UPDATE {video} SET download_counter = download_counter + 1 where vid = %d", $vid); //Increment download counter.
     }
@@ -1623,7 +1209,7 @@
  */
 function _video_get_fileurl($video_file) {
   global $base_url;
-  
+
   //creation of absolute url
   if (preg_match("/^(http|ftp|mm|rstp)(s?):\/\//", $video_file)) { //If path is absolute
     return check_plain($video_file);
Index: video/views_video.inc
===================================================================
--- video.orig/views_video.inc	2007-06-28 13:35:26.000000000 -0700
+++ video/views_video.inc	2007-06-28 13:35:39.000000000 -0700
@@ -89,7 +89,7 @@
       'help' => t('This will display the thumbnail image for the video.'),
       );
   }
-  
+
   return $tables;
 }
 
@@ -102,7 +102,7 @@
 **/
 function video_views_default_views() {
   $views = array();
- 
+
   // recent video node activity view
   $view = new stdClass();
   $view->name = 'video_tracker';
@@ -171,7 +171,7 @@
   $view->exposed_filter = array ();
   $view->requires = array(node, users, video);
   $views[$view->name] = $view;
- 
+
   return $views;
 }
 
@@ -200,20 +200,20 @@
 function video_views_handler_field_playtime_seconds($fieldinfo, $fielddata, $value, $data) {
   $seconds = $value;
   $hms = _video_sec2hms($seconds);
- 
+
   // Pad the minutes / seconds with a leading "0", if
   // necessary
   if ($hms['hours'] > 0) {
     $hms['minutes'] = str_pad($hms['minutes'], 2, '0', STR_PAD_LEFT);
   }
   $hms['seconds'] = str_pad($hms['seconds'], 2, '0', STR_PAD_LEFT);
-  
+
   $out = '';
   if ($hms['hours'] > 0) {
  $out .= $hms['hours'].":";
   }
   $out .= $hms['minutes'].":".$hms['seconds'];
-  
+
   return t($out);
 }
 
