' . t('The FlashVideo module for Drupal 5.x is an easy to use module that expands the Upload module by allowing users to upload videos and attach those videos to any content. Even more exciting, is that FlashVideo automatically performs the very common Flash format conversion as well as create an image thumbnail of any newly uploaded video for every cron cycle. Once the video is in Flash format, the video can then be embedded in that node using the very simple [video] tag.') . '

'; $output .= '

' . t('To enable this module for a certain node type, you must first go to the ' . l(t('FlashVideo Settings'), 'admin/settings/flashvideo') . ' and select the FlashVideo settings for any available node type in the Drupal system. Once the FlashVideo module has been enabled for that node type, you will then notice the modified Upload form when you add new content for that node type.') . '

'; $output .= '

' . t('Once a video has been uploaded, it will then have to wait for the next Cron cycle for the conversion to Flash format to begin. You can manually run the cron operation by going to Administer->Logs->Status Report and then click on the link that says run cron manually. After the video has been converted, it will then be available to any node referencing that video. That node can then reference the video by using the [video] tag, and also reference the video thumbnail by providing the [thumbnail] tag.') . '

'; $output .= '

' . t('Parameters for these tags are provided by using a ":" to indicate a new parameter is being provided. The following format should be used for both the [video] and [thumbnail] tags. [video: param=value ] where param is the name of the parameter being passed, and value is the value of the parameter.') . '

'; $output .= '

' . t('The following parameters can be used...') . '

'; $output .= t(''); $output .= '

' . t('The following are examples of using the [video] and [thumbail] tag system...') . '

'; $output .= t(''); return $output; case 'admin/settings/modules#description': return t('Allows you to insert videos into nodes.'); } } /** * Implementation of hook_perm(). */ function flashvideo_perm() { return array('administer flashvideo'); } /** * Checks all of their PHP settings to make sure that their PHP directives are all set according to the recommended settings. */ function _flashvideo_get_php_settings() { $file_uploads = ini_get('file_uploads'); // Whether or not to allow HTTP file uploads $post_max_size = ini_get('post_max_size'); // Get their Max Post size. $upload_max_filesize = ini_get('upload_max_filesize'); // Get their Max Upload size. $max_execution_time = ini_get('max_execution_time'); // Get their Max Execution Time. $max_input_time = ini_get('max_input_time'); // This sets the maximum time in seconds a script is allowed to parse input data, like POST, GET and file uploads // Give them an error if they have file uploads turned off. if($file_uploads != "1") { drupal_set_message('File uploads (file_uploads) are not enabled in your php.ini file. The FlashVideo module will not work unless this directive is set.', 'error'); } // Give them a warning message if they don't have FFMPEG installed. if(!extension_loaded("ffmpeg")) { drupal_set_message('FlashVideo has determined that you do not have FFMPEG installed on this machine. You can still use this module without FFMPEG, however server-side video conversions will not occur.'); } $output = '

IMPORTANT NOTE:  In order for the FlashVideo module to work according to design, '; $output .= 'some parameters need to be set in your php.ini file or the root .htaccess file. These parameters are as follows...

'; $output .= '

'; $output .= '

The following shows the recommended values for these parameters followed by your current settings.

'; $output .= '

'; $output .= '

Warning: Please consult your hosting provider or a professional before making the Recommeneded changes. Drupal or the writers of the FlashVideo module will not be held responsible for any malfunctions due to this change. Change these PHP settings at your own risk!


