<?xml version="1.0" encoding="utf-8"?>
<parser delay="2500" crpj="true" date="2021.01.16">
    <url><![CDATA[https?://(?:live\.)?kuaishou\.com/playback/(?<id>[^?]+)]]></url>
    <title><![CDATA[title="([^"]+)"]]></title>
    <thumbnail><![CDATA[thumbnail=([^,]+)]]></thumbnail>
    <duration><![CDATA[duration=([^,]+)]]></duration>
    <mediaUrl><![CDATA[cr_video_url=([^\$]+)]]></mediaUrl>
    <jsCode><![CDATA[
        try {
            //https://live.kuaishou.com/playback/3xvyqkg68hixziq
            var href = window.external.url || window.location.href;
            var video_url = '', thumbnail = '', duration = 0;
            var title = (document.getElementsByClassName('h2').length != 0) ? document.getElementsByClassName('h2')[0].innerText : document.title;
            var html = window.external.getHtmlCode(href);
            if (html.indexOf('__APOLLO_STATE__') != -1) {
                var text = html.match(/\{\"baseUrl.*?PlaybackProduct\"\}/)[0];
                var jo = JSON.parse(text);
                title = jo.caption || title;
                video_url = jo.m3u8Url || href;
                thumbnail = jo.coverUrl;
                duration = jo.duration;
            }
            document.head.innerHTML = '';
            document.body.innerHTML = 'title=\"' + title + '\",thumbnail=' + thumbnail + ',duration=' + duration + ',cr_video_url=' + video_url + '$';
        }
        catch (ex) {
        }
    ]]></jsCode>
</parser>