<?xml version="1.0" encoding="utf-8"?>
<parser delay="4500" crpj="true" date="2020.10.11">
    <url><![CDATA[https?://(?:\w+\.)?taozhi\.\w+/.*?bookId=\d+&bookMenuId=(?<id>\d+)]]></url>
    <title><![CDATA[<title>([^<]+)</title>]]></title>
    <thumbnail><![CDATA[background-image:\s+url\("([^"]+)"]]></thumbnail>
    <duration><![CDATA[]]></duration>
    <mediaUrl><![CDATA[cr_video_url=([^\$]+)]]></mediaUrl>
    <headers><![CDATA[User-Agent: Mozilla/5.0 (iPad; CPU OS 12_0 like Mac OS X) AppleWebKit/604.1.34 (KHTML, like Gecko) Version/12.0 Mobile/15A5341f Safari/604.1]]></headers>
    <jsCode><![CDATA[
        try {
            //https://www.taozhi.cn/phone_vke/10303.htm?bookId=5107&bookMenuId=191920
            if (document.getElementsByClassName('prism-big-play-btn').length != 0)
                document.getElementsByClassName('prism-big-play-btn')[0].click();

            var auth_url = '';
            var api_url = '';
            var video_url = '';
            var entries = window.performance.getEntriesByType('resource');
            for (let i = 0; i <= entries.length - 1; i++) {
                var en = entries[i].name;
                if (en.indexOf('getVideoPlayAuth?videoId=') != -1)
                    auth_url = en;
                else if (en.indexOf('vod.cn-shanghai.aliyuncs.com') != -1) {
                    api_url = en;
                    break;
                }
            }
            if (auth_url && api_url) {
                var guid = function() {
                    for (var e = [], t = '0123456789abcdef', i = 0; i < 36; i++)
                        e[i] = t.substr(Math.floor(16 * Math.random()), 1);
                    return e[14] = '4',
                    e[19] = t.substr(3 & e[19] | 8, 1),
                    e[8] = e[13] = e[18] = e[23] = '-',
                    e.join('')
                };

                var eu = function(e) {
                    var t = encodeURIComponent(e);
                    return t = (t = (t = t.replace('+', '%2B')).replace('*', '%2A')).replace('%7E', '~');
                };

                api_url = api_url.replace(/SignatureNonce=[^&]+/, 'SignatureNonce=' + guid());
                var data = window.external.getHtmlCode(auth_url,window.location.href);
                var jo = JSON.parse(data);
                jo = JSON.parse(atob(jo.data.playAuth));
                var k = jo.AccessKeySecret + '&';
                var a = api_url.match(/AccessKeyId=.*?VideoId=[^&]+/)[0];
                var p = 'GET&%2F&' + eu(a);
                var host = api_url.match(/https.*\?/);
                api_url = host + a + '&Signature=' + eu(window.external.hmacSha1(p, k));
                data = window.external.getHtmlCode(api_url, window.location.href);
                var jo = JSON.parse(data);
                video_url = jo.PlayInfoList.PlayInfo[0].PlayURL;
            }

            document.body.innerHTML = 'cr_video_url=' + video_url + '$' + document.body.innerHTML;
        }
        catch (ex) {
        }
    ]]></jsCode>
</parser>