项目用到临时写的。待完善:
/*<BR> * 根据用户提交的(swf/html)地址,获取优酷,土豆的swf播放地址<BR> * */<BR> private function _getSwf ($url = '') {<BR> if(isset($url) && !empty($url)){<BR> preg_match_all('/http:\/\/(.*?)?\.(.*?)?\.com\/(.*)/',$url,$types);<BR> }else{<BR> return false;<BR> }<BR> $type = $types[2][0];<BR> $domain = $types[1][0];<BR> $isswf = strpos($types[3][0], 'v.swf') === false ? false : true;<BR> $method = substr($types[3][0],0,1);</P><P> switch ($type){<BR> case 'youku' :<BR> if( $domain == 'player' ) {<BR> $swf = $url;<BR> }else if( $domain == 'v' ) {<BR> preg_match_all('/http:\/\/v\.youku\.com\/v_show\/id_(.*)?\.html/',$url,$url_array);<BR> $swf = 'http://player.youku.com/player.php/sid/'.str_replace('/','',$url_array[1][0]).'/v.swf';<BR> }else{<BR> $swf = $url;<BR> }<BR> break;<BR> case 'tudou' :<BR> if($isswf){<BR> $swf = $url;<BR> }else{<BR> $method = $method == 'p' ? 'v' : $method ;<BR> preg_match_all('/http:\/\/www.tudou\.com\/(.*)?\/(.*)?/',<div style="color:transparent">!本文来源gaodai.ma#com搞##代!^码网(</div><sup>搞gaodaima代码</sup>$url,$url_array);<BR> $str_arr = explode('/',$url_array[1][0]);<BR> $count = count($str_arr);<BR> if($count == 1) {<BR> $id = explode('.',$url_array[2][0])[0];<BR> }else if($count == 2){<BR> $id = $str_arr[1];<BR> }else if($count == 3){<BR> $id = $str_arr[2];<BR> }<BR> $swf = 'http://www.tudou.com/'.$method.'/'.$id.'/v.swf';<BR> }<BR> break;<BR> default :<BR> $swf = $url;<BR> break;<BR> }<BR> return $swf;<BR> }<BR>