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

 找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索

免费!!分享视频增加缩略图!更正版!

[复制链接]
耶小稣 发表于 2009-10-30 13:45:40 | 显示全部楼层 |阅读模式
本帖最后由 耶小稣 于 2010-01-26 10:22 编辑

插件说明
此插件来源于:
https://discuz.dismall.com/viewthread.php?tid=1431374
只是大多人都装不上去,我把代码重新写了下并附带了安装说明
功能:
将从youku,tudou,ku6,mofile等视频站分享的视频以缩略图显示

环境支持:
空间需支持file_get_contents函数。默认allow_url_fopen开启的时候该函数有效。
allow_url_fopen开启方法:
php.ini文件中将allow_url_fopen如下设置:(大部分空间都是开启的)
allow_url_fopen = on

这个是装上插件以后分享视频的效果


这个是安装插件之前分享的视频(没有缩略图,默认以图片代替)


安装说明
1、需要更改的文件
source/cp_share.php
source/script_common.js(支持土豆视频需要修改此文件)
template/你自己的风格目录/space_feed_li.htm(默认情况下此文件在默认风格目录即default文件夹下)
template/你自己的风格目录/space_share_li.htm(默认情况下此文件在默认风格目录即default文件夹下)
2、增加的文件
image/movie_icon.png(视频缩略图上显示的播放按钮)
image/noimg.gif(没有视频缩略图时的显示图标)
3、安装步骤
在2楼
安装说明:


免修改版本(内附安装说明)

本帖子中包含更多资源

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

x
 楼主| 耶小稣 发表于 2009-10-30 13:45:58 | 显示全部楼层
