一个更好的演示操作网址:http://www.hdj.me/tag/youku
http://purperwind.blog.163.com/blog/static/26960703201042593542123/
if(preg_match("/(youku.com|youtube.com|5show.com|ku6.com|sohu.com|mofile.com|sina.com.cn)$/i", $parseLink['host'], $hosts)) {
$flashvar = getflash($link, $hosts[1]);
if(!empty($flashvar)) {
$arr['title_template'] = cplang('share_video');
$type = 'video';
$arr['body_data']['flashvar'] = $flashvar;
$arr['body_data']['host'] = $hosts[1];
}
}
将上面代码用以下代码替换
if(preg_match("/(youku.com|youtube.com|5show.com|ku6.com|sohu.com|mofile.com|sina.com.cn|tudou.com)$/i", $parseLink['host'], $hosts)) {
$flashvar = getflash($link, $hosts[1]);
$flashimg = getflashimg($link, $hosts[1]);
if(!empty($flashvar)) {
$arr['title_template'] = cplang('share_video');
$type = 'video';
$arr['body_data']['flashvar'] = $flashvar;
$arr['body_data']['host'] = $hosts[1];
if(!empty($flashimg)){
$arr['image'] = $flashimg;
}
}
}
3.2再查找function getflash($link, $host)(默认在490行)
function getflash($link, $host) {
$return = '';
if('youku.com' == $host) {
// http://v.youku.com/v_show/id_XNDg1MjA0ODg=.html
preg_match_all("/id\_(\w+)[=.]/", $link, $matches);
if(!empty($matches[1][0])) {
$return = $matches[1][0];
}
} elseif('ku6.com' == $host) {
// http://v.ku6.com/show/bjbJKPEex097wVtC.html
preg_match_all("/\/([\w\-]+)\.html/", $link, $matches);
if(1 > preg_match("/\/index_([\w\-]+)\.html/", $link) && !empty($matches[1][0])) {
$return = $matches[1][0];
}
} elseif('youtube.com' == $host) {
// http://tw.youtube.com/watch?v=hwHhRcRDAN0
preg_match_all("/v\=([\w\-]+)/", $link, $matches);
if(!empty($matches[1][0])) {
$return = $matches[1][0];
}
} elseif('5show.com' == $host) {
// http://www.5show.com/show/show/160944.shtml
preg_match_all("/\/(\d+)\.shtml/", $link, $matches);
if(!empty($matches[1][0])) {
$return = $matches[1][0];
}
} elseif('mofile.com' == $host) {
// http://tv.mofile.com/PPU3NTYW/
preg_match_all("/\/(\w+)\/*$/", $link, $matches);
if(!empty($matches[1][0])) {
$return = $matches[1][0];
}
} elseif('sina.com.cn' == $host) {
// http://you.video.sina.com.cn/b/16776316-1338697621.html
preg_match_all("/\/(\d+)-(\d+)\.html/", $link, $matches);
if(!empty($matches[1][0])) {
$return = $matches[1][0];
}
} elseif('sohu.com' == $host) {
// http://v.blog.sohu.com/u/vw/1785928
preg_match_all("/\/(\d+)\/*$/", $link, $matches);
if(!empty($matches[1][0])) {
$return = $matches[1][0];
}
}
return $return;
}
将上面的代码用下面的替换
function getflash($link, $host) {
$return = '';
if('youku.com' == $host) {
// http://v.youku.com/v_show/id_XNDg1MjA0ODg=.html
preg_match_all("/id\_(\w+)[=.]/", $link, $matches);
if(!empty($matches[1][0])) {
$return = $matches[1][0];
}
} elseif('ku6.com' == $host) {
// http://v.ku6.com/show/bjbJKPEex097wVtC.html
preg_match_all("/\/([\w\-]+)\.html/", $link, $matches);
if(1 > preg_match("/\/index_([\w\-]+)\.html/", $link) && !empty($matches[1][0])) {
$return = $matches[1][0];
}
} elseif('youtube.com' == $host) {
// http://tw.youtube.com/watch?v=hwHhRcRDAN0
preg_match_all("/v\=([\w\-]+)/", $link, $matches);
if(!empty($matches[1][0])) {
$return = $matches[1][0];
}
} elseif('5show.com' == $host) {
// http://www.5show.com/show/show/160944.shtml
preg_match_all("/\/(\d+)\.shtml/", $link, $matches);
if(!empty($matches[1][0])) {
$return = $matches[1][0];
}
} elseif('mofile.com' == $host) {
// http://tv.mofile.com/PPU3NTYW/
//http://v.mofile.com/show/HLD5PLD2.shtml
preg_match_all("/\/([\w\-]+)\.shtml/", $link, $matches);
if(!empty($matches[1][0])) {
$return = $matches[1][0];
}
} elseif('sina.com.cn' == $host) {
// http://you.video.sina.com.cn/b/16776316-1338697621.html
preg_match_all("/\/(\d+)-(\d+)\.html/", $link, $matches);
if(!empty($matches[1][0])) {
$return = $matches[1][0];
}
} elseif('sohu.com' == $host) {
// http://v.blog.sohu.com/u/vw/1785928
preg_match_all("/\/(\d+)\/*$/", $link, $matches);
if(!empty($matches[1][0])) {
$return = $matches[1][0];
}
} elseif('tudou.com' == $host) {
// http://www.tudou.com/programs/view/oOrUqgezkOc/
preg_match_all("/\/([\w\-]+)\/*$/", $link, $matches);
if(!empty($matches[1][0])) {
$return = $matches[1][0];
}
}
return $return;
}
function getflashimg($link, $host) {
$return='';
$content = file_get_contents($link);//获取
if('tudou.com' == $host)
{
preg_match_all("/<span class=\"s_pic\">(.*?)<\/span>/i",$content,$img);
}
elseif('youku.com' == $host)
{
preg_match_all("/\+0800\|(.*?)\|\">/i",$content,$img);
//$img = $img[1][0];
}
elseif('ku6.com' == $host)
{
preg_match_all("/<span class=\"s_pic\">(.*?)<\/span>/i",$content,$img);
}
elseif('mofile.com' == $host)
{
preg_match_all("/thumbpath=\"(.*?)\";/i",$content,$img);
}
$img = $img[1][0];
if($img){
$return = $img;
}
return $return;
}
3.3
打开script_common.js(默认在342行)
在'mofile.com' : 'http://tv.mofile.com/cn/xplayer.swf?v=FLASHVAR',下面添加下面的代码(支持土豆)
'tudou.com' : 'http://www.tudou.com/v/FLASHVAR',
3.4
再查找hideObj.style.cursor = 'pointer';
在其下面加入下面代码:
//add
if('music' != host&&'flash' != host){
$('icon_id_'+shareid).style.display='none';
$('media_id_'+shareid).style.display='none';
}
//end
3.5
查找obj.style.display = '';(有两处,在第一处下面)
在其下面添加代码:
//add
if('music' != host&&'flash' != host){
$('icon_id_'+shareid).style.display='';
$('media_id_'+shareid).style.display='';
}
//end
3.6
打开space_feed_li.htm
查找:
<!--{if $value['image_1']}-->
修改为:
<!--{if $value['image_1'] && empty($value['body_data']['flashvar'])}-->
查找:(在47行)
<div class="media">
<img src="image/vd.gif" alt="点击播放" οnclick="javascript:showFlash('{$value['body_data']['host']}', '{$value['body_data']['flashvar']}', this, '{$value['feedid']}');" style="cursor:pointer;" />
</div>
修改为:
<div class="media">
<div class="movie_app">
<img id=icon_id_$value[feedid] class=movie_icon alt="点击播放" src="image/movie_icon.png" alt="点击播放" οnclick="javascript:showFlash('{$value['body_data']['host']}', '{$value['body_data']['flashvar']}', this, '{$value['feedid']}');" style="cursor:pointer;" />
<img id="media_id_$value[feedid]" class=movie_pic src="<!--{if !empty($value['image_1'])}-->$value[image_1]<!--{else}-->/image/noimg.gif<!--{/if}-->" alt="点击播放" οnclick="javascript:showFlash('{$value['body_data']['host']}', '{$value['body_data']['flashvar']}', this, '{$value['feedid']}');" style="cursor:pointer;" />
</div>
</div>
3.7
打开space_share_li.htm
查找:(默认15行附近)
<!--{if $value['image']}-->
修改为:
<!--{if $value['image'] && 'video'!=$value['type']}-->
查找:(默认22行附近)
<!--{if 'video' == $value['type']}-->
<div class="media">
<img src="image/vd.gif" alt="点击播放" οnclick="javascript:showFlash('{$value['body_data']['host']}', '{$value['body_data']['flashvar']}', this, '{$value['sid']}');" style="cursor:pointer;" />
</div>
修改为:
<!--{if 'video' == $value['type']}-->
<div class="media">
<div class="movie_app">
<img id=icon_id_$value[sid] class=movie_icon alt="点击播放" src="image/movie_icon.png" alt="点击播放" οnclick="javascript:showFlash('{$value['body_data']['host']}', '{$value['body_data']['flashvar']}', this, '{$value['sid']}');" style="cursor:pointer;">
<img id="media_id_$value[sid]" class=movie_pic src="<!--{if !empty($value['image'])}-->$value[image]<!--{else}-->/image/noimg.gif<!--{/if}-->" alt="点击播放" οnclick="javascript:showFlash('{$value['body_data']['host']}', '{$value['body_data']['flashvar']}', this, '{$value['sid']}');" style="cursor:pointer;" />
</div>
</div>
3.8
打开default/style.css(缩略图上显示播放按钮需要修改此文件)
在文件末尾加上下面的代码:
/**********************************************Vedio_img***/
.movie_none{display:none;position:relative}
.movie_app .movie_pic{width:128px;height:96px;}
* html .movie_pic{width: expression(this.width > 120 ? 120 : true); display:block}
.media{display:block;POSITION: relative;zoom:1}
.movie_app{}
.movie_app img {margin-left:5px;margin-top:5px; max-width: 130px; max-height: 96px;}
* html .movie_app img { width: expression(this.width > 200 && this.width/this.height > 2 ? 200 : true); height: expression(this.height > 100 && this.width/this.height < 2 ? 200 : true); display:block}
.movie_app .movie_icon {
width:21px;height:21px;BACKGROUND: none transparent scroll repeat 0% 0%; FILTER: alpha(opacity=70); left: 55px; BORDER-TOP-STYLE: none! important; BOTTOM: 35px; BORDER-RIGHT-STYLE: none! important; BORDER-LEFT-STYLE: none! important; POSITION: absolute; BORDER-BOTTOM-STYLE: none! important; opacity: 0.9
}