频道栏目
首页 > 资讯 > 面向对象 > 正文

php获取优酷土豆页面中视频swf播放器地址

16-01-07        来源:[db:作者]  
收藏   我要投稿
  1. 项目用到临时写的。待完善 /*
  2. *根据用户提交的(swf/html)地址,获取优酷,土豆的swf播放地址 **/
  3. privatefunction_getSwf($url=''){ if(isset($url)&&!emptyempty($url)){
  4. preg_match_all('/http://(.*?)?.(.*?)?.com/(.*)/',$url,$types); }else{
  5. returnfalse; }
  6. $type=$types[2][0]; $domain=$types[1][0];
  7. $isswf=strpos($types[3][0],'v.swf')===false?false:true; $method=substr($types[3][0],0,1);
  8. switch($type){ case'youku':
  9. if($domain=='player'){ $swf=$url;
  10. }elseif($domain=='v'){ preg_match_all('/http://v.youku.com/v_show/id_(.*)?.html/',$url,$url_array);
  11. $swf='http://player.youku.com/player.php/sid/'.str_replace('/','',$url_array[1][0]).'/v.swf'; }else{
  12. $swf=$url; }
  13. break; case'tudou':
  14. if($isswf){ $swf=$url;
  15. }else{ $method=$method=='p'?'v':$method;
  16. preg_match_all('/http://www.tudou.com/(.*)?/(.*)?/',$url,$url_array); $str_arr=explode('/',$url_array[1][0]);
  17. $count=count($str_arr); if($count==1){
  18. $id=explode('.',$url_array[2][0])[0]; }elseif($count==2){
  19. $id=$str_arr[1]; }elseif($count==3){
  20. $id=$str_arr[2]; }
  21. $swf='http://www.tudou.com/'.$method.'/'.$id.'/v.swf'; }
  22. break; default:
  23. $swf=$url; break;
  24. } return$swf;
  25. }
相关TAG标签
上一篇:PHP中关键字与魔术方法介绍
下一篇:PHP 5.0中多态性的实现方案浅析
相关文章
图文推荐

关于我们 | 联系我们 | 广告服务 | 投资合作 | 版权申明 | 在线帮助 | 网站地图 | 作品发布 | Vip技术培训 | 举报中心

版权所有: 红黑联盟--致力于做实用的IT技术学习网站