/** * Function to process youtube videos * * @return void * @author Praveen Rajan */ function process_youtube_videos($galleryID, $videolist) { global $wpdb; $cool_video_gallery = new CoolVideoGallery(); $video_ids = array(); if (is_array($videolist)) { foreach ($videolist as $video) { $youtube_api = new CVGYoutubeAPI(); $video_details = $youtube_api->youtube_video_details($video); if ($video_details == "false") { CvgCore::show_video_error(__('SimpleXML PHP extension not loaded!')); return; } $alttext = $wpdb->escape($video_details->title); $time_updated = current_time('mysql', 1); $thumb_filename = $video_details->thumbnailURL; $videoDuration = CvgCore::secondsToWords((int) $video_details->length); $meta = array('videoDuration' => $videoDuration); // save it to the database $result = $wpdb->query($wpdb->prepare("INSERT INTO " . $wpdb->prefix . "cvg_videos (galleryid, filename, thumb_filename, alttext, description, video_title, videodate, video_type, meta_data) VALUES (%s, %s, %s, %s, %s, %s, %s, %s, %s)", $galleryID, $video_details->watchURL, $thumb_filename, $alttext, $wpdb->escape($video_details->description), $video_details->title, $time_updated, $cool_video_gallery->video_type_youtube, serialize($meta))); $vid_id = (int) $wpdb->insert_id; if ($result) { $video_ids[] = $vid_id; } } } // is_array return $video_ids; }