<?xml version="1.0" encoding="utf-8"?>
<parser delay="1500" crpj="true" date="2021.02.05">
    <url><![CDATA[https?://(?:\w+\.)?(?:cctv\.com|docuchina\.cn)/.*?/(?<id>VIDE[^.]+)\.s?html?]]></url>
    <title><![CDATA[title="([^"]+)"]]></title>
    <thumbnail><![CDATA[thumbnail=([^,]+)]]></thumbnail>
    <duration><![CDATA[]]></duration>
    <mediaUrl><![CDATA[cr_video_url=([^\$]+)]]></mediaUrl>
    <jsCode><![CDATA[
        try {
            //https://tv.cctv.com/2021/01/15/VIDE9wBaPD0WracfCxc6ORcM210115.shtml
            //http://www.docuchina.cn/2020/06/14/VIDE6on8uNzpCR6uNZOP0qOh200614.shtml
            var href = window.external.url || window.location.href;
            var vq = parseInt((window.external.vq && window.external.vq.match(/\d+/) ? window.external.vq : '1080').match(/\d+/)[0]);
            var video_url = href;
            var thumbnail = window.flvImgUrl || window.commentimg || '';
            var title = document.title.substr(0, document.title.indexOf('_'));
            var api_url = 'https://vdn.apps.cntv.cn/api/getHttpVideoInfo.do?pid=' + window.guid;
            var data = window.external.getHtmlCode(api_url);
            if (data.indexOf('hls_url') != -1) {
                //以正则取hls_url，避免JSON.parse(data)出错
                var hls_url = data.match(/hls_url\":\"([^\"]+)/)[1];
                data = window.external.getHtmlCode(hls_url);
                video_url = data.substr(data.lastIndexOf('/asp'));
                var re = new RegExp('x' + vq + '([^.]+\.m3u8)');
                var m = data.match(re);
                video_url = m ? m[1].trim() : video_url;
                video_url = hls_url.substr(0, hls_url.indexOf('/asp')) + video_url;
            }
            document.body.innerHTML = 'title=\"' + title + '\",thumbnail=' + thumbnail + ',cr_video_url=' + video_url + '$';
        }
        catch (ex) {
        }
    ]]></jsCode>
</parser>