This article mainly introduces how to use Youku Tudou's video address to obtain the swf player sharing address, that is, to analyze Youku Tudou's video page address and obtain the corresponding swf player sharing address, if you need it, you can refer to the project to use temporary writing. To be improved:
The 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;
}