You are here

public function Media23VideoInternetHandler::parse in Media 23video 7

Check if a 23Video video ID valid.

Parameters

string $embed_code: 23Video embed code.

Return value

string 23video stream wrapper URI.

2 calls to Media23VideoInternetHandler::parse()
Media23VideoInternetHandler::claim in includes/Media23VideoInternetHandler.inc
Determines if this handler should claim the item.
Media23VideoInternetHandler::getFileObject in includes/Media23VideoInternetHandler.inc
Returns a file object which can be used for validation.

File

includes/Media23VideoInternetHandler.inc, line 25
Definition of Media23VideoInternetHandler object.

Class

Media23VideoInternetHandler
Class Media23VideoInternetHandler.

Code

public function parse($embed_code) {
  if (!empty(self::$processedEmbedCodes[$embed_code][__FUNCTION__])) {
    return self::$processedEmbedCodes[$embed_code][__FUNCTION__];
  }
  $embed_code = rawurldecode($embed_code);
  if (preg_match('/src="([^"]+)/i', $embed_code, $matches)) {
    $url_parts = parse_url($matches[1]);
    if (isset($url_parts['query'])) {
      parse_str($url_parts['query'], $query);
      if (isset($query['photo_id'])) {
        $this->embedCode = $url_parts['scheme'] . '://' . $url_parts['host'] . '/video/' . $query['photo_id'];
      }
    }
  }
  $info = $this
    ->getOEmbed();
  if (!empty($info['provider_url']) && !empty($info['photo_id']) && 'video' == $info['type']) {
    return self::$processedEmbedCodes[$embed_code][__FUNCTION__] = file_stream_wrapper_uri_normalize(MEDIA_23VIDEO_SERVICE . '://v/' . $info['photo_id'] . '/s/' . parse_url($info['provider_url'], PHP_URL_HOST));
  }
  return FALSE;
}