PHP implementation using Youku Potato video address to get SWF player share address _php instance

Source: Internet
Author: User
Tags explode

The project is used for temporary writing. To be perfected:

Copy Code code as follows:
/*
* According to the user submitted (swf/html) address, access to Youku, potato SWF playback address
* */
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;
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.