<?xml version="1.0" encoding="utf-8"?>
<parser delay="1500" speed="2M" date="2021.03.24">
    <url><![CDATA[https?://v\.qq\.com/.*?(?:/(?<id>\w{11,})\.html?|vid=(?<id>[^&]+))]]></url>
    <title><![CDATA[VIDEO_INFO.*?"title":"([^"]+)"]]></title>
    <thumbnail><![CDATA[thumbnail=([^,]+)]]></thumbnail>
    <duration><![CDATA[VIDEO_INFO.*?duration":([^,]+)]]></duration>
    <mediaUrl><![CDATA[cr_video_url=([^\$]+)]]></mediaUrl>
    <ckSign><![CDATA[main_login]]></ckSign>
    <headers><![CDATA[User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/85.0.4183.121 Safari/537.36]]></headers>
    <exjs><![CDATA[https://cdn.jsdelivr.net/gh/btjson/player@latest/aes.js]]></exjs>
    <jsCode><![CDATA[
        try {
            //https://v.qq.com/iframe/player.html?vid=v05042iyre8&width=500&height=375&auto=0
            if (window.location.href.indexOf('vid=') != -1) {
                var vid = window.location.href.match(/vid=([^&]+)/)[1];
                var video_url = 'https://v.qq.com/x/page/' + vid + '.html#ra';
                document.body.innerHTML = 'VIDEO_INFO\"title\":\"' + video_url + '\",cr_video_url=' + video_url + '$';
                return;
            }

            //https://v.qq.com/x/page/f0909o8f3mv.html
            var vq = parseInt((window.external.vq && window.external.vq.match(/\d+/) ? window.external.vq : '1080').match(/\d+/)[0]);
            var vid = VIDEO_INFO.vid;
            var thumbnail = VIDEO_INFO.pic_640_360 || VIDEO_INFO.pic160x90;
            var video_url = '';
            var cookie = window.external.getCookie(window.location.href);
            var is_vip = cookie.indexOf('main_login') != -1;
            var np = document.getElementsByClassName('list_item current').length != 0 && document.getElementsByClassName('list_item current')[0].innerHTML.indexOf('单点付费') != -1;
            //VIDEO_INFO.drm: vip
            if (!is_vip && VIDEO_INFO.drm || np)
                video_url = getol(window.location.href);
            //求此支无水印可用源，最高亦为1080
            if (!video_url) {
                var defn = (vq >= 1080 || vq <= 8) ? 'fhd' : (vq == 720 ? 'shd' : 'hd');
                var api_url = 'https://vv.video.qq.com/getinfo?vid=' + vid + '&defn=' + defn + '&platform=10801&otype=ojson&dtype=3';
                var data = window.external.getHtmlCode(api_url, window.location.href);
                var jo = JSON.parse(data);
                if (jo.vl) {
                    video_url = jo.vl.vi[0].ul.ui[0].url;
                    if (jo.vl.vi[0].ul.ui[0].hls)
                        video_url += (jo.vl.vi[0].ul.ui[0].hls.pt != '') ? jo.vl.vi[0].ul.ui[0].hls.pt : jo.vl.vi[0].fn;
                    //此所取限速，判断时长区分，大于15分者，走annie
                    if (jo.preview && jo.preview >= 15 * 60 && video_url.indexOf('.m3u8') != -1)
                        video_url = '';
                }
            }
            //pc...可能求到的源，下载被禁止。有用户需要此支，保留
            if (!video_url) {
                var defn = (vq >= 1080 || vq <= 8) ? 'fhd' : 'shd';
                var dtype = 3;
                var kd = getkd(vid, '10201');
                var ks = kd.split(';');
                var lt = '';
                var args = '{\"buid\": \"onlyvinfo\", \"vinfoparam\": \"' +
                    'otype=ojson&flowid=' + ks[2] + '&platform=10201&appVer=3.5.57&tm=' + ks[0] + '&vid=' + vid + 
                    '&defn=' + defn + '&dtype=' + dtype + '&show1080p=1&isHLS=1&encryptVer=7.2&cKey=' + ks[1] + 
                    '&logintoken=' + lt + '\"}';
                var headers = 'Referer: https://v.qq.com/\r\nCookie: ' + cookie;
                var data = window.external.getPostResultEx('https://vd.l.qq.com/proxyhttp', args, headers);
                var jo = JSON.parse(data);
                if (jo.vinfo) {
                    jo = JSON.parse(jo.vinfo.replace(/\\\"/g, '\"'));
                    if (jo.vl) {
                        video_url = jo.vl.vi[0].ul.ui[0].url;
                        if (jo.vl.vi[0].ul.ui[0].hls)
                            video_url += (jo.vl.vi[0].ul.ui[0].hls.pt != '') ? jo.vl.vi[0].ul.ui[0].hls.pt : jo.vl.vi[0].fn;
                    }
                }
            }
            //不可判断其是否存在，比如.m3u8地址，其即可能返回不存在
            if (!video_url)
                video_url = window.location.href;

            document.body.innerHTML = 'thumbnail=' + thumbnail + ',cr_video_url=' + video_url + '$' + document.body.innerHTML;

            //...
            function getkd(vid, platform) {
                if (typeof(md5) == 'undefined')
                    md5 = window.external.md5;
                var t = Date.now().toString().substr(0, 10);
                var s = '4244ce1b' + vid + t + '*#06#10201';
                var ckey = md5(s);
                var flowid = md5(t) + '_' + platform;
                return t + ';' + ckey + ';' + flowid;
            }

            function getol(url) {
                var result = '';
                var os = (window.external.os != undefined) ? window.external.os : true;
                if (!os)
                    return result;

                var api_url = '';
                var data = '';
                var sites = ['https://jx.000180.top/180', 'https://api.927jx.com/wab', 'https://8090.winzoo.cn/jiexi', 'https://1717.ntryjd.net/0526', 'http://api.drgxj.com/jiexi', 'https://vip.bljiex.com'];
                var args = 'url=' + encodeURIComponent(url) + '&time=' + Date.now();
                for (var i = 0; i <= sites.length - 1; i++) {
                    api_url = sites[i] + '/api.php';
                    data = window.external.getPostResult(api_url, args, 'application/x-www-form-urlencoded; charset=UTF-8', api_url);
                    if (!data || data == 'null')
                        continue;
                    //bljiex
                    if (data.indexOf('(') != -1)
                        data = data.match(/\(([^\)]+)/)[1];
                    var jo = JSON.parse(data);
                    //此处做有效性判断
                    if (!jo.url || !window.external.urlExists(jo.url))
                        continue;

                    //m3u8...可能它没有title
                    if (jo.url.match(/php\?\w+=/) && typeof(window.external.saveData) != 'undefined') {
                        var m3u8 = window.external.getHtmlCode(jo.url);
                        if (m3u8 && m3u8.indexOf('#EXTM3U') != -1) {
                            if (m3u8.indexOf('url=') != -1) {
                                var f = function($1, $2) {
                                    return atob($2) + '\n';
                                }
                                m3u8 = m3u8.replace(/http.*?url=([^&]+).*?\s/g, f);
                            }
                            result = window.external.saveData(m3u8);
                            break;
                        }
                    }
                    if (jo.title && jo.title != '视频不存在' && jo.title != '解析系统' && jo.url.indexOf('http') != -1 &&
                        (jo.url.indexOf('m3u8') != -1 || jo.url.indexOf('.mp4') != -1)) {
                        result = jo.url;
                        break;
                    }
                }
                if (!result && typeof(CryptoJS) != 'undefined') {
                    api_url = 'https://dm.voooe.cn/m3u8.m3u8?url=' + url;
                    data = window.external.getHtmlCode(api_url);
                    if (data.indexOf('bt_token') != -1 && data.indexOf('\"url\"') != -1) {
                        var bt_token = data.match(/bt_token\s+=\s+\"([^\"]+)/)[1];
                        var url = data.match(/url\":\"([^\"]+)/)[1];
                        var token_key = CryptoJS.enc.Utf8.parse('dvyYRQlnPRCMdQSe');
                        var token_iv =  CryptoJS.enc.Utf8.parse(bt_token);
                        result = CryptoJS.AES.decrypt(url, token_key, {'iv': token_iv}).toString(CryptoJS.enc.Utf8);
                    }
                }
                if (!result) {
                    data = window.external.getHtmlCode('https://api.126c.cn/?url=' + encodeURIComponent(url), 'https://api.sigujx.com/');
                    if (data.indexOf('sigu_url') != -1) {
                        var su = data.match(/sigu_url\"\s+value=\"([^\"]+)/)[1];
                        args = 'url=' + su;
                        api_url = 'https://zl.126c.cn/zl_api.php';
                        data = window.external.getPostResult(api_url, args, 'application/x-www-form-urlencoded; charset=UTF-8', api_url);
                        if (data) {
                            var jo = JSON.parse(data);
                            if (jo.url)
                                result = jo.url;
                        }
                    }
                }
                if (!result) {
                    api_url = 'https://v.jhys.top/jhjiexi/jianghu.php?v=' + url;
                    data = window.external.getHtmlCode(api_url);
                    if (data.indexOf('\"url\"') != -1)
                        result = data.match(/url\":\s+\"([^\"]+)/)[1];
                }
                if (!result) {
                    api_url = 'https://yi29f.cn/vip01/api.php?url=' + encodeURIComponent(url);
                    data = window.external.getHtmlCode(api_url);
                    if (data && data != 'null') {
                        var jo = JSON.parse(data);
                        if (jo.url)
                            result = jo.url;
                    }
                }
                return result;
            }
        }
        catch (ex) {
            document.body.innerHTML = 'cr_video_url=' + window.location.href + '$' + document.body.innerHTML;
        }
    ]]></jsCode>
</parser>