优酷二级.js 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. js:
  2. var d = [];
  3. // VOD={vod_id:input};
  4. VOD={};
  5. let html=request(input);
  6. // print(html);
  7. let json = JSON.parse(html);
  8. if (/keyword/.test(input)) {
  9. input = 'https://search.youku.com/api/search?appScene=show_episode&showIds=' + json.pageComponentList[0].commonData.showId;
  10. json = JSON.parse(fetch(MY_URL, fetch_params));
  11. }
  12. let video_lists = json.serisesList;
  13. var name = json.sourceName;
  14. if(/优酷/.test(name)&&video_lists.length>0){//获取简介详情
  15. let ourl = 'https://v.youku.com/v_show/id_' + video_lists[0].videoId + '.html';
  16. let _img = video_lists[0].thumbUrl;
  17. // log(ourl);
  18. let html = fetch(ourl,{headers:{'Referer':'https://v.youku.com/','User-Agent':PC_UA}});
  19. let json = /__INITIAL_DATA__/.test(html)?html.split('window.__INITIAL_DATA__ =')[1].split(';')[0]:'{}';
  20. if(json==='{}'){
  21. log('触发了优酷人机验证');
  22. VOD.vod_remarks = ourl;
  23. VOD.vod_pic = _img;
  24. VOD.vod_name = video_lists[0].title.replace(/(\d+)/g,'');
  25. VOD.vod_content = '触发了优酷人机验证,本次未获取详情,但不影响播放('+ourl+')';
  26. }else{
  27. try {
  28. json = JSON.parse(json);
  29. let data = json.data.data;
  30. let data_extra = data.data.extra;
  31. let img = data_extra.showImgV;
  32. let model = json.data.model;
  33. let m = model.detail.data.nodes[0].nodes[0].nodes[0].data;
  34. let _type = m.showGenre
  35. let _desc = m.updateInfo||m.subtitle;
  36. let JJ=m.desc;
  37. let _title = m.introTitle;
  38. // subtitle desc showImgV 是竖着的 showImg横着的
  39. // let uptips = pdfh(html,'.title-info&&Text');
  40. VOD.vod_pic = img;
  41. VOD.vod_name = _title;
  42. VOD.vod_type = _type;
  43. VOD.vod_remarks = _desc;
  44. VOD.vod_content = JJ;
  45. }catch (e) {
  46. log('海报渲染发生错误:'+e.message);
  47. print(json);
  48. VOD.vod_remarks = name;
  49. VOD.vod_id = input;
  50. }
  51. }
  52. }
  53. if(!/优酷/.test(name)){
  54. VOD.vod_content = '非自家播放源,暂无视频简介及海报';
  55. VOD.vod_remarks = name;
  56. }
  57. function adhead(url){
  58. // let hd = 'https://v.sogou.com';
  59. // if(!url.startsWith(hd)){
  60. // url = hd+url
  61. // }
  62. return urlencode(url)
  63. }
  64. // if(typeof(play_url)==='undefined'){
  65. // var play_url = '';
  66. // }
  67. play_url = play_url.replace('&play_url=','&type=json&play_url=');
  68. video_lists.forEach(function (it){
  69. let url = 'https://v.youku.com/v_show/id_' + it.videoId + '.html';
  70. if (it.thumbUrl) {
  71. d.push({
  72. desc: it.showVideoStage ? it.showVideoStage.replace('期', '集') : it.displayName,
  73. pic_url: it.thumbUrl,
  74. title: it.title,
  75. url: play_url+adhead(url),
  76. });
  77. }else if (name!=='优酷'){
  78. d.push({
  79. title: (it.displayName?it.displayName:it.title),
  80. url: play_url+adhead(it.url),
  81. });
  82. }
  83. });
  84. VOD.vod_play_from = name;
  85. VOD.vod_play_url = d.map(function (it){
  86. return it.title + '$' + it.url;
  87. }).join('#');