View source
<?php
define('VIDEO_CCK_MYSPACE_MAIN_URL', 'http://vids.myspace.com/index.cfm?fuseaction=vids.videos');
function video_cck_myspace_info() {
$name = t('MySpace');
$features = array(
array(
t('Autoplay'),
t('No'),
'',
),
array(
t('RSS Attachment'),
t('No'),
'',
),
array(
t('Thumbnails'),
t('Yes'),
'',
),
);
return array(
'provider' => 'myspace',
'name' => $name,
'url' => VIDEO_CCK_MYSPACE_MAIN_URL,
'settings_description' => t('These settings specifically affect videos displayed from !provider.', array(
'!provider' => l($name, VIDEO_CCK_MYSPACE_MAIN_URL, array(
'target' => '_blank',
)),
)),
'supported_features' => $features,
);
}
function video_cck_myspace_settings() {
$form = array();
return $form;
}
function video_cck_myspace_request($code, $cacheable = TRUE) {
$args = array();
return module_invoke('emfield', 'request_xml', 'myspace', "http://vids.myspace.com/index.cfm?fuseaction=vids.individual&videoid={$code}", $args, $cacheable);
}
function _video_cck_myspace_scrape_thumbnail($video, $cached = true) {
if (!$cached || !($cache = cache_get('myspace:thumbnail:' . $video, 'cache'))) {
$vidid = substr($video, 0, 10);
if ($str = file_get_contents("http://vids.myspace.com/index.cfm?fuseaction=vids.individual&videoid={$vidid}")) {
$channel_id = preg_replace('/.*tvchanid=([0-9]+);.*/si', '\\1', $str);
if (is_numeric($channel_id)) {
$str2 = file_get_contents("http://vids.myspace.com/index.cfm?fuseaction=vids.viewVideos&channelid={$channel_id}");
if ($str2) {
$picturelink = preg_replace('@.*href="[^"]+' . $vidid . '"[^>]+><img[^>]+src="([^"]+)".*@si', '\\1', $str2);
if ($picturelink) {
$thumbnail = $picturelink;
cache_set('myspace:thumbnail:' . $video, 'cache', $thumbnail, time() + 3600);
}
}
}
}
}
else {
$thumbnail = $cache->data;
}
return $thumbnail;
}
function video_cck_myspace_extract($embed) {
return array(
'@src="myspace\\.com/index.cfm\\?fuseaction=vids\\.individual&videoid=([^&"]+)@i',
'@myspace\\.com/index\\.cfm\\?fuseaction=vids\\.individual&videoid=([^&"]+)@i',
'@src="myspacetv\\.com/index.cfm\\?fuseaction=vids\\.individual&videoid=([^&"]+)"@i',
'@myspacetv\\.com/index\\.cfm\\?fuseaction=vids\\.individual&videoid=([^&"]+)@i',
);
}
function video_cck_myspace_video_link($video_code) {
return 'http://vids.myspace.com/index.cfm?fuseaction=vids.individual&videoid=' . $video_code;
}
function theme_video_cck_myspace_flash($embed, $width, $height) {
static $count = 0;
if ($embed) {
$embed = check_plain($embed);
$width = (int) $width;
$height = (int) $height;
$output .= '<object height="' . $height . 'px" width="' . $width . 'px" >
<param name="allowFullScreen" value="true"/>
<param name="wmode" value="transparent"/>
<param name="movie" value="http://mediaservices.myspace.com/services/media/embed.aspx/m=' . $embed . ',t=1,mt=video" />
<embed src="http://mediaservices.myspace.com/services/media/embed.aspx/m=' . $embed . ',t=1,mt=video" width="' . $width . '" height="' . $height . '" allowFullScreen="true" type="application/x-shockwave-flash" wmode="transparent"></embed></object>';
}
$count++;
return $output;
}
function video_cck_myspace_thumbnail($field, $item, $formatter, $node, $width, $height) {
return _video_cck_myspace_scrape_thumbnail($item['value']);
}
function video_cck_myspace_video($embed, $width, $height, $field, $item) {
$output = theme('video_cck_myspace_flash', $embed, $width, $height);
return $output;
}
function video_cck_myspace_preview($embed, $width, $height, $field, $item) {
$output = theme('video_cck_myspace_flash', $embed, $width, $height);
return $output;
}