Discuz!官方免费开源建站系统

 找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索

重磅推出,分享视频增加缩略图(免费)

  [复制链接]
dudupi 发表于 2009-9-30 11:17:37 | 显示全部楼层 |阅读模式
UCHome插件
语言编码: GBK简体 
插件名称: 分享视频增加缩略图
插件作者: 俺dudupi
适用版本: UCHome 2.0
本帖最后由 dudupi 于 2009-10-4 13:22 编辑

本人发就发功能强的,免费发,不要钱
官方没有这个功能,大站都有,kaixin001也加了这个功能,个人觉得非常有必要,经过长时间摸索,找到了方法,目前可支持youku,tudou,ku6,mofile视频网站,以下分享方法。
此方法需要空间支持file_get_contents函数。当然也可能有更好的方法(如从视频中获取帧),但对空间要求更大啊。
忘记截图了,补上:

以下是修改方法(特别说明,修改前做好备份):
修改cp_share.php 408行起以下内容
   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;
     }
    }
   }
找到这个函数:
function getflash($link, $host) {
$return = '';
if('youku.com' == $host) {
  // http://v.youku.com/v_show/id_XNDg1MjA0ODg=.html]http://v.youku.com/v_show/id_XNDg1MjA0ODg=.html[/url]
  preg_match_all("/id\_(\w+)[=.]/", $link, $matches);
  if(!empty($matches[1][0])) {
   $return = $matches[1][0];
  }
} elseif('ku6.com' == $host) {
  // [url=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]http://v.youku.com/v_show/id_XNDg1MjA0ODg=.html[/url]
  preg_match_all("/id\_(\w+)[=.]/", $link, $matches);
  if(!empty($matches[1][0])) {
   $return = $matches[1][0];
  }
} elseif('ku6.com' == $host) {
  // [url=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]http://tw.youtube.com/watch?v=hwHhRcRDAN0[/url]
  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]http://www.5show.com/show/show/160944.shtml[/url]
  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://tv.mofile.com/PPU3NTYW/[/url]
  //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) {
  // [url=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) {
  // [url=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) {
                // [url=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;
}
}
上面同时修改了mofile视频的bug,增加了支持土豆视频。
修改模板文件space_share_li.htm 找到(大约15行):
<!--{if $value['image']}-->
<a href="$value[image_link]"><img src="$value[image]" class="summaryimg image" alt="" width="70" /></a>
<!--{/if}-->
修改为:
<!--{if $value['image'] && 'video'!=$value['type']}-->
<a href="$value[image_link]"><img src="$value[image]" class="summaryimg image" alt="" width="70" /></a>
<!--{/if}-->
找到(22行左右):
<div class="media">
<img src="image/vd.gif" alt="点击播放" style="cursor:pointer;" />
</div>
修改为:
<div class="media">
<img src="<!--{if !empty($value['image'])}-->$value[image]<!--{else}-->/image/vd.gif<!--{/if}-->" alt="点击播放" style="cursor:pointer;" />
</div>
以上借用了feed表中的image字段,免得修改表结构了
然后是修改space_feed_li.htm
找到:
   <!--{if $value['image_1']}-->
   <a href="$value[image_1_link]"{$value[target]}><img src="$value[image_1]" class="summaryimg" /></a>
   <!--{/if}-->
修改为:
   <!--{if $value['image_1'] && empty($value['body_data']['flashvar'])}-->
   <a href="$value[image_1_link]"{$value[target]}><img src="$value[image_1]" class="summaryimg" /></a>
   <!--{/if}-->

发的仓促,以下内容漏掉了,现补上,feed页没有显示缩略图的注意一下在大约48行找到
                        <div class="media">
                                <img src="image/vd.gif" alt="点击播放" onclick="javascript:showFlash('{$value['body_data']['host']}', '{$value['body_data']['flashvar']}', this, '{$value['feedid']}');" style="cursor:pointer;" />
                        </div>
修改为
                        <div class="media">
                                <img src="<!--{if !empty($value['image_1'])}-->$value[image_1]<!--{else}-->/image/noimg.gif<!--{/if}-->" alt="点击播放" onclick="javascript:showFlash('{$value['body_data']['host']}', '{$value['body_data']['flashvar']}', this, '{$value['feedid']}');" style="cursor:pointer;" />
                        </div>


原先发过一个贴子:https://discuz.dismall.com/thread-1422324-1-1.html 很多朋友要求共享,现提供以上改进,也算是没让你们白回复一次。

修改中有何问题到临时支持网站:
http://www.zanjia.cn/space.php?uid=1&do=thread&id=4 中交流;

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?立即注册

x

评分

1

查看全部评分

abcnic18 发表于 2009-9-30 11:30:55 | 显示全部楼层
沙发来支持。。。
回复

使用道具 举报

jousst 发表于 2009-9-30 11:32:08 | 显示全部楼层
請問有支援youtube的方式嗎
回复

使用道具 举报

 楼主| dudupi 发表于 2009-9-30 11:38:18 | 显示全部楼层
楼上的,youtube我这边连不上,无法测试啊,应该可以的
回复

使用道具 举报

junhan 发表于 2009-9-30 11:42:18 | 显示全部楼层
好贴支持一下
回复

使用道具 举报

kufou 发表于 2009-9-30 11:44:05 | 显示全部楼层
难得好东东,支持一下!
回复

使用道具 举报

zhaolinlang 发表于 2009-9-30 11:55:22 | 显示全部楼层
楼主TJ啊?
MJJ?
咱家?
回复

使用道具 举报

weixinjoy 发表于 2009-9-30 12:03:31 | 显示全部楼层
提示: 作者被禁止或删除 内容自动屏蔽
回复

使用道具 举报

 楼主| dudupi 发表于 2009-9-30 12:18:29 | 显示全部楼层
是space_feed_li.htm,改过来了
回复

使用道具 举报

serverhz 发表于 2009-9-30 12:19:04 | 显示全部楼层
做板凳看插件电影了!
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

手机版|小黑屋|Discuz! 官方站 ( 皖ICP备16010102号 )star

GMT+8, 2024-10-6 19:51 , Processed in 0.472894 second(s), 22 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2023, Tencent Cloud.

快速回复 返回顶部 返回列表