nkvod_open.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  1. import { Crypto, load, _ } from 'assets://js/lib/cat.js';
  2. let key = 'nkvod';
  3. let HOST = 'https://nkvod.pro';
  4. let parseMap = {
  5. '新自建.5': 'https://op.xn--it-if7c19g5s4bps5c.com/player/ez.php?code=nkvod&if=1&url=',
  6. '新自建': 'https://op.xn--it-if7c19g5s4bps5c.com/player/ez.php?code=nkvod&if=1&url=',
  7. 'Pp自建': 'https://op.xn--it-if7c19g5s4bps5c.com/player/ez.php?code=nkvod&if=1&url=',
  8. '自建三.5': 'https://op.xn--it-if7c19g5s4bps5c.com/player/ez.php?code=nkvod&if=1&url=',
  9. '新自建.0': 'https://op.xn--it-if7c19g5s4bps5c.com/player/ez.php?code=nkvod&if=1&url=',
  10. '自建三': 'https://op.xn--it-if7c19g5s4bps5c.com/player/ez.php?code=nkvod&if=1&url=',
  11. 'Af自建': 'https://op.xn--it-if7c19g5s4bps5c.com/player/ez.php?code=nkvod&if=1&url=',
  12. '自建四': 'https://op.xn--it-if7c19g5s4bps5c.com/player/ez.php?code=nkvod&if=1&url=',
  13. '西瓜视频': 'https://op.xn--it-if7c19g5s4bps5c.com/player/xigua.php?code=nkvod&if=1&url=',
  14. '自建一': 'https://ag.xn--it-if7c19g5s4bps5c.com/nk.php?url=',
  15. '自建二': 'https://ag.xn--it-if7c19g5s4bps5c.com/nk.php?url=',
  16. '腾讯视频': 'https://op.xn--it-if7c19g5s4bps5c.com/player/gg.php?code=nkvod&if=1&url=',
  17. '奇艺视频': 'https://op.xn--it-if7c19g5s4bps5c.com/player/gg.php?code=nkvod&if=1&url=',
  18. '优酷视频': 'https://op.xn--it-if7c19g5s4bps5c.com/player/gg.php?code=nkvod&if=1&url=',
  19. '芒果视频': 'https://op.xn--it-if7c19g5s4bps5c.com/player/gg.php?code=nkvod&if=1&url=',
  20. 'B站': 'https://op.xn--it-if7c19g5s4bps5c.com/player/gg.php?code=nkvod&if=1&url=',
  21. '量子资源': 'https://op.xn--it-if7c19g5s4bps5c.com/player/en.php?code=nkvod&if=1&url=',
  22. '非凡资源': 'https://op.xn--it-if7c19g5s4bps5c.com/player/en.php?code=nkvod&if=1&url=',
  23. '失效': 'https://op.xn--it-if7c19g5s4bps5c.com/player/ez.php?code=nkvod&if=1&url=',
  24. '云播一': 'https://www.lkvod.com/addons/dplayer/?url='
  25. };
  26. let siteKey = '';
  27. let siteType = 0;
  28. const UA = 'Mozilla/5.0 (iPhone; CPU iPhone OS 13_2_3 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/13.0.3 Mobile/15E148 Safari/604.1';
  29. async function request(reqUrl) {
  30. let res = await req(reqUrl, {
  31. method: 'get',
  32. headers: {
  33. 'User-Agent': UA,
  34. 'Referer': HOST
  35. },
  36. });
  37. return res.content;
  38. }
  39. // cfg = {skey: siteKey, ext: extend}
  40. async function init(cfg) {
  41. siteKey = cfg.skey;
  42. siteType = cfg.stype;
  43. //await initParseMap();
  44. //console.log(parseMap);
  45. }
  46. async function initParseMap() {
  47. const date = new Date();
  48. const t = '' + date.getFullYear() + (date.getMonth() + 1) + date.getDate();
  49. const js = await request(HOST + '/static/js/playerconfig.js?t=' + t);
  50. try {
  51. const playerList = JSON.parse(js.split('MacPlayerConfig.player_list=')[1].split(',MacPlayerConfig.downer_list')[0]);
  52. const players = _.values(playerList);
  53. _.each(players, (item) => {
  54. if (!item.ps || item.ps == '0') return;
  55. if (_.isEmpty(item.parse)) return;
  56. parseMap[item.show] = item.parse;
  57. });
  58. } catch(e) {
  59. console.log('error', e);
  60. }
  61. }
  62. async function home(filter) {
  63. const classes = [{'type_id':'1','type_name':'电影'},{'type_id':'2','type_name':'电视剧'},{'type_id':'3','type_name':'综艺'},{'type_id':'4','type_name':'动漫'}];
  64. const filterObj = {
  65. '1':[{'key':'cateId','name':'类型','init':'1','value':[{'n':'全部','v':'1'},{'n':'动作片','v':'6'},{'n':'喜剧片','v':'7'},{'n':'爱情片','v':'8'},{'n':'科幻片','v':'9'},{'n':'恐怖片','v':'10'},{'n':'剧情片','v':'11'},{'n':'战争片','v':'12'}]},{'key':'year','name':'年代','init':'','value':[{'n':'全部','v':''},{'n':'2023','v':'2023'},{'n':'2022','v':'2022'},{'n':'2021','v':'2021'},{'n':'2020','v':'2020'},{'n':'2019','v':'2019'},{'n':'2018','v':'2018'},{'n':'2017','v':'2017'},{'n':'2016','v':'2016'},{'n':'2015','v':'2015'},{'n':'2014','v':'2014'},{'n':'2013','v':'2013'},{'n':'2012','v':'2012'},{'n':'2011','v':'2011'},{'n':'2010','v':'2010'}]},{'key':'by','name':'排序','value':[{'n':'时间','v':'time'},{'n':'人气','v':'hits'},{'n':'评分','v':'score'}]}],
  66. '2':[{'key':'cateId','name':'类型','init':'2','value':[{'n':'全部','v':'2'},{'n':'国产剧','v':'13'},{'n':'港台剧','v':'14'},{'n':'日韩剧','v':'15'},{'n':'欧美剧','v':'16'},{'n':'其他剧','v':'20'}]},{'key':'year','name':'年代','init':'','value':[{'n':'全部','v':''},{'n':'2023','v':'2023'},{'n':'2022','v':'2022'},{'n':'2021','v':'2021'},{'n':'2020','v':'2020'},{'n':'2019','v':'2019'},{'n':'2018','v':'2018'},{'n':'2017','v':'2017'},{'n':'2016','v':'2016'},{'n':'2015','v':'2015'},{'n':'2014','v':'2014'},{'n':'2013','v':'2013'},{'n':'2012','v':'2012'},{'n':'2011','v':'2011'},{'n':'2010','v':'2010'},{'n':'2009','v':'2009'},{'n':'2008','v':'2008'},{'n':'2007','v':'2007'},{'n':'2006','v':'2006'},{'n':'2005','v':'2005'},{'n':'2004','v':'2004'}]},{'key':'by','name':'排序','value':[{'n':'时间','v':'time'},{'n':'人气','v':'hits'},{'n':'评分','v':'score'}]}],
  67. '3':[{'key':'year','name':'年代','init':'','value':[{'n':'全部','v':''},{'n':'2023','v':'2023'},{'n':'2022','v':'2022'},{'n':'2021','v':'2021'},{'n':'2020','v':'2020'},{'n':'2019','v':'2019'},{'n':'2018','v':'2018'},{'n':'2017','v':'2017'},{'n':'2016','v':'2016'},{'n':'2015','v':'2015'},{'n':'2014','v':'2014'},{'n':'2013','v':'2013'},{'n':'2012','v':'2012'},{'n':'2011','v':'2011'},{'n':'2010','v':'2010'},{'n':'2009','v':'2009'},{'n':'2008','v':'2008'},{'n':'2007','v':'2007'},{'n':'2006','v':'2006'},{'n':'2005','v':'2005'},{'n':'2004','v':'2004'}]},{'key':'by','name':'排序','value':[{'n':'时间','v':'time'},{'n':'人气','v':'hits'},{'n':'评分','v':'score'}]}],
  68. '4':[{'key':'year','name':'年代','init':'','value':[{'n':'全部','v':''},{'n':'2023','v':'2023'},{'n':'2022','v':'2022'},{'n':'2021','v':'2021'},{'n':'2020','v':'2020'},{'n':'2019','v':'2019'},{'n':'2018','v':'2018'},{'n':'2017','v':'2017'},{'n':'2016','v':'2016'},{'n':'2015','v':'2015'},{'n':'2014','v':'2014'},{'n':'2013','v':'2013'},{'n':'2012','v':'2012'},{'n':'2011','v':'2011'},{'n':'2010','v':'2010'},{'n':'2009','v':'2009'},{'n':'2008','v':'2008'},{'n':'2007','v':'2007'},{'n':'2006','v':'2006'},{'n':'2005','v':'2005'},{'n':'2004','v':'2004'}]},{'key':'by','name':'排序','value':[{'n':'时间','v':'time'},{'n':'人气','v':'hits'},{'n':'评分','v':'score'}]}]
  69. };
  70. return JSON.stringify({
  71. class: classes,
  72. filters: filterObj,
  73. });
  74. }
  75. async function homeVod() {}
  76. async function category(tid, pg, filter, extend) {
  77. if (pg <= 0) pg = 1;
  78. const link = HOST + '/show/' + (extend.cateId || tid) + '--' + (extend.by || '') + '-' + (extend.class || '') + '--' + (extend.letter || '') + '---' + pg + '---' + (extend.year || '') + '.html';
  79. const html = await request(link);
  80. const $ = load(html);
  81. const items = $('a.module-item');
  82. const videos = _.map(items, (item) => {
  83. const $item = $(item);
  84. const a = $item;
  85. const img = $item.find('img:first');
  86. const remarks = $item.find('div.module-item-note').text().trim();
  87. return {
  88. vod_id: a.attr('href').replace(/.*?\/detail\/(.*).html/g, '$1'),
  89. vod_name: a.attr('title'),
  90. vod_pic: img.attr('data-original'),
  91. vod_remarks: remarks,
  92. };
  93. });
  94. const limit = 72;
  95. const hasMore = $('div#page > a:contains(下一页)').length > 0;
  96. const pgCount = hasMore ? parseInt(pg) + 1 : parseInt(pg);
  97. return JSON.stringify({
  98. page: parseInt(pg),
  99. pagecount: pgCount,
  100. limit: limit,
  101. total: limit * pgCount,
  102. list: videos,
  103. });
  104. }
  105. async function detail(id) {
  106. const html = await request(HOST + '/detail/' + id + '.html');
  107. const $ = load(html);
  108. const vod = {
  109. vod_id: id,
  110. vod_name: $('h1:first').text().trim(),
  111. vod_type: $('.module-info-tag a:eq(2)').text().trim(),
  112. vod_year: $('.module-info-tag a:eq(0)').text().trim(),
  113. vod_area: $('.module-info-tag a:eq(1)').text().trim(),
  114. vod_actor: $('.module-info-item:contains(主演:)').text().trim().substring(3).replace(/\/$/, ''),
  115. vod_director: $('.module-info-item:contains(导演:)').text().trim().substring(3).replace(/\/$/, ''),
  116. vod_pic: $('.module-info-poster img:first').attr('data-original'),
  117. vod_remarks : $('.module-info-item:contains(备注:)').text(),
  118. vod_content: $('.module-info-introduction-content').text().trim(),
  119. };
  120. const playMap = {};
  121. const tabs = $('.module-tab .module-tab-item span');
  122. const playlists = $('.module-play-list');
  123. _.each(tabs, (tab, i) => {
  124. const $tab = $(tab);
  125. const from = $tab.text().trim();
  126. let list = playlists[i];
  127. list = $(list).find('a');
  128. _.each(list, (it) => {
  129. const $it = $(it);
  130. let title = $it.find('span').text();
  131. const playUrl = $it.attr('href');
  132. if (_.isEmpty(title)) title = $it.text();
  133. if (!playMap.hasOwnProperty(from)) {
  134. playMap[from] = [];
  135. }
  136. playMap[from].push(title + '$' + from + '|' +playUrl);
  137. });
  138. });
  139. vod.vod_play_from = _.keys(playMap).join('$$$');
  140. const urls = _.values(playMap);
  141. const vod_play_url = _.map(urls, (urlist) => {
  142. return urlist.join('#');
  143. });
  144. vod.vod_play_url = vod_play_url.join('$$$');
  145. return JSON.stringify({
  146. list: [vod],
  147. });
  148. }
  149. async function play(flag, id, flags) {
  150. const from = id.split('|')[0];
  151. const url = id.split('|')[1];
  152. const link = HOST + url;
  153. const html = await request(link);
  154. const $ = load(html);
  155. const js = JSON.parse($('script:contains(player_)').html().replace('var player_aaaa=',''));
  156. let playUrl = js.url;
  157. if (js.encrypt == 1) {
  158. playUrl = unescape(playUrl);
  159. } else if (js.encrypt == 2) {
  160. playUrl = unescape(base64Decode(playUrl));
  161. }
  162. const parseUrl = parseMap[from];
  163. if (parseUrl) {
  164. const reqUrl = parseUrl + playUrl;
  165. const parseHtml = await request(reqUrl);
  166. const matches = parseHtml.match(/let ConFig = {([\w\W]*)},box/);
  167. if (!_.isEmpty(matches)) {
  168. const configJson = '{' + matches[1].trim() + '}';
  169. const config = JSON.parse(configJson);
  170. playUrl = decryptUrl(config);
  171. }
  172. }
  173. return JSON.stringify({
  174. parse: 0,
  175. url: playUrl,
  176. header: {
  177. 'User-Agent': UA,
  178. }
  179. });
  180. }
  181. function decryptUrl(jsConfig) {
  182. const key = Crypto.enc.Utf8.parse('2890' + jsConfig.config.uid + 'tB959C');
  183. const iv = Crypto.enc.Utf8.parse('GZ4JgN2BdSqVWJ1z');
  184. const mode = Crypto.mode.CBC;
  185. const padding = Crypto.pad.Pkcs7;
  186. const decrypted = Crypto.AES.decrypt(jsConfig.url, key, {
  187. iv: iv,
  188. mode: mode,
  189. padding: padding
  190. });
  191. const decryptedUrl = Crypto.enc.Utf8.stringify(decrypted);
  192. return decryptedUrl;
  193. }
  194. async function search(wd, quick) {
  195. const data = JSON.parse(await request(HOST + '/index.php/ajax/suggest?mid=1&limit=50&wd=' + wd)).list;
  196. const videos = _.map(data, (vod) => {
  197. return {
  198. vod_id: vod.id,
  199. vod_name: vod.name,
  200. vod_pic: vod.pic,
  201. vod_remarks: '',
  202. };
  203. });
  204. return JSON.stringify({
  205. list: videos,
  206. });
  207. }
  208. export function __jsEvalReturn() {
  209. return {
  210. init: init,
  211. home: home,
  212. homeVod: homeVod,
  213. category: category,
  214. detail: detail,
  215. play: play,
  216. search: search,
  217. };
  218. }