立即注册 找回密码

QQ登录

只需一步,快速开始

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

2018-1-16 00:23| 发布者: 猪八戒| 查看: 2701| 评论: 0

摘要: 项目用到临时写的。待完善2/* * 根据用户提交的(swf/html)地址,获取优酷,土豆的swf播放地址 * */ private function _getSwf ($url = '') { if(isset($url) !empty($url)){ preg_match_all('/http://(.*?)?.( ...
项目用到临时写的。待完善
2/*
     * 根据用户提交的(swf/html)地址,获取优酷,土豆的swf播放地址
     * */
    private function _getSwf ($url = '') {
        if(isset($url) && !empty($url)){
            preg_match_all('/http://(.*?)?.(.*?)?.com/(.*)/',$url,$types);
        }else{
            return false;
        }
        $type = $types[2][0];
        $domain = $types[1][0];
        $isswf = strpos($types[3][0], 'v.swf') === false ? false : true;
        $method = substr($types[3][0],0,1);
3        switch ($type){
            case 'youku' :
                if( $domain == 'player' ) {
                    $swf = $url;
                }else if( $domain == 'v' ) {
                    preg_match_all('/http://v.youku.com/v_show/id_(.*)?.html/',$url,$url_array);
                    $swf = 'http://player.youku.com/player.php/sid/'.str_replace('/','',$url_array[1][0]).'/v.swf';
                }else{
                    $swf = $url;
                }
                break;
            case 'tudou' :
                if($isswf){
                    $swf = $url;
                }else{
                    $method = $method == 'p' ? 'v' : $method ;
                    preg_match_all('/http://www.tudou.com/(.*)?/(.*)?/',$url,$url_array);
                    $str_arr = explode('/',$url_array[1][0]);
                    $count = count($str_arr);
                    if($count == 1) {
                        $id = explode('.',$url_array[2][0])[0];
                    }else if($count == 2){
                        $id = $str_arr[1];
                    }else if($count == 3){
                        $id = $str_arr[2];
                    }
                    $swf = 'http://www.tudou.com/'.$method.'/'.$id.'/v.swf';
                }
                break;
            default :
                $swf = $url;
                break;
        }
        return $swf;
    }

鲜花

握手

雷人

路过

鸡蛋

最新评论

相关推荐
相关推荐
道勤望推介优质主机商
道勤网推荐优质idc主机
!jz_fbzt! !jz_lxwm! !jz_gfqqq!

关于我们|手机版|小黑屋|地图|【道勤网】-www.daoqin.net 软件视频自学教程|免费教程|自学电脑|3D教程|平面教程|影视动画教程|办公教程|机械设计教程|网站设计教程 ( 皖ICP备15000319号-1 )

GMT+8, 2024-12-26 09:30

Powered by DaoQin! X3.4 © 2016-2063 Dao Qin & 道勤科技

返回顶部