搜狗二级.js 4.1 KB
Newer Older
1 2 3 4
js:
// let d = [];
var vod = {vod_id:input};
let html = request(input);
H
hjdhnx 已提交
5 6

try {
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
    let json = JSON.parse(html.match(/INITIAL_STATE.*?({.*});/)[1]).detail.itemData;
    let key = json.dockey;
    let name = json.name;
    let zone = json.zone;
    let score = json.score ? json.score: '暂无';
    let style = json.style;
    let emcee = json.emcee ? '主持:' + json.emcee: json.name;
    let director = json.director ? '导演:' + json.director: name;
    director = director.replace(/;/g, '\t');
    let starring = json.starring ? '演员:' + json.starring: '声优:' + json.shengyou;
    starring = starring.replace(/.*undefined/, '').replace(/;/g, '\t')
    let update = json.update_wordstr ? json.update_wordstr: '';
    let tv_station = json.tv_station ? json.tv_station: zone;
    let introduction = json.introduction;
    let shengyou = json.shengyou;
    let shows = json.play_from_open_index;
    let plays = json.play.item_list;
H
hjdhnx 已提交
24
    if (shows) {
25 26 27 28 29 30 31
        vod.vod_name = name;
        vod.vod_area = emcee + ',' + tv_station;
        vod.vod_director = director;
        vod.vod_actor = starring;
        vod.vod_pic = jsp.pd(html, '#thumb_img&&img&&src');
        vod.vod_remarks = style + ' 评分:' + score + ',' + update;
        vod.vod_content = introduction;
H
hjdhnx 已提交
32
    } else {
33 34 35 36 37 38 39
        vod.vod_name = name;
        // vod.vod_area = '';
        vod.vod_director = director;
        vod.vod_actor = starring;
        vod.vod_pic = jsp.pd(html, '#thumb_img&&img&&src');
        // vod.vod_remarks = style + ' 评分:' + score + ',' + update;
        vod.vod_content = introduction;
H
hjdhnx 已提交
40 41
    }
    try {
42 43 44 45
        let tabs = [];
        let lists = [];
        plays.forEach(function (it){
            lists.push(it.info);
H
优化  
hjdhnx 已提交
46 47 48
            let tbn = it.sitename[0]||it.site.replace('.com','');
            tbn = tbn.split('').join(' '); // 加空格防止被软件拦截
            tabs.push(tbn);
49 50 51 52 53 54 55 56 57
        });
        vod.vod_play_from = tabs.join('$$$');
        // print(vod);
        // print(lists);
        // print(shows);
        vod_lists = []; // 拿$$$去填
        lists.forEach(function (item,idex){ // item是个json列表
            if (item || shows) { // 动漫,电视剧
                if(item && Array.isArray(item)&&item.length>1){
H
优化  
hjdhnx 已提交
58
                    let tmp = item.slice(1).map(function (its){return its.index+'$'+play_url+'https://v.sogou.com'+its.url});
59
                    vod_lists.push(tmp.join('#'));
H
hjdhnx 已提交
60
                }
61 62 63 64 65 66 67 68 69
                if (shows) { //综艺,纪录片
                    let arr = [];
                    let tmp = [];
                    let zy = shows.item_list[idex];
                    zy.date.forEach(function (date){
                        let day = date.day;
                        for (let j=0;j<day.length;j++) {
                            let dayy = day[j][0] >= 10 ? day[j][0] : "0" + day[j][0];
                            let Tdate = date.year + date.month + dayy;
H
hjdhnx 已提交
70 71
                            arr.push(Tdate);
                        }
72
                    });
H
hjdhnx 已提交
73

74 75
                    for (let k = 0; k < arr.length; k++) {
                        let url = "https://v.sogou.com/vc/eplay?query=" + arr[k] + "&date=" + arr[k] + "&key=" + key + "&st=5&tvsite=" + plays[idex].site;
H
优化  
hjdhnx 已提交
76
                        tmp.push("" + arr[k] + ""+'$'+play_url+'https://v.sogou.com'+url);
H
hjdhnx 已提交
77
                    }
78
                    vod_lists.push(tmp.join('#'));
H
hjdhnx 已提交
79
                }
80 81 82 83
            } else if (plays[idex].site) {//电影
                // print(plays[idex].site);
                let tmp = [];
                if (!plays[idex].flag_list.includes('trailer')) {
H
优化  
hjdhnx 已提交
84
                    tmp.push(plays[idex].sitename[0]+'$'+play_url+'https://v.sogou.com' + plays[idex].url);
85
                } else {
H
优化  
hjdhnx 已提交
86
                    tmp.push(plays[idex].sitename[0] + '—预告'+'$'+play_url+"https://v.sogou.com" + plays[idex].url);
H
hjdhnx 已提交
87
                }
88
                vod_lists.push(tmp.join('#'));
H
hjdhnx 已提交
89 90
            }
        });
91 92 93 94 95 96
        // print(vod_lists);
        vod.vod_play_url = vod_lists.join('$$$');
    } catch(e) {
        let img = json.photo.item_list;
        vod.vod_name = '本片无选集';
        vod.vod_pic = img.length>0?img[0]:'';
H
hjdhnx 已提交
97
    }
98
} catch(e) {}