function emvideo_dailymotion_extract in Embedded Media Field 6
Same name and namespace in other branches
- 6.3 contrib/emvideo/providers/dailymotion.inc \emvideo_dailymotion_extract()
hook emvideo_PROVIDER_extract this is called to extract the video code from a pasted URL or embed code.
Parameters
$embed: an optional string with the pasted URL or embed code
Return value
either an array of regex expressions to be tested, or a string with the video code to be used if the hook tests the code itself, it should return either the string of the video code (if matched), or an empty array. otherwise, the calling function will handle testing the embed code against each regex string in the returned array.
File
- contrib/
emvideo/ providers/ dailymotion.inc, line 57 - This include processes dailymotion media files for use by emfield.module.
Code
function emvideo_dailymotion_extract($embed = '') {
// http://www.dailymotion.com/us/cluster/news/featured/video/x3xk8v_primary-smackdown-obama-girl-return_fun
// http://www.dailymotion.com/barelypolitical/video/x3xk8v_primary-smackdown-obama-girl-return_fun
// http://www.dailymotion.com/barelypolitical/video/x3xk8v
// <div><object width="420" height="252"><param name="movie" value="http://www.dailymotion.com/swf/x3xk8v" /></param><param name="allowFullScreen" value="true"></param><param name="allowScriptAccess" value="always"></param><embed src="http://www.dailymotion.com/swf/x3xk8v" type="application/x-shockwave-flash" width="420" height="252" allowFullScreen="true" allowScriptAccess="always"></embed></object><br /><b><a href="http://www.dailymotion.com/video/x3xk8v_primary-smackdown-obama-girl-return_fun">Primary Smackdown: Obama Girl Returns</a></b><br /><i>Uploaded by <a href="http://www.dailymotion.com/BarelyPolitical">BarelyPolitical</a></i></div>
// <div><object width="420" height="252"><param name="movie" value="http://www.dailymotion.com/swf/x3xk8v"></param><param name="allowFullScreen" value="true"></param><param name="allowScriptAccess" value="always"></param><embed src="http://www.dailymotion.com/swf/x3xk8v" type="application/x-shockwave-flash" width="420" height="252" allowFullScreen="true" allowScriptAccess="always"></embed></object><br /><b><a href="http://www.dailymotion.com/video/x3xk8v_primary-smackdown-obama-girl-return_fun">Primary Smackdown: Obama Girl Returns</a></b><br /><i>Uploaded by <a href="http://www.dailymotion.com/BarelyPolitical">BarelyPolitical</a></i></div>
// if (preg_match('@dailymotion\.com@i', $embed, $matches)) {
// if (preg_match('@/([^/_]+)_@i', $embed, $matches)) {
// return $matches[0];
// }
// }
if (preg_match('@dailymotion\\.com/swf/([^"\\&]+)@i', $embed, $matches)) {
return $matches[1];
}
if (preg_match('@dailymotion\\.com@i', $embed, $matches)) {
if (preg_match('@/([^/_]+)_@i', $embed, $matches)) {
return $matches[1];
}
}
return array();
}