The project uses temporary write. To be improved:
Copy codeThe Code is as follows :/*
* Obtain the swf playback address of Youku and Tudou based on the (swf/html) Address submitted by the user.
**/
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 'tuu ':
If ($ isswf ){
$ Swf = $ url;
} Else {
$ 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/'.w.method.'/'.mongoid.'/v.swf ';
}
Break;
Default:
$ Swf = $ url;
Break;
}
Return $ swf;
}