上午刚发现这个插件 下来看看 插件写不错 但也有BUG 目前发现 如果分享的视频是土豆的豆单 自动获取分享就会出问题
无论你填写的是豆单的第几个视频 他都会解析成第一个视频 即http://www.tudou.com/playlist/p/l14476853.html 和 http://www.tudou.com/playlist/p/l14476853i109422837.html 解析出来的标题 图片和视频的地址是一样的 经查程序发现 在getflashimg 函数中 有逻辑错误 特贴出代码忘楼主更改 这也是对楼主的一种支持
原代码:
- function getflashimg($link, $host) {
- $return='';
- if('tudou.com' == $host){
- $content = file_get_contents($link);
- $content = gzdecode($content);
- //desc = "
- preg_match_all("/desc = "(.*?)"/i",$content,$message);
- $message = diconv($message[1][0], 'GB18030', 'UTF-8');
- if(preg_match_all("/view\/([\w\-]+)\//i", $link, $matches)){
- //,title = "超载被查司机车底“躲猫猫”"
- preg_match_all("/title = "(.*?)"/i",$content,$varchar);
- $title = diconv($varchar[1][0], 'GB18030', 'UTF-8');
- //pic = 'http://i1.tdimg.com/111/212/014/p.jpg'
- preg_match_all("/pic = \'(.*?)\'/i",$content,$img);
- //,iid = 111212014
- preg_match_all("/,iid = (\d+)/i",$content,$varchar);
- $getiid = $varchar[1][0];
- $code1 = $matches[1][0];
- $geturl = "http://www.tudou.com/v/".$code1."/v.swf";
- }else{//从这里开始有错误
- //,ltitle = "湖南耒阳矿征办暗箱操作 集体贪腐"
- preg_match_all("/,ltitle = "(.*?)"/i",$content,$varchar);
- $title = diconv($varchar[1][0], 'GB18030', 'UTF-8');
- if(!$title){
- preg_match_all("/title:"(.*?)"/i",$content,$varchar);
- $title = diconv($varchar[1][0], 'GB18030', 'UTF-8');
- }
- //pic:"http://i4.tdimg.com/111/180/333/p.jpg"
- preg_match_all("/pic:"(.*?)"/i",$content,$img);
- //iid:111180333
- preg_match_all("/iid:(\d+)/i",$content,$varchar);
- $getiid = $varchar[1][0];
- preg_match_all("/lcode = \'(.*?)\'/i",$content,$varchar);
- $code1 = $varchar[1][0];
- $geturl = "http://www.tudou.com/l/".$code1."/&iid=".$getiid."/v.swf";
- }
- }elseif('sina.com.cn' == $host){
复制代码 修改后:
- function getflashimg($link, $host) {
- $return='';
- if('tudou.com' == $host){
- $content = file_get_contents($link);
- $content = $this->gzdecode($content);
- //desc = "
- preg_match_all("/desc = "(.*?)"/i",$content,$message);
- $message = $this->diconv($message[1][0], 'GB18030', 'UTF-8');
- if(preg_match_all("/view\/([\w\-]+)\//i", $link, $matches)){
- //,title = "超载被查司机车底“躲猫猫”"
- preg_match_all("/title = "(.*?)"/i",$content,$varchar);
- $title = $this->diconv($varchar[1][0], 'GB18030', 'UTF-8');
- //pic = 'http://i1.tdimg.com/111/212/014/p.jpg'
- preg_match_all("/pic = \'(.*?)\'/i",$content,$img);
- //,iid = 111212014
- preg_match_all("/,iid = (\d+)/i",$content,$varchar);
- $getiid = $varchar[1][0];
- $code1 = $matches[1][0];
- $geturl = "http://www.tudou.com/v/".$code1."/v.swf";
- }else{//从这里开始修正
- //iid:111180333
- preg_match_all("/iid:(\d+)/i",$content,$varchar);
- //匹配URL中的iid
- preg_match("/i(\d+)\.html/i",$link,$iid);
- $iid=$iid[1];
- //获取iid对应的数组键值
- if(!empty($iid)){
- $key=array_search($iid,$varchar[1]);
- }else{
- $key=0;
- }
- $getiid = $varchar[1][$key];
- //,ltitle = "湖南耒阳矿征办暗箱操作 集体贪腐"
- preg_match_all("/,ltitle = "(.*?)"/i",$content,$varchar);
- $title = $this->diconv($varchar[1][$key], 'GB18030', 'UTF-8');
- if(!$title){
- preg_match_all("/title:"(.*?)"/i",$content,$varchar);
- $title = $this->diconv($varchar[1][$key], 'GB18030', 'UTF-8');
- }
- //pic:"http://i4.tdimg.com/111/180/333/p.jpg"
- preg_match_all("/pic:"(http:\/\/i.*?.jpg)"/i",$content,$varchar);
- $img[1][0]=$varchar[1][$key];
- preg_match_all("/,icode:"(.*?)"/i",$content,$varchar);
- $code1 = $varchar[1][$key];
- $geturl = "http://www.tudou.com/l/".$code1."/&iid=".$getiid."/v.swf";
- }
- }elseif('sina.com.cn' == $host){
复制代码
|