myspace thumbnail code is not working (anymore?).
here's my fix:
function _video_cck_myspace_scrape_thumbnail($video, $cached = true)
{
if (!$cached || !$cache = cache_get('myspace:thumbnail:' . $video, 'cache'))
{
$vidid = substr($video, 0, 10);
$vidlink = 'http://vids.myspace.com/index.cfm?fuseaction=vids.individual&videoid='.$vidid.'';
$str=file_get_contents($vidlink);
if ($str)
{
// $regex = '@src="((?=/' . $vidid . '_thumb1\.jpg)[^"]*)"@';
// if (preg_match($regex, $str, $matches)) {
// $thumbnail = $matches[1];
// cache_set('myspace:thumbnail:' . $video, 'cache', $thumbnail, time() + 3600);
// }print_r($regex);print_r($matches);
// grab videos channel-id first
$channelID = preg_replace('/.*tvchanid=([0-9]+);.*/si','\1',$str);
if ( is_numeric( $channelID ) )
{
// now from channel-page grab videos thumbnail
$str2 = file_get_contents("http://vids.myspace.com/index.cfm?fuseaction=vids.viewVideos&channelid=".$channelID);
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;
}
Comments
Comment #1
fjen commentedshould have mentioned that this is for "providers/myspace.inc".
Comment #2
alex ua commentedThis worked somewhat, but when I first submitted a myspace video with the code above I got the following error:
I'm guessing it's a problem with the cache_set function, but I'm not really sure, so I'm marking this as code needs work.
Also, this is a duplicate of: http://drupal.org/node/185951
Comment #3
aaron commentedComment #4
aaron commentedtweaked the patch and committed it to the devel version. works for me. reopen if you still get errors.
thanks!
aaron
Comment #5
Anonymous (not verified) commentedAutomatically closed -- issue fixed for two weeks with no activity.
Comment #6
tj2653 commentedEDIT: Just realized it is the same problem as #2 on http://drupal.org/node/165360, and confirm that it is working for me now.
Comment #7
tj2653 commented[Sorry - please delete, problem solved]