<?xml version="1.0" encoding="utf-8"?>
<parser delay="1500" crpj="true" date="2021.03.24">
    <url><![CDATA[https?://(?:www\.)?ddrk\.me/(?<id>[^/]+)]]></url>
    <title><![CDATA[title="([^"]+)"]]></title>
    <thumbnail><![CDATA[thumbnail=([^,]+)]]></thumbnail>
    <duration><![CDATA[]]></duration>
    <mediaUrl><![CDATA[cr_video_url=([^\$]+)]]></mediaUrl>
    <jsCode><![CDATA[
        try {
            //https://ddrk.me/legend-of-deification/
            var title = document.getElementsByTagName('h1').length != 0 ? document.getElementsByTagName('h1')[0].innerText : document.title;
            var thumbnail = document.body.innerHTML.match(/post.*?src=\"([^\"]+)/) ? document.body.innerHTML.match(/post.*?src=\"([^\"]+)/)[1] : '';
            var video_url = window.location.href;
            function getServerDate(){
                var xhr = window.XMLHttpRequest ? new window.XMLHttpRequest() : new ActiveObject('Microsoft'); 
                xhr.open('GET','/',false)
                xhr.send(null);
                var date = xhr.getResponseHeader('Date');
                return new Date(date);
            }

            function getVid(src) {
                var srvdate = getServerDate();
                var eTimes = srvdate.getTime() + 600000;
                var uTxt = CryptoJS.enc.Utf8.parse('{\"path\":\"' + src + '\",\"expire\":' + eTimes.toString() + '}');
                var uKey = CryptoJS.enc.Utf8.parse('zevS%th@*8YWUm%K');
                var waiv = CryptoJS.enc.Utf8.parse('5080305495198718');
                var ttestvtrack = CryptoJS.AES.encrypt(uTxt,uKey,{
                    iv: waiv,
                    mode: CryptoJS.mode.CBC
                });
                return encodeURIComponent(ttestvtrack.ciphertext.toString(CryptoJS.enc.Base64));
            }

            var data = document.getElementsByClassName('wp-playlist-script')[0].innerText;
            var jo = JSON.parse(data);
            var src = jo.tracks[0].src0;
            var api_url = 'https://v.ddrk.me:9543/video?id=' + getVid(src) + '&type=mix';
            data = window.external.getHtmlCode(api_url, window.location.href);
            if (data) {
                jo = JSON.parse(data);
                if (jo.pin) {
                    data = pako.ungzip(jo.pin,{to:'string'});
                    video_url = window.external.saveData(data);
                }
            }
            document.head.innerHTML = '';
            document.body.innerHTML = 'title=\"' + title + '\",thumbnail=' + thumbnail + ',cr_video_url=' + video_url + '$';
        }
        catch (ex) {
        }
    ]]></jsCode>
</parser>