[PHP] 优酷、土豆、腾讯视频html到swf转换 →→→→→进入此内容的聊天室

来自 , 2019-09-27, 写在 PHP, 查看 108 次.
URL http://www.code666.cn/view/1b79b52d
  1. <?php
  2. /**
  3.  * 支持优酷、土豆、腾讯视频html到swf转换
  4.  * @link http://www.phpddt.com
  5.  */
  6. function convert_html_to_swf($url = '')
  7. {
  8.     if(!is_string($url) || empty($url)) return ;
  9.     if(strpos($url, 'swf')) return $url;
  10.    
  11.     preg_match_all('/http:\/\/(.*?)?\.(.*?)?\.com\/(.*)/', $url, $types);
  12.     $type = $types[2][0];
  13.     $domain = $types[1][0];
  14.  
  15.     switch ($type) {
  16.         case 'youku' :
  17.             preg_match_all('/http:\/\/v\.youku\.com\/v_show\/id_(.*)?\.html/', $url, $url_array);
  18.             $swf = 'http://player.youku.com/player.php/sid/' . str_replace('/', '', $url_array[1][0]) . '/v.swf';
  19.             break;
  20.        
  21.         case 'tudou' :
  22.             $method = substr($types[3][0], 0, 1);
  23.             $method = $method == 'p' ? 'v' : $method;
  24.             preg_match_all('/http:\/\/www.tudou\.com\/(.*)?\/(.*)?/', $url, $url_array);
  25.             $str_arr = explode('/', $url_array[1][0]);
  26.             $count = count($str_arr);
  27.            
  28.             if ($count == 1) {
  29.                 $id = explode('.', $url_array[2][0]);
  30.                 $id = $id[0];
  31.             } else if ($count == 2) {
  32.                 $id = $str_arr[1];
  33.             } else if ($count == 3) {
  34.                 $id = $str_arr[2];
  35.             }
  36.            
  37.             $swf = 'http://www.tudou.com/' . $method . '/' . $id . '/v.swf';
  38.             break;
  39.            
  40.         case 'qq' :
  41.             $url_array = parse_url($url);
  42.             $swf = "http://static.video.qq.com/TPout.swf?{$url_array['query']}&auto=0";
  43.             break;
  44.  
  45.         default :
  46.             $swf = $url;
  47.             break;
  48.     }
  49.     return $swf;
  50. }
  51.  
  52.  
  53. /**
  54.  * 优酷视频转换测试
  55.  * html地址  http://v.youku.com/v_show/id_XNzU4Mzg2NDA4.html?f=22720170&ev=2&from=y1.1-2.10001-0.1-2
  56.  * swf地址 http://player.youku.com/player.php/sid/XNzU4Mzg2NDA4/v.swf
  57.  */
  58.  
  59. echo convert_html_to_swf("http://v.youku.com/v_show/id_XNzU4Mzg2NDA4.html?f=22720170&ev=2&from=y1.1-2.10001-0.1-2");
  60. echo "<hr>";
  61.  
  62. /**
  63.  * 腾讯视频转换测试
  64.  *
  65.  * html地址 http://v.qq.com/cover/w/w5lb270k15j7ita.html?vid=v0015mnd5x6
  66.  * swf地址 http://static.video.qq.com/TPout.swf?vid=v0015mnd5x6&auto=0
  67.  */
  68.  
  69. echo convert_html_to_swf("http://v.qq.com/cover/w/w5lb270k15j7ita.html?vid=v0015mnd5x6");
  70. echo "<hr>";
  71.  
  72. /**
  73.  * 土豆视频转换测试
  74.  *
  75.  * html地址 http://www.tudou.com/albumplay/hqtp6W5XLN8/Kscjyz4J-RE.html
  76.  * swf地址  http://www.tudou.com/a/hqtp6W5XLN8/&iid=132223533&resourceId=0_04_0_99/v.swf
  77.  */
  78.  
  79. echo convert_html_to_swf("http://www.tudou.com/albumplay/hqtp6W5XLN8/Kscjyz4J-RE.html");
  80. echo "<hr>";

回复 "优酷、土豆、腾讯视频html到swf转换"

这儿你可以回复上面这条便签

captcha