这家伙很懒~

优酷、土豆、腾讯视频html到swf转换

Javascript2015-01-23 15:40:00swf
<?php
/*
 * 支持优酷、土豆、腾讯视频html到swf转换
 * @link http://www.phpddt.com</p><p name="4-706b">
*/
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']}&amp;auto=0";
            break;
        default :
            $swf = $url;
            break;
    }
    return $swf;
}
讨论(0)
  • 暂无,求挽尊 ~
还可输入2000个字
京公网安备 11011202003202号 鲁ICP备 13027548号-1