'; return $output; } /** * Implements play callback function from node menu */ function flashvideo_play($video) { // include video.js file for Internet Explorer fixes theme('flashvideo_get_script'); switch (_flashvideo_get_filetype($video['file'])) { case 'mpeg': case 'mpg': case 'mov': case 'mp4': case '3gp': case '3g2': return theme('flashvideo_play_quicktime', $video); case 'rm': return theme('flashvideo_play_realmedia', $video); case 'flv': case 'playlist': return theme('flashvideo_play_flash', $video); case 'swf': return theme('flashvideo_play_swf', $video); case 'dir': case 'dcr': return theme('flashvideo_play_dcr', $video); case 'wmv': case 'avi': return theme('flashvideo_play_windowsmedia', $video); case 'ogg': return theme('flashvideo_play_ogg_theora', $video); case 'youtube': return theme('flashvideo_play_youtube', $video); case 'googlevideo': return theme('flashvideo_play_googlevideo', $video); case 'brightcove': return theme('flashvideo_play_brightcove', $video); default: return _flashvideo_get_filetype($video['file']) . ' filetypes are not supported'; break; } } /** * Implementation of hook_form_alter() */ function flashvideo_form_alter($form_id, &$form) { if (isset($form['type'])) { $node_type = $form['type']['#value']; if($form_id == $node_type.'_node_form') { //We want to move the File attachments to the top and also change a couple of parameters. if(variable_get('flashvideo_'. $node_type .'_enable', 0)) { if( isset($form['attachments']) ) { $form['attachments']['#title'] = variable_get('flashvideo_'. $node_type .'_upload_title', t('Video Upload')); $form['attachments']['#collapsed'] = FALSE; $form['attachments']['#weight'] = variable_get('flashvideo_'. $node_type .'_weight', -10); $form['attachments']['#required'] = variable_get('flashvideo_'. $node_type .'_require', 0); } } /* Not quite ready yet... // This will add a text box that will allow the users to submit object code from other websites. if(variable_get('flashvideo_' . $node_type . '_enable_embeded_filter', 0)) { $form['embededfilter']['#title'] = t('Video URL or Video Object Code'); $form['embededfilter']['#description'] = t("Copy the object code or the video URL from any of the following websites, and paste it here.\n"); $form['embededfilter']['#default_value'] = $form['#node']->video_object; //$form['embededfilter']['#default_value'] = flashvideo_get_video($form['#node']); $form['embededfilter']['#type'] = 'textarea'; $form['embededfilter']['#rows'] = 3; $form['embededfilter']['#collapsed'] = FALSE; $form['embededfilter']['#weight'] = variable_get('flashvideo_' . $node_type . '_embeded_weight', 0); $form['embededfilter']['#required'] = 0; } */ } } } /** * Implementation of hook_menu(). */ function flashvideo_menu($may_cache) { $items = array(); if ($may_cache) { $items[] = array( 'path' => 'admin/settings/flashvideo', 'title' => t('FlashVideo Settings'), 'description' => t('Administer the FlashVideo module.'), 'callback' => 'flashvideo_settings', 'access' => user_access('administer flashvideo'), 'type' => MENU_NORMAL_ITEM ); } else { $items[] = array( 'path' => 'admin/settings/flashvideo/edit', 'title' => t('Edit FlashVideo'), 'callback' => 'flashvideo_settings_main', 'access' => user_access('administer flashvideo'), 'type' => MENU_CALLBACK ); } return $items; } function flashvideo_settings() { //Must have "administer site configuration" and "administer flashvideo" privilages. if (!user_access('administer flashvideo') || !user_access('administer site configuration')) { drupal_access_denied(); } // We need to change the max upload size, and also add the extensions to the file uploads. $size = variable_get('upload_uploadsize_default', 1); $user_size = variable_get('upload_usersize_default', 1); if($size == 1) variable_set('upload_uploadsize_default', 100); if($user_size == 1) variable_set('upload_usersize_default', 1000); $extensions = variable_get('upload_extensions_default', 'jpg jpeg gif png txt html doc xls pdf ppt pps'); $new_exts = array('avi', 'mpeg', 'mpg', 'mov', 'rm', 'flv', 'wmv', '3gp', 'mp4', 'dir', 'dcr'); foreach($new_exts as $new_ext) { if(strpos($extensions, $new_ext) === FALSE) $extensions .= ' ' . $new_ext; } variable_set('upload_extensions_default', $extensions); $header = array(t('NodeType'), t('Status'), t('Operations')); // Create a list of all node types. $types = node_get_types(); foreach($types as $type) { $status = variable_get('flashvideo_'. $type->type .'_enable', 0) ? '(Enabled)' : '(Disabled)'; $rows[] = array($type->name, $status, l(t('FlashVideo Settings for this node type.'), "admin/settings/flashvideo/edit/$type->type")); } $output = _flashvideo_get_php_settings(); $output .= theme('table', $header, $rows); return $output; } function flashvideo_settings_main() { //Must have "administer site configuration" and "administer flashvideo" privilages. if (!user_access('administer flashvideo') || !user_access('administer site configuration')) { drupal_access_denied(); } $args = func_get_args(); $node_type = $args[0]; if($node_type) return drupal_get_form('flashvideo_settings_form', $node_type); } function flashvideo_settings_form($node_type) { $form['flashvideo_' . $node_type . '_enable'] = array( '#type' => 'checkbox', '#title' => t('Enable the FlashVideo for this Node Type'), '#default_value' => variable_get('flashvideo_' . $node_type . '_enable', 0), '#description' => t("Enable the FlashVideo for this Node Type.") ); /* Not quite ready yet... $form['flashvideo_' . $node_type . '_enable_embeded_filter'] = array( '#type' => 'checkbox', '#title' => t('Enable the FlashVideo Embeded Filter for this Node Type'), '#default_value' => variable_get('flashvideo_' . $node_type . '_enable_embeded_filter', 0), '#description' => t("The FlashVideo Embeded Filter is an easy way for your users to enter videos from other websites such as Google Video and YouTube. Go to the help section to find out more.") ); */ $form['flashvideo_' . $node_type . '_require'] = array( '#type' => 'checkbox', '#title' => t('Require the FlashVideo for this node type.'), '#default_value' => variable_get('flashvideo_' . $node_type . '_require', 0), '#description' => t("If checked, the video will be required to submit this node type.") ); $form['flashvideo_' . $node_type . '_change_status'] = array( '#type' => 'checkbox', '#title' => t('Change Node Status after Conversion.'), '#default_value' => variable_get('flashvideo_' . $node_type . '_change_status', 1), '#description' => t('If checked, the status for the node containing the video will be changed to "Published" after a successful video conversion.') ); $form['flashvideo_' . $node_type . '_upload_title'] = array( '#title' => t('FlashVideo Upload Title'), '#type' => 'textfield', '#default_value' => variable_get('flashvideo_' . $node_type . '_upload_title', t('Video Upload')), '#maxlength' => 128, '#description' => t('The title for the Video Upload for this node.') ); $form['flashvideo_' . $node_type . '_weight'] = array( '#title' => t('FlashVideo Upload Weight'), '#type' => 'textfield', '#default_value' => variable_get('flashvideo_' . $node_type . '_weight', -10), '#maxlength' => 10, '#description' => t('Determines how high in the submit form you would like to have the video upload. The lower the value, the higher the placement.') ); $form['flashvideo_' . $node_type . '_player_download'] = array( '#type' => 'checkbox', '#title' => t('Attach Video Player Download Link'), '#default_value' => variable_get('flashvideo_' . $node_type . '_player_download', 0), '#description' => t("Add a link to download the player at the bottom of the Video object.") ); $form['flashvideo_' . $node_type . '_attachment_links'] = array( '#type' => 'checkbox', '#title' => t('Show Videos as Attachments'), '#default_value' => variable_get('flashvideo_' . $node_type . '_attachment_links', 0), '#description' => t("Checking this box will show all videos in the attachments section of this node type.") ); $form['performance'] = array('#type' => 'fieldset', '#title' => t('Performance'), '#collapsible' => TRUE, '#collapsed' => TRUE); $form['performance']['flashvideo_' . $node_type . '_search_thumbnails'] = array( '#type' => 'checkbox', '#title' => t('Search for thumbnails in the Node Body.'), '#default_value' => variable_get('flashvideo_' . $node_type . '_search_thumbnails', 0), '#description' => t("Checking this box will allow you to have video thumbnails in the Node body, at a performance cost.") ); $form['performance']['flashvideo_' . $node_type . '_search_video'] = array( '#type' => 'checkbox', '#title' => t('Search for videos in the Node Teaser.'), '#default_value' => variable_get('flashvideo_' . $node_type . '_search_video', 0), '#description' => t("Checking this box will allow you to have video objects in the Node Teasers, at a slight performance cost.") ); $form['player'] = array('#type' => 'fieldset', '#title' => t('Flash Player Settings'), '#description' => t('Settings for the Flash Player'), '#collapsible' => TRUE, '#collapsed' => TRUE); $form['player']['flashvideo_' . $node_type . '_flash_player'] = array( '#title' => t('Flash Player Name'), '#type' => 'textfield', '#default_value' => variable_get('flashvideo_' . $node_type . '_flash_player', 'Player.swf'), '#maxlength' => 128, '#description' => t('The name of the Flash Player. Note: This player MUST reside in the output directory to work.'), '#required' => TRUE ); $form['player']['flashvideo_' . $node_type .'_player_logo'] = array( '#title' => t('Flash Player Logo'), '#type' => 'textfield', '#default_value' => variable_get('flashvideo_' . $node_type .'_player_logo', ''), '#maxlength' => 128, '#description' => t('The name of the logo file to place as a watermark in the bottom right of the Flash Player. Example: logo.png Note: This logo MUST reside in the same directory as the player.'), '#required' => FALSE ); $form['player']['flashvideo_' . $node_type .'_player_logo_link'] = array( '#title' => t('Watermark (Logo) Link'), '#type' => 'textfield', '#default_value' => variable_get('flashvideo_' . $node_type .'_player_logo_link', ''), '#maxlength' => 128, '#description' => t('The URL in which you would like your watermark (logo) to link too.'), '#required' => FALSE ); $form['player']['flashvideo_' . $node_type .'_player_intro'] = array( '#title' => t('Flash Player Intro Video'), '#type' => 'textfield', '#default_value' => variable_get('flashvideo_' . $node_type .'_player_intro', ''), '#maxlength' => 128, '#description' => t('The name of an intro video file to play at the beginning of all video files. Example: intro.flv Note: This logo MUST be a *.flv file and MUST reside in the same directory as the player.'), '#required' => FALSE ); $form['player']['flashvideo_' . $node_type .'_player_intro_image'] = array( '#title' => t('Flash Player Intro Image'), '#type' => 'textfield', '#default_value' => variable_get('flashvideo_' . $node_type .'_player_intro_image', ''), '#maxlength' => 128, '#description' => t('If your intro does not need to be a video, you can just specify an intro image here. This dramatically saves on bandwidth. Example: intro.png Note: This logo MUST reside in the same directory as the player.'), '#required' => FALSE ); $form['player']['flashvideo_' . $node_type .'_player_intro_use_thumbnail'] = array( '#type' => 'checkbox', '#title' => t('Use Thumbnail as Intro Image.'), '#default_value' => variable_get('flashvideo_' . $node_type .'_player_intro_use_thumbnail', 1), '#description' => t("Check this checkbox if you would like to use the generated thumbnail as the intro image.") ); $form['player']['flashvideo_' . $node_type .'_player_intro_image_time'] = array( '#title' => t('Intro Image Time'), '#type' => 'textfield', '#default_value' => variable_get('flashvideo_' . $node_type .'_player_intro_image_time', '3'), '#maxlength' => 128, '#description' => t('The amount of time to show the intro image in seconds.'), '#required' => FALSE ); $form['player']['flashvideo_' . $node_type . '_default_autostart'] = array( '#title' => t('Default AutoStart'), '#type' => 'select', '#options' => array('true' => 'true', 'false' => 'false'), '#default_value' => variable_get('flashvideo_' . $node_type . '_default_autostart', 'true'), '#maxlength' => 128, '#description' => t('If the player should default to play automatically or not.'), '#required' => TRUE ); $form['ffmpeg'] = array('#type' => 'fieldset', '#title' => t('FFMPEG settings'), '#collapsible' => TRUE, '#collapsed' => TRUE); $form['ffmpeg']['flashvideo_' . $node_type .'_use_ffmpeg_php'] = array( '#type' => 'checkbox', '#title' => t('Use FFMPEG-PHP to extract video information.'), '#default_value' => variable_get('flashvideo_' . $node_type .'_use_ffmpeg_php', 0), '#description' => t("Checking this box will extract the uploaded video information, but is not essential to making this module work.") ); $form['ffmpeg']['flashvideo_' . $node_type .'_ffmpeg_cmd'] = array( '#title' => t('ffmpeg Command'), '#type' => 'textfield', '#default_value' => variable_get('flashvideo_' . $node_type .'_ffmpeg_cmd', '-i @input -f flv -acodec mp3 -ar 22050 -ab 64k -ac 1 @output'), '#maxlength' => 256, '#description' => t('This is the command to give to the ffmpeg executable. Refer to the FFMPEG Online Documentation for more information.
The following parameters can be used: '), '#required' => TRUE ); $form['ffmpeg']['flashvideo_' . $node_type .'_ffmpeg_path'] = array( '#title' => t('ffmpeg Path'), '#type' => 'textfield', '#default_value' => variable_get('flashvideo_' . $node_type .'_ffmpeg_path', '/usr/bin/ffmpeg'), '#maxlength' => 128, '#description' => t('The path to the ffmpeg binary.'), '#required' => TRUE ); $form['ffmpeg']['flashvideo_' . $node_type .'_delete_original_video'] = array( '#type' => 'checkbox', '#title' => t('Delete Original Video.'), '#default_value' => variable_get('flashvideo_' . $node_type .'_delete_original_video', 0), '#description' => t("Checking this checkbox will delete the original video after conversion.") ); $form['ffmpeg']['flashvideo_' . $node_type .'_output_dir'] = array( '#title' => t('Output Directory'), '#type' => 'textfield', '#default_value' => variable_get('flashvideo_' . $node_type .'_output_dir', ''), '#maxlength' => 128, '#description' => t('The output directory to contain the thumbnail and video.'), '#required' => FALSE ); $form['ffmpeg']['flashvideo_' . $node_type .'_video_default_size'] = array( '#title' => t('Video Default Size'), '#type' => 'textfield', '#default_value' => variable_get('flashvideo_' . $node_type .'_video_default_size', '450x337'), '#maxlength' => 10, '#description' => t('The default size of the video, if none is given in the [video] tag. Width x Height. Example "450x337"'), '#required' => TRUE ); $form['ffmpeg']['flashvideo_' . $node_type .'_thumbnail_size'] = array( '#title' => t('Thumbnail Size'), '#type' => 'textfield', '#default_value' => variable_get('flashvideo_' . $node_type .'_thumbnail_size', '130x100'), '#maxlength' => 10, '#description' => t('The size of the thumnail. Width x Height. Example "130x100"'), '#required' => TRUE ); $form['ffmpeg']['flashvideo_' . $node_type .'_thumbnail_time'] = array( '#title' => t('Thumbnail Time'), '#type' => 'textfield', '#default_value' => variable_get('flashvideo_' . $node_type .'_thumbnail_time', '00:00:02'), '#maxlength' => 10, '#description' => t('The amount of time to move from the beginning of the video before taking a snapshot. Example "00:00:02" is 2 seconds.'), '#required' => TRUE ); $form['ffmpeg']['flashvideo_' . $node_type .'_thumbnail_link'] = array( '#title' => t('Make Thumbnails a Link?'), '#type' => 'select', '#options' => array('yes' => 'yes', 'no' => 'no'), '#default_value' => variable_get('flashvideo_' . $node_type . '_thumbnail_link', 'yes'), '#maxlength' => 128, '#description' => t('If yes, the thumbnails will be a link to the node that has the video.'), '#required' => TRUE ); $form['ffmpeg']['flashvideo_' . $node_type .'_max_num_failures'] = array( '#title' => t('Maximum Failures'), '#type' => 'textfield', '#default_value' => variable_get('flashvideo_' . $node_type .'_max_num_failures', 5), '#maxlength' => 10, '#description' => t('The maximum amount of conversion failures, before it reverts to using standard (non-Flash) video display. If you wish to disable the ffmpeg conversions then just enter 0.'), '#required' => TRUE ); $form['ffmpeg']['flashvideo_' . $node_type .'_log_data'] = array( '#type' => 'checkbox', '#title' => t('Log Conversion Data.'), '#default_value' => variable_get('flashvideo_' . $node_type .'_log_data', 0), '#description' => t("Logs all conversion information in the ffmpeg_data table. Good for debugging.") ); return system_settings_form($form); } /** * Pull the file extension from a filename * * @param $vidfile * string filename to get the filetype from. * * @return * string value of file type or boolean FALSE on error */ function _flashvideo_get_filetype($vidfile) { if (strstr($vidfile, '.')) { /* Normal file */ $file_type = substr($vidfile, strrpos($vidfile, '.') + 1); /* Get the extension */ if(strstr($file_type, '.') === FALSE) { /* Make sure they don't spoof the file. */ if(substr($file_type, 0, 3) == 'php') { /* Check to see if it is a PHP file (playlist) */ $file_type = substr($vidfile, strrpos($vidfile, "/") + 1); /* Get the file name */ if( strpos($file_type, 'flashvideo_playlist.php') === 0 ) { /* Make sure it is our playlist */ $file_type = 'playlist'; } else { $file_type = FALSE; /* Non-playlist PHP files */ } } } } else if (strpos($vidfile, 'google-') === 0) { /* They provided a Google Video */ $file_type = 'googlevideo'; } else if (strpos($vidfile, 'brightcove-') === 0) { $file_type = 'brightcove'; } else if (!strpos($vidfile, '.') && !strpos($vidfile, '/') && !strpos($vidfile, '\\') && strlen($vidfile) == 11) { $file_type = 'youtube'; /* They provided a YouTube video */ } else { $file_type = FALSE; } return strtolower($file_type); } /** * Returns the correct mime-type for the video. Returns false if the * mime-type cannot be detected. */ function _flashvideo_get_mime_type($filename, $extension = FALSE) { $file_type = $extension ? $filename : _flashvideo_get_filetype($filename); switch ($file_type) { case 'avi': return 'video/avi'; case 'mpeg': case 'mpg': case 'mov': return 'video/quicktime'; case 'rm': return 'application/vnd.rn-realmedia'; case 'flv': return 'flv-application/octet-stream'; case 'wmv': return 'video/x-ms-wmv'; case '3gp': return 'video/3gpp'; case 'mp4': return 'video/mp4'; case 'dir': case 'dcr': return 'application/x-director'; // We can't support this sources properly, so return false. case 'youtube': case 'googlevideo': case 'brightcove': return false; case 'ogg': return 'application/ogg'; default: // We couldn't detect the mime-type, so return false. return false; } } /** * Performs the conversion using FFMPEG. * * @param $file * File object that contains the CWD relative path, extension, etc. (CWD - Current Working Directory) * * @param $output_dir * The system output directory for this FlashVideo node type. Contains leading and trailing "/" * * @param $ffmpeg_path * The CWD relative path to the FFMPEG executable. * * @param $node_type * The node type of the node which we are converting for. * * @param $thumbsize * Object whose members are "height" and "width" for the dimensions of our thumbnail. * * @param $thumbtime * string containing the amount of time to delay before taking a snapshot. * * @return * string containing the base filename that was created. Without extension. FALSE on failure. */ function _perform_ffmpeg($file, $output_dir, $ffmpeg_path, $node_type, $thumbsize = NULL, $thumbtime = '') { $base_name = basename($file->filepath, "." . $file->extension); // Grab the base name of the file (without extension). $new_extension = $thumbsize ? ".jpg" : ".flv"; // The new extension. $output_path = getcwd() . $output_dir . $base_name . $new_extension; // Get's the relative Current Working Directory path. /* * If the video file is already an FLV extension, and this isn't the pass to create a thumbnail, then we will * just copy the video to the output path and set the status to converted. Otherwise, we will just go ahead and try and convert * the video. */ if(!$thumbsize && $file->extension == 'flv') { rename($file->filepath, $output_path); // Move the file to the output directory $new_filepath = substr($output_dir, 1) . basename($output_path); // Find the new file path for database changes. db_query("UPDATE {flashvideo} SET status=3 WHERE fid=%d", $file->fid); // Set the status to converted. db_query("UPDATE {files} SET filepath='%s' WHERE fid=%d", $new_filepath, $file->fid); // Change the filepath in the files table. return $base_name; // Return the new file name if the conversion was a success. } else if((file_exists($file->filepath) && filesize($file->filepath) > 0) && !(file_exists($output_path) && filesize($output_path) > 0)) { // Ok... LET'S DO THIS!!! db_query("UPDATE {flashvideo} SET status=1 WHERE fid=%d", $file->fid); // Status = 1 - File is converting. if($thumbsize) { // Thumbnail creation command setup. $command = "$ffmpeg_path -y -i \"{$file->filepath}\" -vframes 1 -ss $thumbtime -an -vcodec mjpeg -f rawvideo -s " . $thumbsize->width . "x" . $thumbsize->height ." \"{$output_path}\""; } else { // Video conversion command setup. $command = variable_get('flashvideo_' . $node_type .'_ffmpeg_cmd', '-i @input -f flv -acodec mp3 -ar 22050 -ab 64k -ac 1 @output'); $command = str_replace('@input', '"'. $file->filepath .'"', $command); $command = str_replace('@output', '"'. $output_path .'"', $command); $command = $ffmpeg_path . ' ' . $command; } $ffmpeg_data = shell_exec($command); // Execute the command. if(file_exists($output_path) && filesize($output_path) > 0) { // Check to make sure the new file exists. $new_filepath = substr($output_dir, 1) . basename($output_path); // Set the new file path for database insertion. $new_filename = (basename($file->filename, "." . $file->extension) . $new_extension); // Set the new file name for database insertion. $fid = db_next_id('{files}_fid'); // Find the next File ID for the files database table. // Insert the new file into the files database table. db_query("INSERT INTO {files} (fid, nid, filename, filepath, filemime, filesize) VALUES (%d, %d, '%s', '%s', '%s', %d)", $fid, $file->nid, $new_filename, $new_filepath, ($thumbsize ? 'jpg' : 'flv-application/octet-stream'), filesize($output_path)); // Grab the width, height, and video_index from the original video to copy over to the new video, then insert the new video in the flashvideo table. $params = db_fetch_object(db_query("SELECT video_index, width, height FROM {flashvideo} WHERE fid = %d", $file->fid)); db_query("INSERT INTO {flashvideo} (fid, nid, oid, status, video_index, width, height) VALUES (%d, %d, %d, 3, %d, %d, %d)", $fid, $file->nid, $file->fid, $params->video_index, $params->width, $params->height); /* * If this is not the thumbnail creation, then we will want to do some post operations on the original video. * Either delete it, or set the status to 2 (pending). This can be determined by the FlashVideo Settings. */ if(!$thumbsize) { if(variable_get('flashvideo_' . $node_type .'_delete_original_video', 0)) { // If they wish, we will delete the previous file. file_delete($file->filepath); db_query("DELETE FROM {files} WHERE fid = %d", $file->fid); db_query("DELETE FROM {flashvideo} WHERE fid=%d", $file->fid); } else { db_query("UPDATE {flashvideo} SET status=2 WHERE fid=%d", $file->fid); // Status = 2 - File is pending. } } return $base_name; // Return the new file name if the conversion was a success. } /* * The file didn't convert, so we will need to set up the database table so that it will try again with another pass. * We will also want to dump some data into the ffmpeg_data database table so that they can debug the problem at a later time. */ if(!$thumbsize) { db_query("UPDATE {flashvideo} SET status=0 WHERE fid=%d" , $file->fid); // So that it will try again later. if(variable_get('flashvideo_' . $node_type .'_log_data', 0)) { $data = "Command: $command"; $data .= "\n"; $data .= "Data: $ffmpeg_data"; db_query("INSERT INTO {ffmpeg_data} (fid, created, input_file, output_file, status, data) VALUES (%d, NOW(), '%s', '%s', %d, '%s')", $file->fid, $file->filepath, $output_path, 0, $data); } else { db_query("INSERT INTO {ffmpeg_data} (fid, created, input_file, output_file, status) VALUES (%d, NOW(), '%s', '%s', %d)", $file->fid, $file->filepath, $output_path, 0); } } } return FALSE; // The file didn't convert... :( } /** * Implementation of hook_cron */ function flashvideo_cron() { // I will use the Cron task to convert all uploaded video's to Flash file format. $types = node_get_types(); foreach($types as $type){ if(variable_get('flashvideo_' . $type->type . '_enable', 0)) { $output_dir = '/' . file_create_path(variable_get('flashvideo_' . $type->type .'_output_dir', '')) . '/'; // The output directory $max_num_failures = variable_get('flashvideo_' . $type->type .'_max_num_failures', 5); // The maximum number of conversion failures. $ffmpeg_path = variable_get('flashvideo_' . $type->type .'_ffmpeg_path', '/usr/bin/ffmpeg'); // The path to our ffmpeg executable. $size = explode('x', strtolower(variable_get('flashvideo_' . $type->type .'_thumbnail_size', '130x100'))); // The video size as "width x height" $thumbsize = (object)array('width' => $size[0], 'height' => $size[1]); // The thumbnail size as "width x height $thumbtime = variable_get('flashvideo_' . $type->type .'_thumbnail_time', '00:00:02'); // The amount of time to delay before taking a picture snapshot. // First we will want to grab all files that have not been processed yet. $files = db_query("SELECT f.* FROM {files} f LEFT JOIN {flashvideo} fv ON f.fid = fv.fid LEFT JOIN {node} n ON f.nid = n.nid WHERE ((n.type = '%s') AND (fv.status = 0) AND (n.moderate != 1))", $type->type); while($file = db_fetch_object($files)) { $failures = db_result(db_query("SELECT COUNT(*) FROM {ffmpeg_data} WHERE (fid = %d) AND (status = 0)", $file->fid)); /* * If you wish a file to not convert by uploading... You can simply put NOCONVERT anywhere in the name and the conversion * process will be skipped for that file. */ if(!strpos($file->filename, 'NOCONVERT') && ($failures < $max_num_failures) && extension_loaded("ffmpeg")) { $file->filepath = getcwd() . '/' . $file->filepath; // Normalize the filepath to the base of the system. $file->extension = _flashvideo_get_filetype($file->filepath); // Get the file extension. if(_flashvideo_get_mime_type($file->extension, TRUE)) { // Make sure it is a video file. $new_thumb_name = _perform_ffmpeg($file, $output_dir, $ffmpeg_path, $type->type, $thumbsize, $thumbtime); // Create a thumbnail of the video. if($new_file_name = _perform_ffmpeg($file, $output_dir, $ffmpeg_path, $type->type)) { // Convert the video to flash. if(variable_get('flashvideo_' . $type->type . '_change_status', 1)) { // If they opt to change the status of the node. db_query("UPDATE {node} SET status = 1 WHERE nid=%d", $file->nid); // Update the status of the node. } db_query("TRUNCATE {cache}"); // Delete the cache so that our node will update. db_query("INSERT INTO {ffmpeg_data} (fid, created, input_file, output_file, status) VALUES (%d, NOW(), '%s', '%s', %d)", $file->fid, $file->filepath, $output_path, 1); } } } else { /* * If they do not wish to use FFMPEG, they are instructed to simply set the maximum number of failures to 0. However, * we will still need to copy over the Flash file to the specified output directory, and set the status to 3 if they do this. */ if($max_num_failures == 0) { // If they set the max_num_failures to 0 (no FFMPEG) $file->filepath = getcwd() . '/' . $file->filepath; // Normalize the filepath to the base of the system. $file->extension = _flashvideo_get_filetype($file->filepath); // Get the file extension. if($file->extension == 'flv') { // Only continue if the extension is an FLV file. $base_name = basename($file->filepath, "." . $file->extension); // Grab the base name of the file (without extension). $output_path = getcwd() . $output_dir . $base_name . "." . $file->extension; // Get's the relative Current Working Directory path. rename($file->filepath, $output_path); // Move the file to the output directory $new_filepath = substr($output_dir, 1) . basename($output_path); // Find the new file path for database changes. db_query("UPDATE {flashvideo} SET status=3 WHERE fid=%d", $file->fid); // Set the status to converted. db_query("UPDATE {files} SET filepath='%s' WHERE fid=%d", $new_filepath, $file->fid); // Change the filepath in the files table. if(variable_get('flashvideo_' . $type->type . '_change_status', 1)) { // If they opt to change the status of the node. db_query("UPDATE {node} SET status = 1 WHERE nid=%d", $file->nid); // Update the status of the node. } db_query("TRUNCATE {cache}"); // Delete the cache so that our node will update. db_query("INSERT INTO {ffmpeg_data} (fid, created, input_file, output_file, status) VALUES (%d, NOW(), '%s', '%s', %d)", $file->fid, $file->filepath, $output_path, 1); } } else { /* * We are unable to convert the video... Not all is lost. We will just use the original video. * update the status of the file. */ db_query("UPDATE {flashvideo} SET status=3 WHERE fid=%d", $file->fid); } } } } } } function flashvideo_get_size($node, $file = NULL) { if($file && variable_get('flashvideo_' . $node->type .'_use_ffmpeg_php', 0)) { $extension = "ffmpeg"; $extension_soname = $extension . "." . PHP_SHLIB_SUFFIX; $extension_fullname = PHP_EXTENSION_DIR . "/" . $extension_soname; // load extension if (!extension_loaded($extension)) { dl($extension_soname); $filepath = getcwd() . '/' . $file->filepath; $movie = new ffmpeg_movie($filepath); // ffmpeg-PHP : used to get video information. } } if($file && $movie) { $width = $movie->getFrameWidth(); $height = $movie->getFrameHeight(); } else { $size = explode('x', strtolower(variable_get('flashvideo_' . $node->type .'_video_default_size', '450x337'))); // The video size as "width x height" $width = trim($size[0]); $height = trim($size[1]); } return array('width' => $width, 'height' => $height); } // Link into the operations of the upload module for file insertion and deletion. function _flashvideo_update_files($node) { $video_index = 0; if(count($node->files)) { foreach ($node->files as $file) { $file = (object)$file; if ($file->remove) { $files = db_query("SELECT * FROM {files} f LEFT JOIN {flashvideo} fv ON f.fid = fv.fid WHERE fv.oid = %d", $file->fid); db_query("DELETE FROM {flashvideo} WHERE oid = %d", $file->fid); while($oldfile = db_fetch_object($files)) { db_query("DELETE FROM {files} WHERE fid = %d", $oldfile->fid); file_delete($oldfile->filepath); } } else { $found = db_result(db_query("SELECT count(*) FROM {flashvideo} WHERE fid=%d", $file->fid)); $file->extension = _flashvideo_get_filetype($file->filepath); if(_flashvideo_get_mime_type($file->extension, TRUE)) { // Only add if the file is a video and is not already in our flashvideo table. if(!$found) { $size = flashvideo_get_size($node, $file); // Rename the original file. $filepath = substr( $file->filepath, 0, (strrpos($file->filepath, '/') + 1) ); $base_name = preg_replace("/[^a-zA-Z0-9_\.]/", "_", $node->nid . "_" . basename($file->filepath, "." . $file->extension)); $filepath .= $base_name . "." . $file->extension; if(rename( (getcwd() . '/' . $file->filepath), (getcwd() . '/' . $filepath) )) { db_query("UPDATE {files} SET filepath='%s' WHERE fid=%d", $filepath, $file->fid); } db_query("INSERT INTO {flashvideo} (fid, nid, oid, status, video_index, width, height) VALUES (%d, %d, %d, 0, %d, %d, %d)", $file->fid, $node->nid, $file->fid, $video_index, $size['width'], $size['height']); } $video_index++; } } } } } /* * For reverse compatability */ function flashvideo_get_thumb_object($node, $index) { $params['index'] = $index; return flashvideo_get_thumbnail($node, $params); } /** * Given a node variable, and index, this will return a video thumbnail. */ function flashvideo_get_thumbnail($node, $params = array(), $file_only = false) { global $base_url; $index = isset($params['index']) ? $params['index'] : 0; // Set our Video Index $nid = (isset($params['node']) && $params['node'] != 0) ? $params['node'] : $node->nid; // Set our Video Node $fids = (isset($params['fids'])) ? $params['fids'] : ''; // Set the File ID's $nid = ($nid == 'all') ? '' : $nid; // For reverse compatability $fids = ($fids == 'all') ? '' : $fids; // For reverse compatability $url = ''; $image = ''; $node_type = ($node->type) ? $node->type : db_result(db_query("SELECT * FROM {node} WHERE (nid = %d)", $nid)); $thumb_link = variable_get('flashvideo_' . $node_type . '_thumbnail_link', 'yes'); if(isset($params['id']) && $params['id'] != '') { // They provided an ID, which means they just want to show a Google or YouTube Video. switch(_flashvideo_get_filetype()) { case 'youtube': $url = 'http://img.youtube.com/vi/'. $params['id'] .'/2.jpg'; /* YouTube Thumbnail */ break; case 'google': break; default: break; } } else if($fids == '') { // They didn't provide any File ID's. We will use the node, and index to find their video. $thumb_file = db_fetch_object(db_query("SELECT f.filepath FROM {flashvideo} fv LEFT JOIN {files} f ON f.fid = fv.fid WHERE (f.nid = %d) AND (f.filemime='jpg') AND (fv.video_index=%d)", $nid, $index)); if($thumb_file) { $url = check_url(file_create_url($thumb_file->filepath)); } } else { $fids = explode("-", $fids); array_walk($fids, create_function('&$n', '$n = trim($n);')); // Trim all the elements if(count($fids) == 1) { $thumb_file = db_fetch_object(db_query("SELECT filepath FROM {files} WHERE (f.fid = %d) AND (f.filemime='jpg')", $fid)); if($thumb_file) { $url = check_url(file_create_url($thumb_file->filepath)); } } } $image = ($thumb_link == 'yes') ? '' : ''; if($url) { $image .= 'Watch this video!'; } else { $url = $base_url . '/'. drupal_get_path('module', 'flashvideo') . '/thumbnail_MIA.png'; $image .= 'Sorry...'; } $image .= ($thumb_link == 'yes') ? '' : ''; if($file_only) { return $url; } else { return $image; } } /* * For reverse compatability */ function flashvideo_get_video_object($node, $index, $params) { $params['index'] = $index; return flashvideo_get_video($node, $params); } /* * Given a node and some parameters, this will return a video object. * * @param stdObject $node * A node object. * @param array $params * An array of optional parameters: * index => Integer video index * node => stdObject video node * fids => String of File ID's to play in the format '34-21-35' * autostart => String 'true' or 'false' to automatically play the video * width => Integer video width in pixels * height => Integer video height in pixels * id => String YouTube or Google Video ID * @param boolean $file_only * Determine the type of output returned (see below). * @return String * If $file_only is TRUE, return path to video file. * If $file_only is FALSE, return HTML code. * */ function flashvideo_get_video($node, $params = array(), $file_only = false) { global $base_url; $index = isset($params['index']) ? $params['index'] : 0; // Set our Video Index $nid = (isset($params['node']) && $params['node'] && $params['node'] != 'all') ? $params['node'] : $node->nid; $fids = (isset($params['fids']) && $params['fids'] != 'all') ? $params['fids'] : ''; // Set the File ID's $video = array(); $video['nodetype'] = ($node->type) ? $node->type : db_result(db_query("SELECT * FROM {node} WHERE (nid = %d)", $nid)); $video['autostart'] = (isset($params['autostart'])) ? $params['autostart'] : variable_get('flashvideo_' . $video['nodetype'] . '_default_autostart', 'true'); $video['width'] = (isset($params['width']) && $params['width'] > 0) ? $params['width'] : ''; $video['height'] = (isset($params['height']) && $params['height'] > 0) ? $params['height'] : ''; if(isset($params['id']) && $params['id'] != '') { // They provided an ID, which means they just want to show a Google or YouTube Video. $size = flashvideo_get_size($node); $video['width'] = ($video['width'] == '') ? $size['width'] : $video['width']; $video['height'] = ($video['height'] == '') ? $size['height'] : $video['height']; $video['file'] = $params['id']; } else if($fids == '') { // They didn't provide any File ID's. We will use the node, and index to find their video. $video_file = db_fetch_object(db_query("SELECT f.filepath, fv.width, fv.height FROM {flashvideo} fv LEFT JOIN {files} f ON f.fid = fv.fid WHERE (f.nid = %d) AND ((f.filemime='flv-application/octet-stream') OR (f.filemime='application/octet-stream')) AND (fv.status=3) AND (fv.video_index=%d)", $nid, $index)); } else { $fids = explode("-", $fids); array_walk($fids, create_function('&$n', '$n = trim($n);')); // Trim all the elements if(count($fids) == 1) { $video_file = db_fetch_object(db_query("SELECT f.filepath, fv.width, fv.height FROM {flashvideo} fv LEFT JOIN {files} f ON f.fid = fv.fid WHERE (f.fid = %d) AND ((f.filemime='flv-application/octet-stream') OR (f.filemime='application/octet-stream')) AND (fv.status=3)", $fid)); } else { if(file_exists(getcwd() . '/flashvideo_playlist.php')) { $video['file'] = $base_url . '/flashvideo_playlist.php'; $video['file'] .= (count($fids) == 0) ? '' : '?fids='. implode("-", $fids); } } } if($video_file) { $video['width'] = ($video['width'] == '') ? $video_file->width : $video['width']; $video['height'] = ($video['height'] == '') ? $video_file->height : $video['height']; $video['file'] = check_url(file_create_url($video_file->filepath)); } if($video['file']) { return ($file_only ? $video['file'] : flashvideo_play($video)); } else { $url = $base_url . '/' . drupal_get_path('module', 'flashvideo') . '/video_MIA.png'; return ($file_only ? $url : 'Sorry...'); } } /** * Parses all of the tags, and places them in a parameters array. */ function _flashvideo_parse_params($body, &$pos, $max_params = 10) { if(($endpos = strpos($body, ']', $pos)) !== FALSE) { $bad_chars = array("

