You are here

function video_cck_livestream_extract in Embedded Media Field 5

hook video_cck_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/video_cck/providers/livestream.inc, line 203
This include processes livestream.com media files for use by emfield.module.

Code

function video_cck_livestream_extract($embed = '') {

  // http://channel.api.livestream.com/1.0/embed?channel=whatstrending
  // http://www.livestream.com/whatstrending
  // http://www.livestream.com/whatstrending/video?clipId=flv_083673e4-c87b-4af1-9553-c5057495d111&time=0
  // <iframe width="560" height="340" src="http://cdn.livestream.com/embed/whatstrending?layout=4&amp;clip=flv_083673e4-c87b-4af1-9553-c5057495d111&amp;autoplay=false" style="border:0;outline:0" frameborder="0" scrolling="no"></iframe><div style="font-size: 11px;padding-top:10px;text-align:center;width:560px">Watch <a href="http://www.livestream.com/?utm_source=lsplayer&amp;utm_medium=embed&amp;utm_campaign=footerlinks" title="live streaming video">live streaming video</a> from <a href="http://www.livestream.com/whatstrending?utm_source=lsplayer&amp;utm_medium=embed&amp;utm_campaign=footerlinks" title="Watch whatstrending at livestream.com">whatstrending</a> at livestream.com</div>
  // <iframe width="560" height="340" src="http://cdn.livestream.com/embed/whatstrending?layout=4&amp;autoplay=false" style="border:0;outline:0" frameborder="0" scrolling="no"></iframe><div style="font-size: 11px;padding-top:10px;text-align:center;width:560px">Watch <a href="http://www.livestream.com/?utm_source=lsplayer&amp;utm_medium=embed&amp;utm_campaign=footerlinks" title="live streaming video">live streaming video</a> from <a href="http://www.livestream.com/whatstrending?utm_source=lsplayer&amp;utm_medium=embed&amp;utm_campaign=footerlinks" title="Watch whatstrending at livestream.com">whatstrending</a> at livestream.com</div>
  if (preg_match('@livestream\\.com/1.0/embed\\?channel=([^"\\& ]+)@i', $embed, $matches)) {
    return $matches[1];
  }
  if (preg_match('@livestream\\.com/(embed/)?([^/\\? ]+).*?((clipId|clip)=([^\\&\'" ]+))@i', $embed, $matches)) {
    return $matches[2] . '?clip=' . $matches[5];
  }
  else {
    if (preg_match('@livestream\\.com/(embed/)?([^/\\? ]+)@i', $embed, $matches)) {
      return $matches[2];
    }
  }
}