1080kk_open.js 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. import { Crypto, load, _, jinja2 } from './lib/cat.js';
  2. let key = '108kk';
  3. let HOST = 'https://www.1080kk.com';
  4. let siteKey = '';
  5. let siteType = 0;
  6. 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';
  7. async function request(reqUrl, agentSp) {
  8. let res = await req(reqUrl, {
  9. method: 'get',
  10. headers: {
  11. 'User-Agent': agentSp || UA,
  12. 'Referer': HOST
  13. },
  14. });
  15. return res.content;
  16. }
  17. // cfg = {skey: siteKey, ext: extend}
  18. async function init(cfg) {
  19. siteKey = cfg.skey;
  20. siteType = cfg.stype;
  21. }
  22. async function home(filter) {
  23. let classes = [{"type_id":1,"type_name":"电影"},{"type_id":2,"type_name":"追剧"},{"type_id":3,"type_name":"综艺"},{"type_id":4,"type_name":"动漫"}];
  24. let filterObj = {
  25. "2":[{"key":"cateId","name":"类型","value":[{"n":"全部","v":"2"},{"n":"陆剧","v":"13"},{"n":"日韩剧","v":"15"},{"n":"欧美剧","v":"16"},{"n":"港台剧","v":"14"}]},{"key":"class","name":"剧情","value":[{"n":"全部","v":""},{"n":"历史","v":"历史"},{"n":"古装","v":"古装"},{"n":"战争","v":"战争"},{"n":"青春偶像","v":"青春偶像"},{"n":"喜剧","v":"喜剧"},{"n":"家庭","v":"家庭"},{"n":"犯罪","v":"犯罪"},{"n":"奇幻","v":"奇幻"},{"n":"剧情","v":"剧情"},{"n":"乡村","v":"乡村"},{"n":"情景","v":"情景"},{"n":"商战","v":"商战"}]},{"key":"year","name":"年份","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"}]},{"key":"letter","name":"字母","value":[{"n":"全部","v":""},{"n":"A","v":"A"},{"n":"B","v":"B"},{"n":"C","v":"C"},{"n":"D","v":"D"},{"n":"E","v":"E"},{"n":"F","v":"F"},{"n":"G","v":"G"},{"n":"H","v":"H"},{"n":"I","v":"I"},{"n":"J","v":"J"},{"n":"K","v":"K"},{"n":"L","v":"L"},{"n":"M","v":"M"},{"n":"N","v":"N"},{"n":"O","v":"O"},{"n":"P","v":"P"},{"n":"Q","v":"Q"},{"n":"R","v":"R"},{"n":"S","v":"S"},{"n":"T","v":"T"},{"n":"U","v":"U"},{"n":"V","v":"V"},{"n":"W","v":"W"},{"n":"X","v":"X"},{"n":"Y","v":"Y"},{"n":"Z","v":"Z"}]},{"key":"by","name":"排序","value":[{"n":"时间","v":"time"},{"n":"人气","v":"hits"},{"n":"评分","v":"score"}]}],
  26. "1":[{"key":"cateId","name":"类型","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":"年份","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"}]},{"key":"letter","name":"字母","value":[{"n":"全部","v":""},{"n":"A","v":"A"},{"n":"B","v":"B"},{"n":"C","v":"C"},{"n":"D","v":"D"},{"n":"E","v":"E"},{"n":"F","v":"F"},{"n":"G","v":"G"},{"n":"H","v":"H"},{"n":"I","v":"I"},{"n":"J","v":"J"},{"n":"K","v":"K"},{"n":"L","v":"L"},{"n":"M","v":"M"},{"n":"N","v":"N"},{"n":"O","v":"O"},{"n":"P","v":"P"},{"n":"Q","v":"Q"},{"n":"R","v":"R"},{"n":"S","v":"S"},{"n":"T","v":"T"},{"n":"U","v":"U"},{"n":"V","v":"V"},{"n":"W","v":"W"},{"n":"X","v":"X"},{"n":"Y","v":"Y"},{"n":"Z","v":"Z"}]},{"key":"by","name":"排序","value":[{"n":"时间","v":"time"},{"n":"人气","v":"hits"},{"n":"评分","v":"score"}]}],
  27. "3":[{"key":"class","name":"剧情","value":[{"n":"全部","v":""},{"n":"国综","v":"大陆综艺"},{"n":"港综","v":"港台综艺"},{"n":"韩日综","v":"日韩综艺"},{"n":"欧美综","v":"欧美综艺"}]},{"key":"year","name":"年份","value":[{"n":"全部","v":""},{"n":"2023","v":"2023"},{"n":"2022","v":"2022"},{"n":"2021","v":"2021"},{"n":"2020","v":"2020"},{"n":"2019","v":"2019"}]},{"key":"letter","name":"字母","value":[{"n":"全部","v":""},{"n":"A","v":"A"},{"n":"B","v":"B"},{"n":"C","v":"C"},{"n":"D","v":"D"},{"n":"E","v":"E"},{"n":"F","v":"F"},{"n":"G","v":"G"},{"n":"H","v":"H"},{"n":"I","v":"I"},{"n":"J","v":"J"},{"n":"K","v":"K"},{"n":"L","v":"L"},{"n":"M","v":"M"},{"n":"N","v":"N"},{"n":"O","v":"O"},{"n":"P","v":"P"},{"n":"Q","v":"Q"},{"n":"R","v":"R"},{"n":"S","v":"S"},{"n":"T","v":"T"},{"n":"U","v":"U"},{"n":"V","v":"V"},{"n":"W","v":"W"},{"n":"X","v":"X"},{"n":"Y","v":"Y"},{"n":"Z","v":"Z"}]},{"key":"by","name":"排序","value":[{"n":"时间","v":"time"},{"n":"人气","v":"hits"},{"n":"评分","v":"score"}]}],
  28. "4":[{"key":"class","name":"剧情","value":[{"n":"全部","v":""},{"n":"国漫","v":"国产动漫"},{"n":"日韩动漫","v":"日韩动漫"},{"n":"欧美动漫","v":"欧美动漫"},{"n":"港漫","v":"港台动漫"},{"n":"海外动漫","v":"海外动漫"}]},{"key":"year","name":"年份","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"}]},{"key":"letter","name":"字母","value":[{"n":"全部","v":""},{"n":"A","v":"A"},{"n":"B","v":"B"},{"n":"C","v":"C"},{"n":"D","v":"D"},{"n":"E","v":"E"},{"n":"F","v":"F"},{"n":"G","v":"G"},{"n":"H","v":"H"},{"n":"I","v":"I"},{"n":"J","v":"J"},{"n":"K","v":"K"},{"n":"L","v":"L"},{"n":"M","v":"M"},{"n":"N","v":"N"},{"n":"O","v":"O"},{"n":"P","v":"P"},{"n":"Q","v":"Q"},{"n":"R","v":"R"},{"n":"S","v":"S"},{"n":"T","v":"T"},{"n":"U","v":"U"},{"n":"V","v":"V"},{"n":"W","v":"W"},{"n":"X","v":"X"},{"n":"Y","v":"Y"},{"n":"Z","v":"Z"}]},{"key":"by","name":"排序","value":[{"n":"时间","v":"time"},{"n":"人气","v":"hits"},{"n":"评分","v":"score"}]}]
  29. };
  30. return JSON.stringify({
  31. class: classes,
  32. filters: filterObj,
  33. });
  34. }
  35. async function homeVod() {}
  36. async function category(tid, pg, filter, extend) {
  37. if (pg <= 0) pg = 1;
  38. const link = HOST + '/vodshow/' + (extend.CateId || tid) + '--' + (extend.by || 'time') + '-' + (extend.class || '') + '--' + (extend.letter || '') + '---' + pg + '---' + (extend.year || '') + '.html';//https://www.1080kk.com/vodshow/13--hits-%E5%8F%A4%E8%A3%85-%E5%9B%BD%E8%AF%AD-B------2022.html
  39. const html = await request(link);
  40. const $ = load(html);
  41. const items = $('ul.myui-vodlist > li');
  42. let videos = _.map(items, (item) => {
  43. const it = $(item).find('a:first')[0];
  44. const remarks = $($(item).find('span.pic-text text-right')[0]).text().trim();
  45. return {
  46. vod_id: it.attribs.href.replace(/.*?\/voddetail\/(.*).html/g, '$1'),
  47. vod_name: it.attribs.title,
  48. vod_pic: it.attribs['data-original'],
  49. vod_remarks: remarks || '',
  50. };
  51. });
  52. const hasMore = $('ul.myui-page > li > a:contains(下一页)').length > 0;
  53. const pgCount = hasMore ? parseInt(pg) + 1 : parseInt(pg);
  54. return JSON.stringify({
  55. page: parseInt(pg),
  56. pagecount: pgCount,
  57. limit: 24,
  58. total: 24 * pgCount,
  59. list: videos,
  60. });
  61. }
  62. async function detail(id) {
  63. var html = await request( HOST + '/voddetail/' + id + '.html');
  64. var $ = load(html);
  65. var vod = {
  66. vod_id: id,
  67. vod_name: $('h1:first').text().trim(),
  68. vod_type: $('.stui-content__detail p:first a').text(),
  69. vod_actor: $('.stui-content__detail p:nth-child(3)').text().replace('主演:',''),
  70. vod_pic: $('.stui-content__thumb img:first').attr('data-original'),
  71. vod_remarks : $('.stui-content__detail p:nth-child(5)').text() || '',
  72. vod_content: $('span.detail-content').text().trim(),
  73. };
  74. var playMap = {};
  75. var tabs = $('ul.nav-tabs > li > a[data-toggle*=tab]');
  76. var playlists = $('ul.myui-content__list');
  77. _.each(tabs, (tab, i) => {
  78. var from = tab.children[0].data;
  79. var list = playlists[i];
  80. list = $(list).find('a');
  81. _.each(list, (it) => {
  82. var title = it.children[0].data;
  83. var playUrl = it.attribs.href.replace(/\/vodplay\/(.*).html/g, '$1');
  84. if (title.length == 0) title = it.children[0].data.trim();
  85. if (!playMap.hasOwnProperty(from)) {
  86. playMap[from] = [];
  87. }
  88. playMap[from].push( title + '$' + playUrl);
  89. });
  90. });
  91. vod.vod_play_from = _.keys(playMap).join('$$$');
  92. var urls = _.values(playMap);
  93. var vod_play_url = _.map(urls, (urlist) => {
  94. return urlist.join('#');
  95. });
  96. vod.vod_play_url = vod_play_url.join('$$$');
  97. return JSON.stringify({
  98. list: [vod],
  99. });
  100. }
  101. async function play(flag, id, flags) {
  102. const link = HOST + '/vodplay/' + id + '.html';
  103. const html = await request(link);
  104. const $ = load(html);
  105. const js = JSON.parse($('script:contains(player_)').html().replace('var player_aaaa=',''));
  106. const playurl = js.url;
  107. const playUrl = unescape(playurl);
  108. return JSON.stringify({
  109. parse: 0,
  110. url: playUrl,
  111. });
  112. }
  113. async function search(wd, quick) {
  114. let data = JSON.parse(await request(HOST + '/index.php/ajax/suggest?mid=1&wd=' + wd)).list;
  115. let videos = [];
  116. for (const vod of data) {
  117. videos.push({
  118. vod_id: vod.id,
  119. vod_name: vod.name,
  120. vod_pic: vod.pic,
  121. vod_remarks: '',
  122. });
  123. }
  124. return JSON.stringify({
  125. list: videos,
  126. });
  127. }
  128. export function __jsEvalReturn() {
  129. return {
  130. init: init,
  131. home: home,
  132. homeVod: homeVod,
  133. category: category,
  134. detail: detail,
  135. play: play,
  136. search: search,
  137. };
  138. }