学习NO.1 发表于 2018-1-6 02:53:17

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

很多用户不知道如何复制flash地址,只能在程序中帮他们替换了:
<?php
/**
* 支持优酷、土豆、腾讯视频html到swf转换
* @link http://www.phpddt.com
*/
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;
$domain = $types;

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) . '/v.swf';
break;
case 'tudou' :
$method = substr($types, 0, 1);
$method = $method == 'p' ? 'v' : $method;
preg_match_all('/http:\/\/www.tudou\.com\/(.*)?\/(.*)?/', $url, $url_array);
$str_arr = explode('/', $url_array);
$count = count($str_arr);
if ($count == 1) {
$id = explode('.', $url_array);
$id = $id;
} else if ($count == 2) {
$id = $str_arr;
} else if ($count == 3) {
$id = $str_arr;
}
$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;
}


/**
* 优酷视频转换测试
* 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>";

/**
* 腾讯视频转换测试
*
* 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>";

/**
* 土豆视频转换测试
*
* 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>";

学习NO.1 发表于 2018-7-6 14:55:34

兴隆 发表于 2018-6-26 19:15
真是难得给力的帖子啊。

http://www.hunterbj.com/Article/nm.html


看到这帖子真是高兴!非常感谢道勤的老师,太感谢了
页: [1]
查看完整版本: 优酷土豆腾讯视频html地址转flash swf地址的方法