/** * Function to scan gallery folder for new videos * @param $galleryID - gallery id * @author Praveen Rajan */ function scan_upload_videos($galleryID) { global $wpdb; $gallery = videoDB::find_gallery($galleryID); $dirlist = CvgCore::scandir_video($gallery->abspath); $videolist = array(); foreach ($dirlist as $video) { $video_newname = sanitize_file_name($video); $video_found = $wpdb->get_var("SELECT filename FROM " . $wpdb->prefix . "cvg_videos WHERE filename = '{$video_newname}' AND galleryid = '{$galleryID}'"); if (!$video_found) { @rename($gallery->abspath . '/' . $video, $gallery->abspath . '/' . $video_newname); $videolist[] = $video_newname; } } // add videos to database $videos_ids = CvgCore::add_Videos($galleryID, $videolist); if (CvgCore::ffmpegcommandExists("ffmpeg")) { foreach ($videos_ids as $video_id) { CvgCore::create_thumbnail_video($video_id); } } if (count($videos_ids) > 0) { CvgCore::show_video_message(count($videos_ids) . __(' Video(s) successfully added.')); } else { CvgCore::show_video_error(__(' No new video(s) found.')); } }