首页 > 开发 > PHP > 正文

PHP实现使用优酷土豆视频地址获取swf播放器分享地址

2024-05-04 22:20:56
字体:
来源:转载
供稿:网友

项目用到临时写的。待完善:
代码如下:/*
     * 根据用户提交的(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);

发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表