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)換測試
* 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ì)有所幫助。
- 易語言將指定的主機(jī)名與IP地址轉(zhuǎn)換功能
- 將IP地址轉(zhuǎn)換為整型數(shù)字的PHP方法、Asp方法和MsSQL方法、MySQL方法
- 兩端口路由器地址轉(zhuǎn)換的例子
- Cisco 路由器動態(tài)和靜態(tài)地址轉(zhuǎn)換
- FormatRemoteUrl函數(shù)之a(chǎn)sp實(shí)現(xiàn)格式化成當(dāng)前網(wǎng)站完整的URL-將相對地址轉(zhuǎn)換為絕對地址的代碼
- 如何把URL和郵件地址轉(zhuǎn)換為超級鏈接?
- 使用網(wǎng)絡(luò)地址轉(zhuǎn)換實(shí)現(xiàn)多服務(wù)器負(fù)載均衡
- NAT網(wǎng)絡(luò)地址轉(zhuǎn)換詳情
相關(guān)文章
基于ThinkPHP+uploadify+upload+PHPExcel 無刷新導(dǎo)入數(shù)據(jù)
這篇文章主要介紹了基于ThinkPHP+uploadify+upload+PHPExcel 無刷新導(dǎo)入數(shù)據(jù)的相關(guān)資料,需要的朋友可以參考下2015-09-09
PHP把MSSQL數(shù)據(jù)導(dǎo)入到MYSQL的方法
這篇文章主要介紹了PHP把MSSQL數(shù)據(jù)導(dǎo)入到MYSQL的方法,分別列舉了兩個(gè)實(shí)例實(shí)現(xiàn)將MSSQL數(shù)據(jù)導(dǎo)入到MYSQL的功能,是非常實(shí)用的技巧,具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2014-12-12
PHP中使用file_get_contents抓取網(wǎng)頁中文亂碼問題解決方法
這篇文章主要介紹了PHP中使用file_get_contents抓取網(wǎng)頁中文亂碼問題解決方法,可以通過使用curl配置gzip選項(xiàng)來解決,具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2014-12-12

