您好,欢迎来到三六零分类信息网!老站,搜索引擎当天收录,欢迎发信息

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

2024/11/10 6:58:57发布20次查看
下面我来给各位同学介绍一个php获取优酷土豆页面中视频swf播放器地址,临时写的不够完善各位朋友可完善与我分享哦。
 代码如下 复制代码
项目用到临时写的。待完善
/*
     * 根据用户提交的(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);
        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;
    }
http://www.bkjia.com/phpjc/633129.htmlwww.bkjia.comtruehttp://www.bkjia.com/phpjc/633129.htmltecharticle下面我来给各位同学介绍一个php获取优酷土豆页面中视频swf播放器地址,临时写的不够完善各位朋友可完善与我分享哦。 代码如下 复制代码...
该用户其它信息

VIP推荐

免费发布信息,免费发布B2B信息网站平台 - 三六零分类信息网 沪ICP备09012988号-2
企业名录 Product