--- video.module.drupal5 2007-06-27 20:24:06.000000000 +0000 +++ video.module 2007-06-27 23:59:43.000000000 +0000 @@ -663,10 +674,11 @@ } //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.')); + if ((!isset($node->size) || !is_numeric($node->size) || $node->size < 0) && !$node->video_upload_file_path) { //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.')); + //print_r($node); } - + //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) { --- plugins/video_upload/video_upload.module.drupal5 2007-06-27 20:27:38.000000000 +0000 +++ plugins/video_upload/video_upload.module 2007-06-27 23:42:33.000000000 +0000 @@ -88,27 +88,18 @@ } 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); + _video_upload_insert($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); + _video_upload_insert($node); break; case 'delete': @@ -191,59 +182,32 @@ } } - -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']); - } - - +function _video_upload_insert(&$node) { 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']; + $node->video_upload_file_path = $node->video_upload_file->filepath; + $file = new stdClass(); + $file->filepath = $node->video_upload_file_path; + $file->filename = basename($file->filepath); + $file->filesize = filesize($file->filepath); + $file->vidfile = $file->filepath; + $file->filemime = _video_get_mime_type($file); + $node->video_upload_file = $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']); + $node->video_upload_file_stored = $file; } else { drupal_set_message(t('An error occurred during file saving. Your video file has not been stored.'), 'error'); } - } + } else { + drupal_set_message("not file " . $node->video_upload_file_path); + } } @@ -264,7 +228,7 @@ /** * Create video upload specific form fields */ -function _video_upload_form($node) { +function _video_upload_form(&$node) { _video_upload_check_settings(); $form = array(); @@ -277,14 +241,24 @@ '#description' => t('The uploaded file will be used as video file for this node.
NOTE: 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'); + $form['video_upload_file_info']['#after_build'][] = 'video_upload_add_info'; + if ($node->new_vidfile) { + $form['video_upload_file_path'] = array('#type' => 'hidden', '#value' => $node->video_upload_file->filepath); + } + else { + $form['video_upload_file_path'] = array('#type' => 'hidden', '#default_value' => $node->video_upload_file->filepath); } return $form; } - + +function video_upload_add_info($form_id, $edit) { + if ($edit['video_upload_file_path']) { + $node = (object)($edit); + $form = array('#type' => 'item', '#title' => t('Video information:'), '#value' => theme('video_upload_file_info_form', $node), '#weight' => -10); + } + return $form; +} /** * Display informations about already uploaded file --- plugins/video_ffmpeg_helper/video_ffmpeg_helper.module.drupal5 2007-06-28 00:01:45.000000000 +0000 +++ plugins/video_ffmpeg_helper/video_ffmpeg_helper.module 2007-06-27 23:56:45.000000000 +0000 @@ -282,7 +291,17 @@ * Add a video conversion rendering process to the queue */ function _video_ffmpeg_helper_add_rendering(&$node) { - $file = $_SESSION['video_upload_file_stored']->filepath; + if (_video_get_filetype($node->vidfile) == 'youtube' or _video_get_filetype($node->vidfile) == 'googlevideo') { + return; + } + //print_r($node); + $file = $node->video_upload_file_path; + if (!$file) { + drupal_set_message(t('not converting remote file @file', array('@file' => $file . ":" .$node->vidfile))); + return; + } else { + drupal_set_message(t('received file @file, will be converted shortly', array('@file' => $file))); + } //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); @@ -300,7 +319,8 @@ function _video_ffmpeg_helper_get_video_info(&$node) { // escape file name for safety - $file = escapeshellarg($_SESSION['video_upload_file']->filepath); + $file = escapeshellarg($node->video_upload_file_path); + // create the full command to execute $command = variable_get('video_ffmpeg_helper_ffmpeg_path', '/usr/bin/ffmpeg') . ' -i ' . $file; @@ -361,18 +382,12 @@ * a drupal file object */ function _video_ffmpeg_helper_auto_thumbnail(&$node) { - if(empty($_SESSION['video_upload_file']) || - !$_SESSION['video_upload_file']->newfile || - $node->iid || $_SESSION['video_upload_file']->iid || - $_SESSION['video_upload_file']->thumbnailed) { - if (variable_get('video_image_auto_thumbnail_debug', false)) { - if (empty($_SESSION['video_upload_file'])) - drupal_set_message(t('no video has been uploaded: make sure that video_image weight is greater than video_upload weight; make sure that the video file is not too large to be uploaded.')); - } + if(empty($node->video_upload_file)) { + drupal_set_message(t('no video has been uploaded: make sure that video_image weight is greater than video_upload weight; make sure that the video file is not too large to be uploaded.')); return null; } $debug = variable_get('video_image_auto_thumbnail_debug', false); - $videofile = escapeshellarg($_SESSION['video_upload_file']->filepath); + $videofile = escapeshellarg($node->video_upload_file_path); $thumbfile = tempnam(file_directory_temp(), 'tnail-thumb'); $seek = variable_get('video_image_auto_thumbnail_seek', 2); $tnail = variable_get('video_ffmpeg_helper_ffmpeg_path', '/usr/bin/ffmpeg'); @@ -392,13 +407,13 @@ drupal_set_message(t('video_image_auto_thumbnail: file %file does not exist', array('%file' => $thumbfile)), 'error'); } $file = array( - 'filename' => $_SESSION['video_upload_file']->filename . ".video-thumb.jpg", + 'filename' => basename($node->video_upload_file_path) . ".video-thumb.jpg", 'filemime' => 'image/jpeg', 'filesize' => filesize($thumbfile), 'filepath' => $thumbfile, 'nid' => $node->nid, ); - $_SESSION['video_upload_file']->thumbnailed = TRUE; + $node->thumbnailed = TRUE; if ($debug) { if ($tnail_return) { drupal_set_message(t('Failed to thumbnail video'));