Home > Backend Development > PHP Tutorial > PHP gets the video swf player address in Youku Tudou page_PHP tutorial

PHP gets the video swf player address in Youku Tudou page_PHP tutorial

WBOY
Release: 2016-07-13 10:44:17
Original
1039 people have browsed it

Now let me introduce to you a php method to get the video swf player address on the Youku Tudou page. The temporary writing is not perfect, so friends can improve it and share it with me.

The code is as follows Copy code


The project uses temporary writing. To be improved

/*
*According to the (swf/html) address submitted by the user, obtain the swf playback address of Youku and Tudou
* */
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;
    }

www.bkjia.comtruehttp: //www.bkjia.com/PHPjc/633129.htmlTechArticleNow let me introduce to you a php to get the video swf player address on the Youku Tudou page. I haven’t written enough temporarily. If you want to improve it, you can share it with me. The code is as follows Copy the code...
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template