优酷土豆腾讯视频html地址转flash swf地址

很多用户不知道如何复制flash地址,只能在程序中帮他们替换了:


  
  
  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. preg_match_all('/http:\/\/(.*?)?\.(.*?)?\.com\/(.*)/', $url, $types);
  11. $type = $types[2][0];
  12. $domain = $types[1][0];
  13.  
  14. switch ($type) {
  15. case 'youku' :
  16. preg_match_all('/http:\/\/v\.youku\.com\/v_show\/id_(.*)?\.html/', $url, $url_array);
  17. $swf = 'http://player.youku.com/player.php/sid/' . str_replace('/', '', $url_array[1][0]) . '/v.swf';
  18. break;
  19. case 'tudou' :
  20. $method = substr($types[3][0], 0, 1);
  21. $method = $method == 'p' ? 'v' : $method;
  22. preg_match_all('/http:\/\/www.tudou\.com\/(.*)?\/(.*)?/', $url, $url_array);
  23. $str_arr = explode('/', $url_array[1][0]);
  24. $count = count($str_arr);
  25. if ($count == 1) {
  26. $id = explode('.', $url_array[2][0]);
  27. $id = $id[0];
  28. } else if ($count == 2) {
  29. $id = $str_arr[1];
  30. } else if ($count == 3) {
  31. $id = $str_arr[2];
  32. }
  33. $swf = 'http://www.tudou.com/' . $method . '/' . $id . '/v.swf';
  34. break;
  35. case 'qq' :
  36. $url_array = parse_url($url);
  37. $swf = "http://static.video.qq.com/TPout.swf?{$url_array['query']}&auto=0";
  38. break;
  39.  
  40. default :
  41. $swf = $url;
  42. break;
  43. }
  44. return $swf;
  45. }
  46.  
  47.  
  48. /**
  49. * 优酷视频转换测试
  50. * html地址 http://v.youku.com/v_show/id_XNzU4Mzg2NDA4.html?f=22720170&ev=2&from=y1.1-2.10001-0.1-2
  51. * swf地址 http://player.youku.com/player.php/sid/XNzU4Mzg2NDA4/v.swf
  52. */
  53.  
  54. 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");
  55. echo "<hr>";
  56.  
  57. /**
  58. * 腾讯视频转换测试
  59. *
  60. * html地址 http://v.qq.com/cover/w/w5lb270k15j7ita.html?vid=v0015mnd5x6
  61. * swf地址 http://static.video.qq.com/TPout.swf?vid=v0015mnd5x6&auto=0
  62. */
  63.  
  64. echo convert_html_to_swf("http://v.qq.com/cover/w/w5lb270k15j7ita.html?vid=v0015mnd5x6");
  65. echo "<hr>";
  66.  
  67. /**
  68. * 土豆视频转换测试
  69. *
  70. * html地址 http://www.tudou.com/albumplay/hqtp6W5XLN8/Kscjyz4J-RE.html
  71. * swf地址 http://www.tudou.com/a/hqtp6W5XLN8/&iid=132223533&resourceId=0_04_0_99/v.swf
  72. */
  73.  
  74. echo convert_html_to_swf("http://www.tudou.com/albumplay/hqtp6W5XLN8/Kscjyz4J-RE.html");
  75. echo "<hr>";
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值