本帖最后由 耶小稣 于 2009-10-30 13:47 编辑
  1. 3.1打开cp_share.php(默认408行)
  2.                         if(preg_match("/(youku.com|youtube.com|5show.com|ku6.com|sohu.com|mofile.com|sina.com.cn)$/i", $parseLink['host'], $hosts)) {
  3.                                 $flashvar = getflash($link, $hosts[1]);
  4.                                 if(!empty($flashvar)) {
  5.                                         $arr['title_template'] = cplang('share_video');
  6.                                         $type = 'video';
  7.                                         $arr['body_data']['flashvar'] = $flashvar;
  8.                                         $arr['body_data']['host'] = $hosts[1];
  9.                                 }
  10.                         }
  11. 将上面代码用以下代码替换
  12.                         if(preg_match("/(youku.com|youtube.com|5show.com|ku6.com|sohu.com|mofile.com|sina.com.cn|tudou.com)$/i", $parseLink['host'], $hosts)) {
  13.                                 $flashvar = getflash($link, $hosts[1]);
  14.                                 $flashimg = getflashimg($link, $hosts[1]);
  15.                                 if(!empty($flashvar)) {
  16.                                         $arr['title_template'] = cplang('share_video');
  17.                                         $type = 'video';
  18.                                         $arr['body_data']['flashvar'] = $flashvar;
  19.                                         $arr['body_data']['host'] = $hosts[1];
  20.                                         if(!empty($flashimg)){
  21.                                                 $arr['image'] = $flashimg;
  22.                                         }
  23.                                 }
  24.                         }
  25. 3.2再查找function getflash($link, $host)(默认在490行)
  26. function getflash($link, $host) {
  27.         $return = '';
  28.         if('youku.com' == $host) {
  29.                 // http://v.youku.com/v_show/id_XNDg1MjA0ODg=.html
  30.                 preg_match_all("/id\_(\w+)[=.]/", $link, $matches);
  31.                 if(!empty($matches[1][0])) {
  32.                         $return = $matches[1][0];
  33.                 }
  34.         } elseif('ku6.com' == $host) {
  35.                 // http://v.ku6.com/show/bjbJKPEex097wVtC.html
  36.                 preg_match_all("/\/([\w\-]+)\.html/", $link, $matches);
  37.                 if(1 > preg_match("/\/index_([\w\-]+)\.html/", $link) && !empty($matches[1][0])) {
  38.                         $return = $matches[1][0];
  39.                 }
  40.         } elseif('youtube.com' == $host) {
  41.                 // http://tw.youtube.com/watch?v=hwHhRcRDAN0
  42.                 preg_match_all("/v\=([\w\-]+)/", $link, $matches);
  43.                 if(!empty($matches[1][0])) {
  44.                         $return = $matches[1][0];
  45.                 }
  46.         } elseif('5show.com' == $host) {
  47.                 // http://www.5show.com/show/show/160944.shtml
  48.                 preg_match_all("/\/(\d+)\.shtml/", $link, $matches);
  49.                 if(!empty($matches[1][0])) {
  50.                         $return = $matches[1][0];
  51.                 }
  52.         } elseif('mofile.com' == $host) {
  53.                 // http://tv.mofile.com/PPU3NTYW/
  54.                 preg_match_all("/\/(\w+)\/*$/", $link, $matches);
  55.                 if(!empty($matches[1][0])) {
  56.                         $return = $matches[1][0];
  57.                 }
  58.         } elseif('sina.com.cn' == $host) {
  59.                 // http://you.video.sina.com.cn/b/16776316-1338697621.html
  60.                 preg_match_all("/\/(\d+)-(\d+)\.html/", $link, $matches);
  61.                 if(!empty($matches[1][0])) {
  62.                         $return = $matches[1][0];
  63.                 }
  64.         } elseif('sohu.com' == $host) {
  65.                 // http://v.blog.sohu.com/u/vw/1785928
  66.                 preg_match_all("/\/(\d+)\/*$/", $link, $matches);
  67.                 if(!empty($matches[1][0])) {
  68.                         $return = $matches[1][0];
  69.                 }
  70.         }
  71.         return $return;
  72. }

  73. 将上面的代码用下面的替换
  74. function getflash($link, $host) {
  75.         $return = '';
  76.         if('youku.com' == $host) {
  77.                 // http://v.youku.com/v_show/id_XNDg1MjA0ODg=.html
  78.                 preg_match_all("/id\_(\w+)[=.]/", $link, $matches);
  79.                 if(!empty($matches[1][0])) {
  80.                         $return = $matches[1][0];
  81.                 }
  82.         } elseif('ku6.com' == $host) {
  83.                 // http://v.ku6.com/show/bjbJKPEex097wVtC.html
  84.                 preg_match_all("/\/([\w\-]+)\.html/", $link, $matches);
  85.                 if(1 > preg_match("/\/index_([\w\-]+)\.html/", $link) && !empty($matches[1][0])) {
  86.                         $return = $matches[1][0];
  87.                 }
  88.         } elseif('youtube.com' == $host) {
  89.                 // http://tw.youtube.com/watch?v=hwHhRcRDAN0
  90.                 preg_match_all("/v\=([\w\-]+)/", $link, $matches);
  91.                 if(!empty($matches[1][0])) {
  92.                         $return = $matches[1][0];
  93.                 }
  94.         } elseif('5show.com' == $host) {
  95.                 // http://www.5show.com/show/show/160944.shtml
  96.                 preg_match_all("/\/(\d+)\.shtml/", $link, $matches);
  97.                 if(!empty($matches[1][0])) {
  98.                         $return = $matches[1][0];
  99.                 }
  100.         } elseif('mofile.com' == $host) {
  101.                 // http://tv.mofile.com/PPU3NTYW/
  102.                 //http://v.mofile.com/show/HLD5PLD2.shtml
  103.                 preg_match_all("/\/([\w\-]+)\.shtml/", $link, $matches);
  104.                 if(!empty($matches[1][0])) {
  105.                         $return = $matches[1][0];
  106.                 }
  107.         } elseif('sina.com.cn' == $host) {
  108.                 // http://you.video.sina.com.cn/b/16776316-1338697621.html
  109.                 preg_match_all("/\/(\d+)-(\d+)\.html/", $link, $matches);
  110.                 if(!empty($matches[1][0])) {
  111.                         $return = $matches[1][0];
  112.                 }
  113.         } elseif('sohu.com' == $host) {
  114.                 // http://v.blog.sohu.com/u/vw/1785928
  115.                 preg_match_all("/\/(\d+)\/*$/", $link, $matches);
  116.                 if(!empty($matches[1][0])) {
  117.                         $return = $matches[1][0];
  118.                 }
  119.         } elseif('tudou.com' == $host) {
  120.         // http://www.tudou.com/programs/view/oOrUqgezkOc/
  121.         preg_match_all("/\/([\w\-]+)\/*$/", $link, $matches);
  122.         if(!empty($matches[1][0])) {
  123.             $return = $matches[1][0];
  124.         }
  125.     }
  126.         return $return;
  127. }
  128. function getflashimg($link, $host) {
  129.         $return='';
  130.         $content = file_get_contents($link);//获取
  131.         if('tudou.com' == $host)
  132.         {
  133.         preg_match_all("/<span class="s_pic">(.*?)<\/span>/i",$content,$img);
  134.         }
  135.         elseif('youku.com' == $host)
  136.         {
  137.         preg_match_all("/\+0800\|(.*?)\|">/i",$content,$img);
  138.         //$img = $img[1][0];
  139.         }
  140.         elseif('ku6.com' == $host)
  141.         {
  142.         preg_match_all("/<span class="s_pic">(.*?)<\/span>/i",$content,$img);
  143.         }
  144.         elseif('mofile.com' == $host)
  145.         {
  146.         preg_match_all("/thumbpath="(.*?)";/i",$content,$img);
  147.         }

  148.         $img = $img[1][0];
  149.         if($img){      
  150.                 $return = $img;
  151.         }
  152.         return $return;
  153. }
  154. 3.3
  155. 打开script_common.js(默认在342行)
  156. 在'mofile.com' : 'http://tv.mofile.com/cn/xplayer.swf?v=FLASHVAR',下面添加下面的代码(支持土豆)
  157. 'tudou.com' : 'http://www.tudou.com/v/FLASHVAR',
  158. 3.4
  159. 再查找hideObj.style.cursor = 'pointer';
  160. 在其下面加入下面代码:
  161. //add
  162. if('music' != host&&'flash' != host){
  163.                 $('icon_id_'+shareid).style.display='none';
  164.                 $('media_id_'+shareid).style.display='none';
  165.                }
  166. //end
  167. 3.5
  168. 查找obj.style.display = '';(有两处,在第一处下面)
  169. 在其下面添加代码:
  170. //add
  171. if('music' != host&&'flash' != host){
  172.                 $('icon_id_'+shareid).style.display='';
  173.                 $('media_id_'+shareid).style.display='';
  174.               }
  175. //end
  176. 3.6
  177. 打开space_feed_li.htm
  178. 查找:
  179. <!--{if $value['image_1']}-->
  180. 修改为:
  181. <!--{if $value['image_1'] && empty($value['body_data']['flashvar'])}-->
  182. 查找:(在47行)
  183.                         <div class="media">
  184.                                 <img src="image/vd.gif" alt="点击播放" onclick="javascript:showFlash('{$value['body_data']['host']}', '{$value['body_data']['flashvar']}', this, '{$value['feedid']}');" style="cursor:pointer;" />
  185.                         </div>
  186. 修改为:
  187.                         <div class="media">
  188.                   <div class="movie_app">       
  189.                     <img id=icon_id_$value[feedid] class=movie_icon alt="点击播放" src="image/movie_icon.png" alt="点击播放" onclick="javascript:showFlash('{$value['body_data']['host']}', '{$value['body_data']['flashvar']}', this, '{$value['feedid']}');" style="cursor:pointer;" />
  190.                                 <img id="media_id_$value[feedid]" class=movie_pic 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;" />
  191.                           </div>
  192.                         </div>
  193. 3.7
  194. 打开space_share_li.htm
  195. 查找:(默认15行附近)
  196. <!--{if $value['image']}-->
  197. 修改为:
  198. <!--{if $value['image'] && 'video'!=$value['type']}-->
  199. 查找:(默认22行附近)
  200.         <!--{if 'video' == $value['type']}-->
  201.         <div class="media">
  202.         <img src="image/vd.gif" alt="点击播放" onclick="javascript:showFlash('{$value['body_data']['host']}', '{$value['body_data']['flashvar']}', this, '{$value['sid']}');" style="cursor:pointer;" />
  203.         </div>
  204. 修改为:
  205.         <!--{if 'video' == $value['type']}-->
  206.         <div class="media">
  207.         <div class="movie_app">
  208.         <img id=icon_id_$value[sid] class=movie_icon alt="点击播放" src="image/movie_icon.png" alt="点击播放" onclick="javascript:showFlash('{$value['body_data']['host']}', '{$value['body_data']['flashvar']}', this, '{$value['sid']}');" style="cursor:pointer;">
  209.         <img id="media_id_$value[sid]" class=movie_pic src="<!--{if !empty($value['image'])}-->$value[image]<!--{else}-->/image/noimg.gif<!--{/if}-->" alt="点击播放" onclick="javascript:showFlash('{$value['body_data']['host']}', '{$value['body_data']['flashvar']}', this, '{$value['sid']}');" style="cursor:pointer;" />
  210.         </div>
  211.         </div>
  212. 3.8
  213. 打开default/style.css(缩略图上显示播放按钮需要修改此文件)
  214. 在文件末尾加上下面的代码:
  215. /**********************************************Vedio_img***/
  216. .movie_none{display:none;position:relative}
  217. .movie_app .movie_pic{width:128px;height:96px;}
  218. * html .movie_pic{width: expression(this.width > 120 ? 120 : true);  display:block}

  219. .media{display:block;POSITION: relative;zoom:1}
  220. .movie_app{}
  221. .movie_app img {margin-left:5px;margin-top:5px; max-width: 130px; max-height: 96px;}
  222. * 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}

  223. .movie_app .movie_icon {
  224.         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
  225. }
