Browse Source

DailyMotion support(patch by Michel Benard)

pecesama 18 years ago
parent
commit
5f2003dc36
2 changed files with 21 additions and 3 deletions
  1. 15 1
      classes/functions.php
  2. 6 2
      classes/gelato.class.php

+ 15 - 1
classes/functions.php View File

126
 		$params = explode("?v=", $videoUrl);
126
 		$params = explode("?v=", $videoUrl);
127
 		$params2 = explode("&",$params[1]);
127
 		$params2 = explode("&",$params[1]);
128
 		return $params2[0];
128
 		return $params2[0];
129
-	}	
129
+	}
130
+	
131
+	function isDailymotionVideo($videoUrl) {
132
+		if (beginsWith($videoUrl, "http://www.dailymotion.com/video/") || beginsWith($videoUrl, "http://dailymotion.com/video/"))
133
+			return true;
134
+		else
135
+			return false;
136
+	}
137
+
138
+	function getDailymotionVideoUrl($videoUrl) {
139
+		$params = explode("video/", $videoUrl);
140
+		$params2 = explode("_",$params[1]);
141
+		return $params2[0];
142
+	}
130
 	
143
 	
131
 	function isVideo($url) {
144
 	function isVideo($url) {
132
 		if (isYoutubeVideo($url)) { return true; }
145
 		if (isYoutubeVideo($url)) { return true; }
133
 		elseif (isVimeoVideo($url)) { return true; }
146
 		elseif (isVimeoVideo($url)) { return true; }
147
+		elseif (isDailymotionVideo($url)) { return true; }
134
 		else { return false; }
148
 		else { return false; }
135
 	}
149
 	}
136
 	
150
 	

+ 6 - 2
classes/gelato.class.php View File

165
 			return "\t\t\t<object type=\"application/x-shockwave-flash\" style=\"width:500px;height:393px\" data=\"http://www.youtube.com/v/".$id_video."\"><param name=\"movie\" value=\"http://www.youtube.com/v/".$id_video."\" /></object>\n";
165
 			return "\t\t\t<object type=\"application/x-shockwave-flash\" style=\"width:500px;height:393px\" data=\"http://www.youtube.com/v/".$id_video."\"><param name=\"movie\" value=\"http://www.youtube.com/v/".$id_video."\" /></object>\n";
166
 		} elseif (isVimeoVideo($url)) {
166
 		} elseif (isVimeoVideo($url)) {
167
 			$id_video = getVimeoVideoUrl($url);
167
 			$id_video = getVimeoVideoUrl($url);
168
-			return "\t\t\t<object type=\"application/x-shockwave-flash\" style=\"width:500px;height:393px\" data=\"http://www.vimeo.com/moogaloop.swf?clip_id=".$id_video."\"><param name=\"movie\" value=\"http://www.vimeo.com/moogaloop.swf?clip_id=".$id_video."\" /></object>\n";
168
+			return "\t\t\t<object type=\"application/x-shockwave-flash\" style=\"width:500px;height:393px\" data=\"http://www.vimeo.com/moogaloop.swf?clip_id=".$id_video."\"><param name=\"movie\" value=\"http://www.vimeo.com/moogaloop.swf?clip_id=".$id_video."\" /></object>\n";}
169
+		elseif (isDailymotionVideo($url)) {
170
+			$id_video = getDailymotionVideoUrl($url);
171
+			return "\t\t\t<object type=\"application/x-shockwave-flash\" style=\"width:500px;height:393px\" data=\"http://www.dailymotion.com/swf/".$id_video."\"><param name=\"movie\" value=\"http://www.dailymotion.com/swf/".$id_video."\" /></object>\n";
172
+
169
 		} else {
173
 		} else {
170
-			return "This URL is not a supported video (YouTube or Vimeo)";
174
+			return "This URL is not a supported video (YouTube, Vimeo or DailyMotion)";
171
 		}		
175
 		}		
172
 	}
176
 	}
173
 	
177