", "

", "
", "
", "\n", "\r", "\t", " "); $param_string = substr($body, $pos, ($endpos - $pos)); $param_string = str_replace($bad_chars, '', $param_string); // Replace all bad characters with null chars. $param_string = str_replace($bad_chars, '', $param_string); // Do it again... There is a bug where the first time doesn't get them all. $parts = explode(':', $param_string); // Create an array with all parameters. $pos = $endpos + 1; // Set the position to the end position. unset($parts[0]); // Remove the first index (it's not a parameter). $parts = array_values($parts); if((count($parts) > 0) && (count($parts) < $max_params)) { $params = array(); // Loop through all of our parameters. foreach($parts as $part) { $sub_parts = explode('=', $part); // Get the value and parameter for this part. $sub_parts[0] = strtolower($sub_parts[0]); // The parameter needs to be all lower case. if((strlen($sub_parts[0]) > 0) && (strlen($sub_parts[1]) > 0)) { $params[$sub_parts[0]] = $sub_parts[1]; } } return $params; } else { return array(); } } return array(); } /** * Search and Replace routine. Scans the body of a node and replaces every tag and its parameters with an object. */ function _flashvideo_replace_tags(&$node, $tag) { $max_num_params = 4; // The maximum number of parameters allowed. All others will be ignored. $body = ($node->body == '') ? $node->teaser : $node->body; for($pos = 0; (($pos = $startpos = strpos($body, $tag, $pos)) !== FALSE); $pos++) { // Search for tags // We need to check to see if this tag has "!" in front of it, if it does, then we will ignore this tag. if(substr($body, $pos - 1, 1) == '!') { $body = substr_replace($body, $tag, $pos - 1, strlen($tag) + 1); } else { $pos++; // So that it will skip over the "[". $params = _flashvideo_parse_params($body, $pos); // Parse all the parameters. $object = ($tag == '[thumbnail') ? flashvideo_get_thumbnail($node, $params) : flashvideo_get_video($node, $params); $body = substr_replace($body, $object, $startpos, ($pos - $startpos)); // Replace this tag. } } if($node->body == '') $node->teaser = $body; else $node->body = $body; } /** * Implementation of hook_link() */ function flashvideo_link($type, $node = NULL, $teaser = FALSE) { $links = array(); // Display a link with the number of attachments if (!variable_get('flashvideo_' . $node->type . '_attachment_links', 0) && $teaser && $type == 'node' && isset($node->files) && user_access('view uploaded files')) { $num_files = 0; if(count($node->files)) { foreach ($node->files as $file) { if (!_flashvideo_get_mime_type($file->filepath) && $file->list) { $num_files++; } } } if ($num_files) { $links['upload_attachments'] = array( 'title' => format_plural($num_files, '1 attachment', '@count attachments'), 'href' => "node/$node->nid", 'attributes' => array('title' => t('Read full article to view attachments.')), 'fragment' => 'attachments' ); } else { $links['upload_attachments'] = ''; } } return $links; } /* Find the end position of the Video ID given the Video String, * and the start position of where the ID begins. This function will either look * for an ", ', or & to find the end value. (This works for any object code, or URL.) */ function _flashvideo_get_video_endpos($string, $pos) { if(($endpos = _flashvideo_preg_strpos($string, "/[\"\'\&]/", $pos)) !== FALSE) { return $endpos; } else { return strlen($string); } } /* Given a string input containing either a Video URL, or the Video Object Code, * This function will scan that string and parse out where the video came from * and the ID for that video. This makes it so much simpler for any end user to * submit a video from an external source. */ function flashvideo_get_videoid($string) { $video = ''; if(($pos = strpos($string, 'http://www.youtube.com/v/')) !== FALSE) { $pos += strlen('http://www.youtube.com/v/'); $endpos = _flashvideo_get_video_endpos($string, $pos); $video = substr($string, $pos, ($endpos - $pos)); $video = preg_replace("[\-\W]", "", $video); // Make sure there are no scary characters. } else if(($pos = strpos($string, 'http://www.youtube.com/watch?v=')) !== FALSE) { $pos += strlen('http://www.youtube.com/watch?v='); $endpos = _flashvideo_get_video_endpos($string, $pos); $video = substr($string, $pos, ($endpos - $pos)); $video = preg_replace("[\-\W]", "", $video); // Make sure there are no scary characters. } else if(($pos = strpos($string, 'http://video.google.com/videoplay?docid=')) !== FALSE) { $pos += strlen('http://video.google.com/videoplay?docid='); $endpos = _flashvideo_get_video_endpos($string, $pos); $video = substr($string, $pos, ($endpos - $pos)); $video = preg_replace("[\-\D]", "", $video); // Google only allows number and an occasional negative sign. $video = 'google-' . $video; } else if(($pos = strpos($string, 'http://video.google.com/googleplayer.swf?docId=')) !== FALSE) { $pos += strlen('http://video.google.com/googleplayer.swf?docId='); $endpos = _flashvideo_get_video_endpos($string, $pos); $video = substr($string, $pos, ($endpos - $pos)); $video = preg_replace("[\-\D]", "", $video); // Google only allows number and an occasional negative sign. $video = 'google-' . $video; } else if(($pos = strpos($string, 'http://www.brightcove.com/title.jsp?title=')) !== FALSE) { $pos += strlen('http://www.brightcove.com/title.jsp?title='); $endpos = _flashvideo_get_video_endpos($string, $pos); $video = substr($string, $pos, ($endpos - $pos)); $video = preg_replace("[\-\D]", "", $video); // Brightcove only allows number and an occasional negative sign. $video = 'brightcove-' . $video; } else if(($pos = strpos($string, 'http://admin.brightcove.com/destination/player/player.swf')) !== FALSE) { $pos += strlen('http://admin.brightcove.com/destination/player/player.swf'); if(($pos = strpos($string, 'initVideoId=', $pos)) !== FALSE) { $pos += strlen('initVideoId='); $endpos = _flashvideo_get_video_endpos($string, $pos); $video = substr($string, $pos, ($endpos - $pos)); $video = preg_replace("[\-\D]", "", $video); // Brightcove only allows number and an occasional negative sign. $video = 'brightcove-' . $video; } } return $video; } /** * Implementation of hook_nodeapi() */ function flashvideo_nodeapi(&$node, $op, $teaser) { // Only if the node type is enabled. if(variable_get('flashvideo_' . strtolower($node->type) . '_enable', 0)) { switch ($op) { case 'insert': case 'update': _flashvideo_update_files($node); /* Not quite ready yet... // See if they provided the object code or the video URL. If so, then parse out the video ID and show that video. if(strlen($node->embededfilter) > 0) { if(($video = flashvideo_get_videoid($node->embededfilter)) !== '') { if($op == 'insert') { $size = flashvideo_get_size($node); db_query("INSERT INTO {flashvideo} (fid, nid, oid, status, video_index, width, height, video_object) VALUES (0, %d, 0, 4, 0, %d, %d, '%s')", $node->nid, $size['width'], $size['height'], $video); } else if($op == 'update') { $video_object = db_result(db_query("SELECT video_object FROM {flashvideo} WHERE nid=%d", $node->nid)); if($video_object != $node->embededfilter) { db_query("UPDATE {flashvideo} SET video_object='%s' WHERE nid=%d", $video, $node->nid); } } } } */ break; case 'load': $results = db_fetch_object(db_query("SELECT play_counter FROM {flashvideo} WHERE nid = %d", $node->nid)); $node->play_counter = $results->play_counter; break; case 'view': // If they uploaded a video, we don't want to see those video's in the attachments. if (!variable_get('flashvideo_' . $node->type . '_attachment_links', 0) && !$teaser && isset($node->files) && user_access('view uploaded files')) { $files = array(); if (count($node->files) ) { foreach ($node->files as $file) { $file = (object)$file; if(!_flashvideo_get_mime_type($file->filepath)) $files[] = $file; } } if (count($files)) { $node->content['files'] = array( '#value' => theme('upload_attachments', $files), '#weight' => 50, ); } else { $node->content['files']['#value'] = ''; } } break; case 'alter': // Here we will do a search and replace for anyone who is using the video and thumbnail tags. if(!$teaser) { db_query("UPDATE {flashvideo} SET play_counter = play_counter + 1 WHERE nid = %d", $node->nid); //Increment play counter. } if(!$teaser || variable_get('flashvideo_' . $node->type . '_search_video', 0)) _flashvideo_replace_tags($node, '[video'); if($teaser || variable_get('flashvideo_' . $node->type . '_search_thumbnails', 0)) _flashvideo_replace_tags($node, '[thumbnail'); break; case 'rss item': $filepath = db_fetch_object(db_query("SELECT f.filepath FROM {flashvideo} fv LEFT JOIN {files} f ON f.fid = fv.fid WHERE (f.nid = %d) AND (fv.status = 3) AND (fv.video_index = 0)", $node->nid)); $attributes['url'] = check_url(file_create_url($filepath)); // Only show the first video $attributes['length'] = filesize(getcwd() . '/' . $filepath); $mime_type = _flashvideo_get_mime_type($filepath->filepath); if ($mime_type) { $attributes['type'] = $mime_type; } $media['url'] = $attributes['url']; $media['fileSize'] = $attributes['length']; $media['type'] = $attributes['type']; return array(array('key' => 'enclosure', 'attributes' => $attributes), array('key' => 'media', 'value' => '', 'attributes' => $media)); case 'delete': case 'delete revision': db_query("DELETE FROM {flashvideo} WHERE nid = %d", $node->nid); if(count($node->files)){ foreach ($node->files as $file) { $file = (object)$file; db_query("DELETE FROM {ffmpeg_data} WHERE fid = %d", $file->fid); } } break; } } } /** * Generates the HTML for any object parameters in an embedded video. * * @param $video the node which is being played * * @return * string with the parameters in HTML form. */ function _flashvideo_get_parameters(&$video) { // call hook_v_get_params $param_value = module_invoke_all('v_get_params', $video); $output = ''; foreach ($param_value as $param => $value) { $output .= ''; } return $output; }