4kysxz_open.js 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. import { Crypto, load, _ } from './lib/cat.js';
  2. let siteUrl = 'https://4kysxz.top';
  3. let siteKey = '';
  4. let siteType = 0;
  5. let headers = {};
  6. async function request(reqUrl, postData, agentSp, get) {
  7. let res = await req(reqUrl, {
  8. method: get ? 'get' : 'post',
  9. headers: headers,
  10. data: postData || {},
  11. postType: get ? '' : 'form',
  12. });
  13. let content = res.content;
  14. return content;
  15. }
  16. async function init(cfg) {
  17. siteKey = cfg.skey;
  18. siteType = cfg.stype;
  19. }
  20. async function home(filter) {
  21. let classes = [{
  22. type_id: '16',
  23. type_name: '高清电影',
  24. },{
  25. type_id: '17',
  26. type_name: '高清剧集',
  27. }];
  28. //let filterObj = genFilterObj();
  29. return JSON.stringify({
  30. class: classes,
  31. //filters: filterObj
  32. });
  33. }
  34. async function homeVod() {
  35. let videos = await getVideos(siteUrl);
  36. return JSON.stringify({
  37. list: videos,
  38. });
  39. }
  40. async function category(tid, pg, filter, extend) {
  41. if (!pg) pg = 1;
  42. if (pg <= 0) pg = 1;
  43. let url = siteUrl + '/category-' + tid + '_' + pg + '.html';
  44. let videos = await getVideos(url);
  45. return JSON.stringify({
  46. list: videos,
  47. page: pg,
  48. });
  49. }
  50. async function detail(id) {
  51. try {
  52. const html = await request(id);
  53. const $ = load(html);
  54. let actors = _.map($('div.entry-content.u-text-format.u-clearfix > div:nth-child(10) > div > span > span'), (n) => {
  55. return $(n).text().split(' ')[0];
  56. });
  57. let actor = actors.join(' ');
  58. let directors = _.map($('div.entry-content.u-text-format.u-clearfix > div:nth-child(8) > div > span'), (n) => {
  59. return $(n).text().split(' ')[0];
  60. });
  61. let director = directors.join(' ');
  62. let title = $('div.site-content > section > div > header > h1').text().trim();
  63. let content = '该影视由【Leospring】采集分享';
  64. let playUrlStr = '';
  65. let playFromStr = '';
  66. //高清直播
  67. const cards = $('div.entry-content.u-text-format.u-clearfix > custag > ul > li > a');
  68. if (cards.length > 0) {
  69. let playUrls = _.map(cards, (n) => {
  70. let playUrl = n.attribs['href'];
  71. if (playUrl.indexOf('url=') > 0) {
  72. playUrl = playUrl.split('url=')[1].split('&name')[0];
  73. }
  74. return $(n).text() + '$' + playUrl;
  75. });
  76. playUrlStr = playUrls.join('#');
  77. playFromStr = '高清直播';
  78. }
  79. //磁力链接
  80. const tbs = $('loginshow > table');
  81. let playFrom = '';
  82. let nameUrls = [];
  83. for(let i = 0;i< tbs.length;i++) {
  84. if (i%2 == 0) {
  85. playFrom = $(tbs[i]).find('tbody > tr >td').text().replaceAll('WEB', '磁力');
  86. } else if (i%2 == 1) {
  87. const tds = $(tbs[i]).find('tbody > tr >td');
  88. let nameUrl = '';
  89. for (let j = 0;j < tds.length;j++) {
  90. if (j%2 == 0) {
  91. nameUrl = $(tds[j]).text().split('.')[0].split(' ')[0];
  92. } else if (j%2==1){
  93. nameUrl = nameUrl + '$' + $(tds[j]).text().split('【')[0];
  94. nameUrls.push(nameUrl);
  95. }
  96. }
  97. if (playFromStr.length > 0) {
  98. playFromStr += '$$$';
  99. playUrlStr += '$$$';
  100. }
  101. playFromStr += playFrom;
  102. playUrlStr += nameUrls.join('#');
  103. }
  104. }
  105. const video = {
  106. vod_actor: actor,
  107. vod_play_from: playFromStr,
  108. vod_play_url: playUrlStr,
  109. vod_director: director,
  110. vod_content: content,
  111. };
  112. const list = [video];
  113. const result = { list };
  114. return JSON.stringify(result);
  115. } catch (e) {
  116. //console.log('err', e);
  117. }
  118. return null;
  119. }
  120. async function search(wd, quick, pg) {
  121. let url = siteUrl + '/search.php?q=' + wd
  122. //console.log('search url:', url);
  123. let videos = await getVideos(url);
  124. return JSON.stringify({
  125. list: videos,
  126. });
  127. }
  128. async function play(flag, id, flags) {
  129. return JSON.stringify({
  130. parse: 0,
  131. url: id,
  132. });
  133. }
  134. async function getVideos(url) {
  135. const html = await request(url);
  136. const $ = load(html);
  137. const cards = $('div.row.posts-wrapper >div > article > div.entry-media > div > a')
  138. let videos = _.map(cards, (n) => {
  139. let id = n.attribs['href'];
  140. let name = $($(n).find('img')[0]).attr('alt').replaceAll('<strong>','').replaceAll('</strong>', '').split(' ')[0];
  141. let pic = $($(n).find('img')[0]).attr('data-src');
  142. return {
  143. vod_id: id,
  144. vod_name: name,
  145. vod_pic: pic,
  146. vod_remarks: '',
  147. };
  148. });
  149. return videos;
  150. }
  151. export function __jsEvalReturn() {
  152. return {
  153. init: init,
  154. home: home,
  155. homeVod: homeVod,
  156. category: category,
  157. detail: detail,
  158. play: play,
  159. search: search,
  160. };
  161. }