示例#1
0
/**
*######################################################################
*#  video  [video type="vimeo" video_id=""]
*######################################################################
*/
function video($atts)
{
    if (isset($atts['type'])) {
        switch ($atts['type']) {
            case 'youtube':
                return youtube($atts);
                break;
            case 'vimeo':
                return vimeo($atts);
                break;
            case 'dailymotion':
                return dailymotion($atts);
                break;
        }
    }
    return '';
}
示例#2
0
文件: func.php 项目: BGmot/kitchen
function rutube($body, $embed = true)
{
    $result = preg_replace_callback('#(?<!\\[url(=|]))((?:https?://)?(?:www\\.)?rutube\\.ru/video/([\\w-]{10,32})/(?:(?:\\?|&)[^\\s<\\]"]*)?)#i', function ($matches) use($embed) {
        $url = $matches[2];
        $id = $matches[3];
        $obj2 = file_get_contents("http://www.rutube.ru/api/video/" . $id . "/");
        //var_dump($obj2);
        if ($obj2 === FALSE) {
            return $url;
        }
        $ar2 = json_decode($obj2);
        $new_body = $url;
        if ($ar2 !== false) {
            // calculate duration
            $di = intval($ar2->duration);
            $duration = '';
            if ((int) ($di / 3600) > 0) {
                $duration .= (int) ($di / 3600) . ':';
            }
            $di %= 3600;
            $duration .= (int) ($di / 60) . ':' . $di % 60;
            $title = $ar2->title;
            if ($embed) {
                $new_body = preg_replace(array('#<iframe (.*)></iframe>#i', '#width="([0-9]*)"#i', '#height="([0-9]*)"#i'), array('[iframe id="rutube-video" $1]', 'width="480"', 'height="320"'), $ar2->html);
                $new_body .= "\n[i][color=lightslategrey][url=" . $url . "][b]" . $title . "[/b]; " . $duration . "[/url][/color][/i] ";
            } else {
                $thumbnail = $ar2->thumbnail_url;
                $new_body .= "\n[i][color=lightslategrey]( " . "[b]" . $title . "[/b]; " . $duration . ")[/color][/i] ";
                $new_body .= "\n[img=" . $thumbnail . "]";
            }
        }
        return $new_body;
    }, $body);
    return dailymotion($result);
}