V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
jeequ
V2EX  ›  程序员

PHP 获取优酷视频缩略图,视频播放时长

  •  
  •   jeequ · 2013-10-18 14:28:37 +08:00 · 5932 次点击
    这是一个创建于 3843 天前的主题,其中的信息可能已经有所发展或是发生改变。
    我不是程序员,只是一个业余的wordpress玩家,已经成功制作出这两个功能。各人已经觉得非常不错了。大家可以看看效果http://jeequ.com
    3 条回复    1970-01-01 08:00:00 +08:00
    a7898585
        1
    a7898585  
       2013-10-18 23:27:02 +08:00
    求分享源码
    wontao
        2
    wontao  
       2013-10-19 00:21:45 +08:00   ❤️ 1
    function get_youku_thumb($url) {
    $content = file_get_contents($url);
    preg_match( '/id="s_msn2".*?screenshot=(.*?)".?target=/', $content, $matchs );
    return $matchs[1];
    }
    echo get_youku_thumb('
    ');
    jingwentian
        3
    jingwentian  
       2013-10-20 01:09:12 +08:00
    function youku( $vid ) {
    if ( !$vid ) {
    return false;
    }

    if ( !preg_match( '/^[0-9a-z_-]+$/i', $vid ) ) {
    if ( !preg_match( '/^http\:\/\/v\.youku\.com\/v_show\/id_([0-9a-z_-]+)/i', $vid, $match ) && !preg_match( '/^http\:\/\/player\.youku\.com\/player\.php[0-9a-z\/_-]*\/sid\/([0-9a-z_-]+)/i', $vid, $match ) ) {
    return false;
    }
    $vid = $match[1];
    }

    $url = 'http://v.youku.com/player/getPlayList/VideoIDS/' . $vid;
    if ( !$json = $this->url( $url ) ) {
    return false;
    }
    if ( !$json = @json_decode( $json, true ) ) {
    return false;
    }
    if ( empty( $json['data'][0] ) ) {
    return false;
    }
    $json = $json['data'][0];

    $r['vid'] = $json['vidEncoded'];
    $r['url'] = 'http://v.youku.com/v_show/id_'. $json['vidEncoded'] .'.html?f=http://www.lianyue.org/';
    $r['swf'] = 'http://player.youku.com/player.php/sid/'. $json['vidEncoded'] .'/lianyue.swf';
    $r['title'] = $json['title'];
    $r['img']['large'] = $json['logo'];
    $r['img']['small'] = str_replace( '.com/11', '.com/01', $json['logo'] );
    $r['time'] = $json['seconds'];
    $r['tag'] = $json['tags'];
    return $r;
    }
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2787 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 25ms · UTC 06:14 · PVG 14:14 · LAX 23:14 · JFK 02:14
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.