<?xml version="1.0" encoding="utf-8"?>
<parser delay="500" crpj="true" date="2020.09.24">
    <url><![CDATA[https?://(?:h5\.)?pipix\.com/(?:\w|item)/(?<id>[^/?]+)]]></url>
    <title><![CDATA[<title>([^<]+)</title>]]></title>
    <thumbnail><![CDATA[<video[^>]+\bposter="([^"]+)"]]></thumbnail>
    <duration><![CDATA[duration=([^,]+)]]></duration>
    <mediaUrl><![CDATA[cr_video_url=([^\$]+)]]></mediaUrl>
    <jsCode><![CDATA[
        try {
            //https://h5.pipix.com/s/JAowfJn/
            //https://h5.pipix.com/s/JAEA9bS/
            //https://aweme.snssdk.com/aweme/v1/play/?video_id=...
            //https://h5.pipix.com/item/6829134825899694343
            //https://h5.pipix.com/item/6875952343070808320?app_id=1319&app=super&timestamp=1600953531&carrier_region=cn&region=cn&language=zh&utm_source=weixin
            var href = window.location.href;
            var id = href.match(/item\/([^?&]+)/)[1];
            var aid = href.match(/app_id=([^&]+)/) ? href.match(/app_id=([^&]+)/)[1] : '1319';
            var app = href.match(/app=([^&]+)/) ? href.match(/app=([^&]+)/)[1] : 'super';
            var api_url = 'https://i.snssdk.com/bds/item/detail/?item_id=' + id + '&aid=' + aid + '&app_name=' + app;
            var data = window.external.getHtmlCode(api_url);
            if (!data) {
                api_url = 'https://h5.pipix.com/bds/webapi/item/detail/?item_id=' + id + '&aid=' + aid + '&app_name=' + app;
                data = window.external.getHtmlCode(api_url);
            }
            var jo = JSON.parse(data);
            var item = jo.data.data || jo.data.item;
            var video = item.origin_video_download || item.video;
            var duration = video.duration;
            var video_url = video.url_list ? video.url_list[0].url : video.video_download.url_list[0].url

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