欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

PHP實(shí)現(xiàn)將優(yōu)酷土豆騰訊視頻html地址轉(zhuǎn)換成flash swf地址的方法

 更新時(shí)間:2017年08月04日 09:39:10   作者:hsany330  
這篇文章主要介紹了PHP實(shí)現(xiàn)將優(yōu)酷土豆騰訊視頻html地址轉(zhuǎn)換成flash swf地址的方法,涉及php根據(jù)各個(gè)網(wǎng)站的網(wǎng)址規(guī)則針對URL地址的正則匹配與轉(zhuǎn)換相關(guān)操作技巧,需要的朋友可以參考下

本文實(shí)例講述了PHP實(shí)現(xiàn)將優(yōu)酷土豆騰訊視頻html地址轉(zhuǎn)換成flash swf地址的方法。分享給大家供大家參考,具體如下:

很多用戶不知道如何復(fù)制flash地址,只能在程序中幫他們替換了:

<?php
/**
 * 支持優(yōu)酷、土豆、騰訊視頻html到swf轉(zhuǎn)換
 */
function convert_html_to_swf($url = '')
{
  if(!is_string($url) || empty($url)) return ;
  if(strpos($url, 'swf')) return $url;
  preg_match_all('/http:\/\/(.*?)?\.(.*?)?\.com\/(.*)/', $url, $types);
  $type = $types[2][0];
  $domain = $types[1][0];
  switch ($type) {
    case 'youku' :
      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';
      break;
    case 'tudou' :
      $method = substr($types[3][0], 0, 1);
      $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]);
        $id = $id[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;
    case 'qq' :
      $url_array = parse_url($url);
      $swf = "http://static.video.qq.com/TPout.swf?{$url_array['query']}&auto=0";
      break;
    default :
      $swf = $url;
      break;
  }
  return $swf;
}
/**
 * 優(yōu)酷視頻轉(zhuǎn)換測試
 * html地址 http://v.youku.com/v_show/id_XNzU4Mzg2NDA4.html?f=22720170&ev=2&from=y1.1-2.10001-0.1-2
 * swf地址 http://player.youku.com/player.php/sid/XNzU4Mzg2NDA4/v.swf
 */
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");
echo "<hr>";
/**
 * 騰訊視頻轉(zhuǎn)換測試
 *
 * html地址 http://v.qq.com/cover/w/w5lb270k15j7ita.html?vid=v0015mnd5x6
 * swf地址 http://static.video.qq.com/TPout.swf?vid=v0015mnd5x6&auto=0
 */
echo convert_html_to_swf("http://v.qq.com/cover/w/w5lb270k15j7ita.html?vid=v0015mnd5x6");
echo "<hr>";
/**
 * 土豆視頻轉(zhuǎn)換測試
 *
 * html地址 http://www.tudou.com/albumplay/hqtp6W5XLN8/Kscjyz4J-RE.html
 * swf地址 http://www.tudou.com/a/hqtp6W5XLN8/&iid=132223533&resourceId=0_04_0_99/v.swf
 */
echo convert_html_to_swf("http://www.tudou.com/albumplay/hqtp6W5XLN8/Kscjyz4J-RE.html");
echo "<hr>";

PS:這里再為大家提供兩款相關(guān)在線工具供大家參考使用:

迅雷、快車、旋風(fēng)URL加密/解密工具:
http://tools.jb51.net/password/urlrethunder

flash版在線下載地址加密解密工具(支持迅雷/快車/旋風(fēng)):
http://tools.jb51.net/password/flash_download_encode

更多關(guān)于PHP相關(guān)內(nèi)容感興趣的讀者可查看本站專題:《PHP數(shù)學(xué)運(yùn)算技巧總結(jié)》、《php正則表達(dá)式用法總結(jié)》、《PHP基本語法入門教程》、《PHP數(shù)組(Array)操作技巧大全》、《php字符串(string)用法總結(jié)》及《php常見數(shù)據(jù)庫操作技巧匯總

希望本文所述對大家PHP程序設(shè)計(jì)有所幫助。

相關(guān)文章

最新評論