PHP get Youku Tudou page in video SWF player address _php Tutorial

Source: Internet
Author: User
Below I will introduce to you a PHP get Youku Tudou page video SWF player address, temporary write not perfect friends can perfect and I share oh.
The code is as follows Copy Code


The project was written on a temporary basis. Ready to be perfected

/*
* Based on user-submitted (swf/html) address, get Youku, potato SWF play 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;
}

http://www.bkjia.com/PHPjc/633129.html www.bkjia.com true http://www.bkjia.com/PHPjc/633129.html techarticle below I will introduce to you a PHP get Youku Tudou page video SWF player address, temporary write not perfect friends can perfect and I share oh. Code to copy code as follows ...

  • 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.