搜狗二级.js 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116
  1. js:
  2. // let d = [];
  3. // VOD = {vod_id:input};
  4. VOD = {};
  5. let html = request(input);
  6. function adhead(url){
  7. let hd = 'https://v.sogou.com';
  8. if(!url.startsWith(hd)){
  9. url = hd+url
  10. }
  11. return urlencode(url)
  12. }
  13. try {
  14. let json = JSON.parse(html.match(/INITIAL_STATE.*?({.*});/)[1]).detail.itemData;
  15. let key = json.dockey;
  16. let name = json.name;
  17. let zone = json.zone;
  18. let score = json.score ? json.score: '暂无';
  19. let style = json.style;
  20. let emcee = json.emcee ? '主持:' + json.emcee: json.name;
  21. let director = json.director ? '导演:' + json.director: name;
  22. director = director.replace(/;/g, '\t');
  23. let starring = json.starring ? '演员:' + json.starring: '声优:' + json.shengyou;
  24. starring = starring.replace(/.*undefined/, '').replace(/;/g, '\t')
  25. let update = json.update_wordstr ? json.update_wordstr: '';
  26. let tv_station = json.tv_station ? json.tv_station: zone;
  27. let introduction = json.introduction;
  28. let shengyou = json.shengyou;
  29. let shows = json.play_from_open_index;
  30. let plays = json.play.item_list;
  31. if (shows) {
  32. VOD.vod_name = name;
  33. VOD.vod_area = emcee + ',' + tv_station;
  34. VOD.vod_director = director;
  35. VOD.vod_actor = starring;
  36. VOD.vod_pic = jsp.pd(html, '#thumb_img&&img&&src');
  37. VOD.vod_remarks = style + ' 评分:' + score + ',' + update;
  38. VOD.vod_content = introduction;
  39. } else {
  40. VOD.vod_name = name;
  41. // VOD.vod_area = '';
  42. VOD.vod_director = director;
  43. VOD.vod_actor = starring;
  44. VOD.vod_pic = jsp.pd(html, '#thumb_img&&img&&src');
  45. // VOD.vod_remarks = style + ' 评分:' + score + ',' + update;
  46. VOD.vod_content = introduction;
  47. }
  48. let tp = '&type=json';
  49. try {
  50. let tabs = [];
  51. let lists = [];
  52. plays.forEach(function (it){
  53. lists.push(it.info);
  54. let tbn = it.sitename[0]||it.site.replace('.com','');
  55. tbn = tbn.split('').join(' '); // 加空格防止被软件拦截
  56. tabs.push(tbn);
  57. });
  58. VOD.vod_play_from = tabs.join('$$$');
  59. // print(VOD);
  60. // print(lists);
  61. // print(shows);
  62. let vod_lists = []; // 拿$$$去填
  63. // if(typeof(play_url)==='undefined'){
  64. // var play_url = '';
  65. // }
  66. print('play_url1:'+play_url);
  67. play_url = play_url.replace('&play_url=','&type=json&play_url=');
  68. print('play_url2:'+play_url);
  69. lists.forEach(function (item,idex){ // item是个json列表
  70. if (item || shows) { // 动漫,电视剧
  71. if(item && Array.isArray(item)&&item.length>1){
  72. // let tmp = item.slice(1).map(function (its){return its.index+'$'+play_url+'https://v.sogou.com'+its.url});
  73. let tmp = item.slice(1).map(function (its){return its.index+'$'+play_url+base64Encode(adhead(its.url))});
  74. vod_lists.push(tmp.join('#'));
  75. }
  76. if (shows) { //综艺,纪录片
  77. let arr = [];
  78. let tmp = [];
  79. let zy = shows.item_list[idex];
  80. zy.date.forEach(function (date){
  81. let day = date.day;
  82. for (let j=0;j<day.length;j++) {
  83. let dayy = day[j][0] >= 10 ? day[j][0] : "0" + day[j][0];
  84. let Tdate = date.year + date.month + dayy;
  85. arr.push(Tdate);
  86. }
  87. });
  88. for (let k = 0; k < arr.length; k++) {
  89. let url = "https://v.sogou.com/vc/eplay?query=" + arr[k] + "&date=" + arr[k] + "&key=" + key + "&st=5&tvsite=" + plays[idex].site;
  90. tmp.push("第" + arr[k] + "期"+'$'+play_url+base64Encode(adhead(url)));
  91. }
  92. vod_lists.push(tmp.join('#'));
  93. }
  94. } else if (plays[idex].site) {//电影
  95. // print(plays[idex].site);
  96. let tmp = [];
  97. if (!plays[idex].flag_list.includes('trailer')) {
  98. tmp.push(plays[idex].sitename[0]+'$'+play_url+base64Encode(adhead(plays[idex].url)));
  99. } else {
  100. tmp.push(plays[idex].sitename[0] + '—预告'+'$'+play_url+base64Encode(adhead(plays[idex].url)));
  101. }
  102. vod_lists.push(tmp.join('#'));
  103. }
  104. });
  105. // print(vod_lists);
  106. VOD.vod_play_url = vod_lists.join('$$$');
  107. } catch(e) {
  108. let img = json.photo.item_list;
  109. VOD.vod_name = '本片无选集';
  110. VOD.vod_pic = img.length>0?img[0]:'';
  111. }
  112. } catch(e) {
  113. print('发生了错误:'+e.message);
  114. }