复制代码
回复

使用道具 举报

gaozhanzhu 发表于 2009-10-30 13:50:15 | 显示全部楼层

很好很强大!!!

本帖最后由 gaozhanzhu 于 2009-10-30 14:06 编辑

非常支持哦!!
很好很强大!!!
我也截个演示图支持下!

本帖子中包含更多资源

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

x
回复

使用道具 举报

meihuipeng 发表于 2009-10-30 13:58:19 | 显示全部楼层
演示呢..
回复

使用道具 举报

abcnic18 发表于 2009-10-30 14:02:17 | 显示全部楼层
哈哈~~ 支持了捏
回复

使用道具 举报

gaozhanzhu 发表于 2009-10-30 14:04:55 | 显示全部楼层
很好很强大!
回复

使用道具 举报

 楼主| 耶小稣 发表于 2009-10-30 14:10:18 | 显示全部楼层
谢谢谢谢!!!
回复

使用道具 举报

coldhair 发表于 2009-10-30 14:16:30 | 显示全部楼层
不错啊,谢谢分享啊
回复

使用道具 举报

 楼主| 耶小稣 发表于 2009-10-30 14:22:00 | 显示全部楼层
大家都试试看能不能用!
反正我给我的客户都装上了!!!
回复

使用道具 举报

xzxyd 发表于 2009-10-30 16:36:41 | 显示全部楼层
站位编辑!!!
回复

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-4-23 16:25 , Processed in 0.129841 second(s), 17 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2023, Tencent Cloud.

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