You are here

function emvideo_lastfm_extract in Embedded Media Field 6.3

Same name and namespace in other branches
  1. 6 contrib/emvideo/providers/lastfm.inc \emvideo_lastfm_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/lastfm.inc, line 55
Provide support for Last.fm to the emfield.module.

Code

function emvideo_lastfm_extract($embed = '') {

  // http://www.last.fm/music/The+Shins/+videos/2794412
  // <object width="340" height="289" id="player" classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,0,0" align="middle"> <param name="movie" value="http://cdn.last.fm/videoplayer/33/VideoPlayer.swf" /> <param name="menu" value="false" /> <param name="quality" value="high" /> <param name="bgcolor" value="#000000" /> <param name="allowFullScreen" value="true" /> <param name="flashvars" value="embed=true&creator=The+Shins&title=Phantom+Limb&uniqueName=2794412&albumArt=http://cdn.last.fm/coverart/130x130/3243014.jpg&album=Wincing+the+Night+Away&duration=&image=http://userserve-ak.last.fm/serve/image:320/2794412.jpg&FSSupport=true" /> <embed src="http://cdn.last.fm/videoplayer/33/VideoPlayer.swf" menu="false" quality="high" bgcolor="#000000" width="340" height="289" name="player" align="middle" allowFullScreen="true" flashvars="embed=true&creator=The+Shins&title=Phantom+Limb&uniqueName=2794412&albumArt=http://cdn.last.fm/coverart/130x130/3243014.jpg&album=Wincing+the+Night+Away&duration=&image=http://userserve-ak.last.fm/serve/image:320/2794412.jpg&FSSupport=true" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" /> </object>
  // thumb:
  // http://userserve-ak.last.fm/serve/image:160/2794412.jpg
  // src="http://www.lastfm.com/v/nvbQQnvxXDk"
  // http://lastfm.com/watch?v=nvbQQnvxXDk
  // http://www.lastfm.com/watch?v=YzFCA-xUc8w&feature=dir
  if (preg_match('@cdn.last.fm@i', $embed, $matches)) {
    if (preg_match('@uniqueName=([0-9]+)@i', $embed, $matches)) {
      return $matches[1];
    }
  }
  else {
    if (preg_match('@last\\.fm@i', $embed, $matches)) {
      if (preg_match('@([0-9]+)@i', $embed, $matches)) {
        return $matches[1];
      }
    }
  }
  return array();
}