需要截图类似qq 空间 那样的 图片 作为视频显示,点击以后再做处理插入flash播放器
最新可用获得 土豆 酷6 youku 视频网站相关视频截图的PHP 代码,10-05-21日测试通过
$link = ‘http://v.youku.com/v_show/id_XMTczMDk5Nzcy.html’;
$host = ‘youku.com’;
$link =”http://v.ku6.com/show/UGLUGb7WYGokx2KU.html“;
$host = ‘ku6.com’;
$link =”http://www.tudou.com/playlist/playindex.do?lid=8615533&iid=51711411&cid=22“;
$host =”tudou.com”;
var_dump( getVideoInfo($link, $host));
$returninfo=getVideoInfo($link, $host);
$img=$returninfo[‘imageurl’];
echo $img;
function getVideoInfo($link, $host) {
$return = array();
if(‘youku.com’ == $host) {
//分析视频网址,获取视频编码号
preg_match_all(“/id\_(\w+)[\=|.html]/”, $link, $matches);
if(!empty($matches[1][0])) {
$return[‘flashvar’] = $matches[1][0];
}
//获取视频页面内容,存与$text中
$text=file_get_contents($link);
//获取视频标题
preg_match(“/
(.*?) – (.*)/”, $text, $title);//获取优酷网上某一视频对应的视频截图,经分析,视频的截图的图片地址在该视频页面html代码里以
标记里的最后一个http://vimg….//例如http://vimg20.yoqoo.com/0100641F4649B9D27344B00131FBB6AFDF5175-7D35-930B-E43C-99C59F918E00
preg_match_all(“/
/”,$text,$match2);preg_match(“/http:\/\/(.*)ykimg.com(.*)\|\”\>/”,$match2[1][0],$imageurl);
/**
var_dump($imageurl);
$html = ob_get_contents(); //读取缓冲区数据
wlog($html);
echo “
”;
*/
if (!empty($imageurl[1])) {
$return[‘imageurl’] = ‘http://g1.ykimg.com’.$imageurl[2];
}
if (!empty($title)) {
$return[‘title’] = $title[1];
}
} elseif(‘ku6.com’ == $host) {
// http://v.ku6.com/show/bjbJKPEex097wVtC.html
// http://v.ku6.com/special/index_3628020.html
//对于酷6网,末尾以index_开头的地址需要另外分析其视频编码
$text=file_get_contents($link);
preg_match_all(“/\/([\w\-]+)\.html/”, $link, $matches);
if(1 > preg_match(“/\/index_([\w\-]+)\.html/”, $link) && !empty($matches[1][0])) {
$return[‘flashvar’] = $matches[1][0];
}else{
preg_match_all(“/refer\/(.*)\/v.swf/”,$text,$videourl);
$return[‘flashvar’] = $videourl[1][0];
}
preg_match(“/
(.*?) – (.*)/”, $text, $title);//经分析,酷六的视频截图地址在视频页面的(.*)/”,$text,$imageurl);
if (!empty($imageurl[1][0])) {
$return[‘imageurl’] = $imageurl[1][0];
}
if (!empty($title)) {
$return[‘title’] = $title[1];
}
}elseif (‘tudou.com’ == $host){
//http://www.tudou.com/programs/view/_ke1lzCnBYw/
$tudou = file_get_contents($link);
preg_match_all(“/view\/([\w\-]+)\//”, $link, $matches);
if(!empty($matches[1][0])) {
$return[‘flashvar’] = $matches[1][0];
}
preg_match(“/
(.*?) – (.*)/”, $tudou, $title);preg_match_all(“/(.*)/”,$tudou,$imageurl);
if (!empty($imageurl[1][0])) {
$return[‘imageurl’] = $imageurl[1][0];
}
if (!empty($title)) {
$return[‘title’] = $title[1];
}
}
return $return;
}