<?xml version="1.0" encoding="utf-8"?>
<parser delay="4500" crpj="true" date="2020.09.11">
    <url><![CDATA[https?://(?:\w+\.)?163\.com/(?:[^/]+/)?movie/(?:.*/(?<id>[^.]+)\.html?|free\?pid=(?<id>[^&]+))]]></url>
    <title><![CDATA[<div\s+title="([^"]+)"]]></title>
    <thumbnail><![CDATA[<img\s+src="([^"]+)"]]></thumbnail>
    <duration><![CDATA[<div\s+class="course-time[^<]+>([^<]+)</div>]]></duration>
    <subtitle><![CDATA[subtitle=([^\$]+)]]></subtitle>
    <mediaUrl><![CDATA[<video[^>]+\bsrc="([^"]+?)"]]></mediaUrl>
    <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>
    <jsCode><![CDATA[
        try {
            var title = document.getElementsByClassName('t-container__title').length != 0 ? document.getElementsByClassName('t-container__title')[0].innerText : document.title;
            var subtitle = '';
            var entries = window.performance.getEntriesByType('resource');
            for (let i = 0; i <= entries.length - 1; i++) {
                var e = entries[i];
                if (e.name.toLowerCase().indexOf('.vtt') != -1 || e.name.toLowerCase().indexOf('.srt') != -1)
                    subtitle = (subtitle == '') ? e.name : subtitle + '#' + e.name;
            }

            if (!subtitle && document.body.innerHTML.indexOf(',title:') != -1) {
                var data = document.body.innerHTML.match(/\{mid:\"\w{9}\",plid:\w,title:\w.*?description:.*?\}/)[0];
                data = unescape(data.replace(/\\/g, '%'));
                subtitle = data.match(/subUrl:/) ? data.match(/subUrl:\"([^\"]+)\"/)[1] : data.match(/subVttUrl:\"([^\"]+)\"/)[1];
            }

            var emts = document.getElementsByClassName('course-content');
            for (let i = 0; i <= emts.length -1; i++) {
                var emt = emts[i];
                if (emt.lastElementChild.firstElementChild.innerText == title) {
                    document.body.innerHTML = emt.innerHTML + document.body.innerHTML;
                    break;
                }
            }

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