diff --git a/wp-content/plugins/bp-dedication/includes/bp-dedication-create-dedication.php b/wp-content/plugins/bp-dedication/includes/bp-dedication-create-dedication.php
index e7d41bd..d9e1962 100644
--- a/wp-content/plugins/bp-dedication/includes/bp-dedication-create-dedication.php
+++ b/wp-content/plugins/bp-dedication/includes/bp-dedication-create-dedication.php
@@ -68,18 +68,36 @@ function bp_dedication_create_new_dedication() {
}
$videoData = array();
- $videoID = getVideoID($video_url);
-
- if (checkYoutubeId($videoID) == 1) {
- $xml = getVideoDetails($videoID);
- if ($xml->title != 'YouTube Videos') {
- $videoData['videoURL'] = $video_url;
- $videoData['title'] = $xml->title;
- $videoData['description'] = $xml->content;
- $videoData['thumbnail'] = "http://i.ytimg.com/vi/" . $videoID . "/hqdefault.jpg";
+
+ if (isYoutubeVideo($video_url)) {
+ $videoID = getYouTubeVideoID($video_url);
+
+ if (checkYoutubeId($videoID) == 1) {
+ $xml = getYouTubeVideoDetails($videoID);
+ if ($xml->title != 'YouTube Videos') {
+ $videoData['videoURL'] = $video_url;
+ $videoData['title'] = $xml->title;
+ $videoData['description'] = $xml->content;
+ $videoData['thumbnail'] = "http://i.ytimg.com/vi/" . $videoID . "/hqdefault.jpg";
+ }
}
}
+ if (isVimeoVideo($video_url)) {
+ $videoID = getVimeoVideoID($video_url);
+
+ if (checkVimeoId($videoID) == 1) {
+ $xml = getVimeoVideoDetails($videoID);
+ if ($xml) {
+ $videoData['videoURL'] = $video_url;
+ $videoData['title'] = $xml->video->title;
+ $videoData['description'] = $xml->video->description;
+ $videoData['thumbnail'] = $xml->video->thumbnail_large;
+ }
+ }
+ }
+
+
$category = get_category_by_slug(DEDICATION_CATEGORY_SLUG);
$new_post = array(
diff --git a/wp-content/plugins/bp-dedication/includes/bp-dedication-functions.php b/wp-content/plugins/bp-dedication/includes/bp-dedication-functions.php
index 79823dd..5703ebf 100644
--- a/wp-content/plugins/bp-dedication/includes/bp-dedication-functions.php
+++ b/wp-content/plugins/bp-dedication/includes/bp-dedication-functions.php
@@ -1,10 +1,32 @@
- j('#thumbs').html(j('
'));
+ processVideoURL(j('#video_url').val());
}
});
+
j('#video_url').keyup(function() { // works immediately when user press button inside of the input
if( j('#video_url').val() != j('#video_url').data('val') ){ // check if value changed
j('#video_url').data('val', j('#video_url').val() ); // save new value
@@ -129,6 +117,56 @@ jQuery(document).ready(function(){
});
+function processVideoURL(url){
+ var id;
+ var imgurl = '';
+ var j = jQuery;
+
+ if ((url.indexOf('youtube.com') > -1) || (url.indexOf('youtu.be') > -1)) {
+ imgurl = j.jYoutube(url);
+ j('#thumbs').html(j('
'));
+
+ getYouTubeInfo(j('#video_url').val(),
+ function(artist, song){
+ j('#artist_name').val(artist);
+ j('#song_name').val(song);
+
+ });
+
+ } else if (url.indexOf('vimeo.com') > -1) {
+ if (url.match(/http:\/\/(www\.)?vimeo.com\/(\d+)($|\/)/)) {
+ id = url.split('/')[3];
+ } else if (url.match(/^vimeo.com\/channels\/[\d\w]+#[0-9]+/)) {
+ id = url.split('#')[1];
+ } else if (url.match(/vimeo.com\/groups\/[\d\w]+\/videos\/[0-9]+/)) {
+ id = url.split('/')[6];
+ } else {
+ j('#thumbs').html('');
+ }
+
+ j.ajax({
+ url: 'http://vimeo.com/api/v2/video/' + id + '.json',
+ dataType: 'jsonp',
+ success: function(data) {
+ imgurl = data[0].thumbnail_medium;
+ j('#thumbs').html(j('
'));
+
+ var otitle = data[0].title;
+ var ntitle = otitle.match('^(.*) - (.*)$');
+ var song = (ntitle && (ntitle[2].length > 0 )) ? ntitle[2] : "";
+ var artist = (ntitle && (ntitle[1].length > 0 )) ? ntitle[1] : otitle;
+ j('#artist_name').val(artist);
+ j('#song_name').val(song);
+
+ }
+ });
+ } else {
+ j('#thumbs').html('');
+ }
+ return imgurl;
+}
+
+
function ia_on_autocomplete_select( value, data ) {
var j = jQuery;
var friendIDs;