/*
@header({
  searchable: 0,
  filterable: 0,
  quickSearch: 0,
  title: '播客[听]',
  '类型': '听书',
  lang: 'ds'
})
*/

var rule = {
    类型: '听书',
    title: '播客[听]',
    host: 'https://getpodcast.xyz',
    url: '/fyclass',
    searchUrl: '',
    searchable: 0,
    quickSearch: 0,
    headers: {
        'User-Agent': 'PC_UA'
    },
    timeout: 5000,
    class_name: '播客&人文&NEWS热点&影视与读书&教育&历史&音乐&情感&有声书',
    class_url: '0&1&2&3&4&5&6&7&8',
    cate_exclude: '',
    play_parse: true,
    lazy: async function () {
        let {input} = this;
        return {jx: 0, url: input, parse: 0}
    },
    limit: 6,
    推荐: async function () {
        let {input, HOST, pdfh, pd, pdfa} = this;
        let d = [];
        let html = await request(HOST);
        let list = pdfa(html, 'body&&.pic_list:eq(0)&&li');
        list.forEach(it => {
            d.push({
                title: pdfh(it, '.title&&Text'),
                pic_url: pdfh(it, 'img&&src'),
                url: pd(it, 'a&&href') + '|' + pdfh(it, '.title&&Text') + '|' + pdfh(it, 'img&&src')
            });
        })
        return setResult(d);
    },
    一级: async function () {
        let {input, HOST, MY_CATE, pdfh, pd, pdfa} = this;
        let d = [];
        let html = await request(HOST);
        let list = pdfa(html, 'body&&.pic_list:eq(list_idx)&&li'.replace("list_idx", MY_CATE));
        list.forEach(it => {
            d.push({
                title: pdfh(it, '.title&&Text'),
                pic_url: pdfh(it, 'img&&src'),
                url: pd(it, 'a&&href') + '|' + pdfh(it, '.title&&Text') + '|' + pdfh(it, 'img&&src')
            });
        })
        return setResult(d);
    },
    二级: async function () {
        let {input, pdfh, pdfa} = this;
        let purl = input.split('|')[0];
        let title = input.split('|')[1];
        let pic = input.split('|')[2];
        let html = await request(purl);
        let VOD = {};
        VOD.vod_name = title;
        VOD.vod_pic = pic;
        if (typeof play_url === 'undefined') {
            var play_url = ''
        }
        let episodes = pdfa(html, 'body&&item');
        // log('episodes =========>' + episodes);
        let vod_play_url = episodes.map(function (it) {
            let ititle = it.match(/<title>(.*?)<\/title>/)[1].replace(/&lt;!\[CDATA\[|\]\]&gt;||<!\[CDATA\[|\]\]>/g, '');
            let iurl = pdfh(it, 'enclosure&&url');
            return ititle + '$' + iurl
        }).join('#')
        VOD.vod_play_from = '道长在线';
        VOD.vod_play_url = vod_play_url
        return VOD
    },
    搜索: '',
}