优酷二级.js 3.0 KB
Newer Older
H
hjdhnx 已提交
1 2
js:
var d = [];
H
hjdhnx 已提交
3 4
// VOD={vod_id:input};
VOD={};
H
hjdhnx 已提交
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21
let html=request(input);
// print(html);
let json = JSON.parse(html);
if (/keyword/.test(input)) {
    input = 'https://search.youku.com/api/search?appScene=show_episode&showIds=' + json.pageComponentList[0].commonData.showId;
    json = JSON.parse(fetch(MY_URL, fetch_params));
}
let video_lists = json.serisesList;
var name = json.sourceName;
if(/优酷/.test(name)&&video_lists.length>0){//获取简介详情
    let ourl = 'https://v.youku.com/v_show/id_' + video_lists[0].videoId + '.html';
    let _img = video_lists[0].thumbUrl;
    // log(ourl);
    let html = fetch(ourl,{headers:{'Referer':'https://v.youku.com/','User-Agent':PC_UA}});
    let json = /__INITIAL_DATA__/.test(html)?html.split('window.__INITIAL_DATA__ =')[1].split(';')[0]:'{}';
    if(json==='{}'){
        log('触发了优酷人机验证');
22 23 24 25
        VOD.vod_remarks = ourl;
        VOD.vod_pic = _img;
        VOD.vod_name = video_lists[0].title.replace(/(\d+)/g,'');
        VOD.vod_content = '触发了优酷人机验证,本次未获取详情,但不影响播放('+ourl+')';
H
hjdhnx 已提交
26 27 28 29 30 31 32 33 34 35 36 37 38 39
    }else{
        try {
            json = JSON.parse(json);
            let data = json.data.data;
            let data_extra = data.data.extra;
            let img = data_extra.showImgV;
            let model = json.data.model;
            let m =  model.detail.data.nodes[0].nodes[0].nodes[0].data;
            let _type = m.showGenre
            let _desc = m.updateInfo||m.subtitle;
            let JJ=m.desc;
            let _title = m.introTitle;
            // subtitle  desc   showImgV 是竖着的  showImg横着的
            // let uptips = pdfh(html,'.title-info&&Text');
40 41 42 43 44
            VOD.vod_pic = img;
            VOD.vod_name = _title;
            VOD.vod_type = _type;
            VOD.vod_remarks = _desc;
            VOD.vod_content = JJ;
H
hjdhnx 已提交
45 46
        }catch (e) {
            log('海报渲染发生错误:'+e.message);
47 48
            print(json);
            VOD.vod_remarks = name;
H
hjdhnx 已提交
49 50 51 52 53
        }
    }
}

if(!/优酷/.test(name)){
54 55
    VOD.vod_content = '非自家播放源,暂无视频简介及海报';
    VOD.vod_remarks = name;
H
hjdhnx 已提交
56 57 58 59 60 61 62 63
}
function adhead(url){
    // let hd = 'https://v.sogou.com';
    // if(!url.startsWith(hd)){
    //     url = hd+url
    // }
    return urlencode(url)
}
H
hjdhnx 已提交
64 65 66
// if(typeof(play_url)==='undefined'){
//     var play_url = '';
// }
H
hjdhnx 已提交
67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83
play_url = play_url.replace('&play_url=','&type=json&play_url=');
video_lists.forEach(function (it){
    let url = 'https://v.youku.com/v_show/id_' + it.videoId + '.html';
    if (it.thumbUrl) {
        d.push({
            desc: it.showVideoStage ? it.showVideoStage.replace('', '') : it.displayName,
            pic_url: it.thumbUrl,
            title: it.title,
            url: play_url+adhead(url),
        });
    }else if (name!=='优酷'){
        d.push({
            title: (it.displayName?it.displayName:it.title),
            url: play_url+adhead(it.url),
        });
    }
});
84 85
VOD.vod_play_from = name;
VOD.vod_play_url = d.map(function (it){
H
hjdhnx 已提交
86 87
    return it.title + '$' + it.url;
}).join('#');