优酷 土豆 爱奇艺 腾讯视频播放插件

IT-Pony 2016-05-16 AM 586℃ 0条
<?php
    //定义播放页面
    $vod_play = [
        'youku'    => '<iframe src="http://player.youku.com/embed/*" frameborder=0 allowfullscreen></iframe>',
        'qq'    => '<iframe frameborder="0" src="http://v.qq.com/iframe/player.html?vid=*&tiny=0&auto=0" allowfullscreen></iframe>',
        'tudou' => '<iframe src="http://www.tudou.com/programs/view/html5embed.action?code=*" allowtransparency="true" allowfullscreen="true" allowfullscreenInteractive="true" scrolling="no" border="0" frameborder="0"></iframe>',
        'iqiyi' => '<iframe src="http://open.iqiyi.com/developer/player_js/coopPlayerIndex.html?*&accessToken=2.f22860a2479ad60d8da7697274de9346&appKey=3955c3425820435e86d0f4cdfe56f5e7&appId=1368&height=100%&width=100%" frameborder="0" allowfullscreen="true" width="100%" height="100%"></iframe>'
    ];
    //定义播放类型
    $share_type = $_GET['type'];

    $value = [
        'qq' => function ($url){
            //匹配唯一视频id标识
            preg_match('/vid:"(.*)"/',file_get_contents($url),$param);
            返回匹配结果
            return $param[1];
        },
        'youku' => function ($url){
            //获取视频id
            return explode('.html',explode('id_',$url)[1])[0];
        },
        'tudou' => function ($url){
            //获取视频id
            preg_match('/,icode: \'(.*)\'/',file_get_contents($url),$param);

            return $param[1];
        },
        'iqiyi' => function ($url){
            //请求数据
            $content = file_get_contents($url);
            //查找视频id
            preg_match('/tvId:(.*),/',$content,$param);
            //匹配videoid
            preg_match('/data-player-videoid="(.*)"/',$content,$params);
            //返回匹配拼接字符串
            return 'vid='.$params[1].'&tvId='.$param[1];
        }
    ];
    //执行地址结果替换
    $vod_play[$share_type] = str_ireplace('*',$value[$share_type]($_GET['url']),$vod_play[$share_type]);
    //输出视频
    die($vod_play[$share_type]);
标签: none

非特殊说明,本博所有文章均为博主原创。

评论啦~