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

H
hjdhnx 已提交
7 8 9 10 11
function adhead(url){
    let hd = 'https://v.sogou.com';
    if(!url.startsWith(hd)){
        url = hd+url
    }
H
hjdhnx 已提交
12
    return urlencode(url)
H
hjdhnx 已提交
13
}
H
hjdhnx 已提交
14
try {
15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
    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 已提交
32
    if (shows) {
33 34 35 36 37 38 39
        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 已提交
40
    } else {
41 42 43 44 45 46 47
        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 已提交
48
    }
H
hjdhnx 已提交
49
    let tp = '&type=json';
H
hjdhnx 已提交
50
    try {
51 52 53 54
        let tabs = [];
        let lists = [];
        plays.forEach(function (it){
            lists.push(it.info);
H
优化  
hjdhnx 已提交
55 56 57
            let tbn = it.sitename[0]||it.site.replace('.com','');
            tbn = tbn.split('').join(' '); // 加空格防止被软件拦截
            tabs.push(tbn);
58
        });
59 60
        VOD.vod_play_from = tabs.join('$$$');
        // print(VOD);
61 62
        // print(lists);
        // print(shows);
H
hjdhnx 已提交
63
        let vod_lists = []; // 拿$$$去填
H
hjdhnx 已提交
64 65 66
        // if(typeof(play_url)==='undefined'){
        //     var play_url = '';
        // }
H
hjdhnx 已提交
67
        play_url = play_url.replace('&play_url=','&type=json&play_url=');
68 69 70
        lists.forEach(function (item,idex){ // item是个json列表
            if (item || shows) { // 动漫,电视剧
                if(item && Array.isArray(item)&&item.length>1){
H
hjdhnx 已提交
71
                    // let tmp = item.slice(1).map(function (its){return its.index+'$'+play_url+'https://v.sogou.com'+its.url});
H
hjdhnx 已提交
72
                    let tmp = item.slice(1).map(function (its){return its.index+'$'+play_url+base64Encode(adhead(its.url))});
73
                    vod_lists.push(tmp.join('#'));
H
hjdhnx 已提交
74
                }
75 76 77 78 79 80 81 82 83
                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 已提交
84 85
                            arr.push(Tdate);
                        }
86
                    });
H
hjdhnx 已提交
87

88 89
                    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 已提交
90
                        tmp.push("" + arr[k] + ""+'$'+play_url+base64Encode(adhead(url)));
H
hjdhnx 已提交
91
                    }
92
                    vod_lists.push(tmp.join('#'));
H
hjdhnx 已提交
93
                }
94 95 96 97
            } else if (plays[idex].site) {//电影
                // print(plays[idex].site);
                let tmp = [];
                if (!plays[idex].flag_list.includes('trailer')) {
H
hjdhnx 已提交
98
                    tmp.push(plays[idex].sitename[0]+'$'+play_url+base64Encode(adhead(plays[idex].url)));
99
                } else {
H
hjdhnx 已提交
100
                    tmp.push(plays[idex].sitename[0] + '—预告'+'$'+play_url+base64Encode(adhead(plays[idex].url)));
H
hjdhnx 已提交
101
                }
102
                vod_lists.push(tmp.join('#'));
H
hjdhnx 已提交
103 104
            }
        });
105
        // print(vod_lists);
106
        VOD.vod_play_url = vod_lists.join('$$$');
107 108
    } catch(e) {
        let img = json.photo.item_list;
109 110
        VOD.vod_name = '本片无选集';
        VOD.vod_pic = img.length>0?img[0]:'';
H
hjdhnx 已提交
111
    }
H
hjdhnx 已提交
112 113 114
} catch(e) {
    print('发生了错误:'+e.message);
}