相關(guān)關(guān)鍵詞
關(guān)于我們
最新文章
- PHP中opcode緩存簡(jiǎn)單用法分析
- thinkPHP控制器變量在模板中的顯示方法示例
- PHP move_uploaded_file() 函數(shù)(將上傳的文件移動(dòng)到新位置)
- dirname(__FILE__)的含義和應(yīng)用說明
- thinkPHP5框架實(shí)現(xiàn)分頁(yè)查詢功能的方法示例
- PHP中單雙號(hào)與變量
- PHP獲得當(dāng)日零點(diǎn)時(shí)間戳的方法分析
- Laravel ORM對(duì)Model::find方法進(jìn)行緩存示例詳解
- PHP讀寫文件高并發(fā)處理操作實(shí)例詳解
- 【CLI】利用Curl下載文件實(shí)時(shí)進(jìn)度條顯示的實(shí)現(xiàn)
PHP實(shí)現(xiàn)將優(yōu)酷土豆騰訊視頻html地址轉(zhuǎn)換成flash swf地址的方法
本文實(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)換測(cè)試 * 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)換測(cè)試 * * 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)換測(cè)試 * * 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>";