zxzj_open.js 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267
  1. import { Crypto, load, _ } from 'assets://js/lib/cat.js';
  2. let key = 'zxzj';
  3. let HOST = 'https://www.zxzj.site'; // 地址发布页
  4. let host = 'https://www.zxzja.com';
  5. let siteKey = '';
  6. let siteType = 0;
  7. const MOBILE_UA = 'Mozilla/5.0 (Linux; Android 11; M2007J3SC Build/RKQ1.200826.002; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/77.0.3865.120 MQQBrowser/6.2 TBS/045714 Mobile Safari/537.36';
  8. async function request(reqUrl, extHeader) {
  9. let headers = {
  10. 'User-Agent': MOBILE_UA,
  11. 'Referer': host,
  12. };
  13. if (extHeader) {
  14. headers = _.merge(headers, extHeader);
  15. }
  16. const res = await req(reqUrl, {
  17. method: 'get',
  18. headers: headers,
  19. });
  20. return res.content;
  21. }
  22. // cfg = {skey: siteKey, ext: extend}
  23. async function init(cfg) {
  24. siteKey = cfg.skey;
  25. siteType = cfg.stype;
  26. const html = await request(HOST);
  27. const $ = load(html);
  28. host = $('div.content-top > ul > li').find('a:first')[0].attribs.href;
  29. console.debug('在线之家 跳转地址 =====>' + host); // js_debug.log
  30. }
  31. async function home(filter) {
  32. const html = await request(host);
  33. const $ = load(html);
  34. const class_parse = $('ul.stui-header__menu > li > a[href*=list]');
  35. let classes = _.map(class_parse, (cls) => {
  36. let typeId = cls.attribs['href'];
  37. typeId = typeId.substring(typeId.lastIndexOf('/') + 1).replace('.html', '');
  38. return {
  39. type_id: typeId,
  40. type_name: cls.children[0].data,
  41. };
  42. });
  43. const filterObj = {
  44. 1: [{ key: 'class', name: '剧情', init: '', 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: 'area', name: '地区', init: '', value: [{ n: '全部', v: '' }, { n: '大陆', v: '大陆' }, { n: '香港', v: '香港' }, { n: '台湾', v: '台湾' }, { n: '欧美', v: '欧美' }, { n: '韩国', v: '韩国' }, { n: '日本', v: '日本' }, { n: '泰国', v: '泰国' }, { n: '印度', v: '印度' }, { n: '俄罗斯', v: '俄罗斯' }, { n: '其他', v: '其他' }] }],
  45. 2: [{ key: 'class', name: '剧情', init: '', 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: '其他' }] }],
  46. 3: [{ key: 'class', name: '剧情', init: '', 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: '其他' }] }],
  47. 4: [{ key: 'class', name: '剧情', init: '', 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: '其他' }] }],
  48. 6: [{ key: 'class', name: '剧情', init: '', 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: '战争' }, { n: '少年', v: '少年' }] }, { key: 'area', name: '地区', init: '', value: [{ n: '全部', v: '' }, { n: '国产', v: '国产' }, { n: '日本', v: '日本' }, { n: '欧美', v: '欧美' }, { n: '其他', v: '其他' }] }]
  49. };
  50. let filYer = { key: 'year', name: '年份', init: '', value: [{ n: '全部', v: '' }, { n: '2024', v: '2024' }, { 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' }] };
  51. let filBy = { key: 'by', name: '排序', value: [{ n: '时间', v: 'time' }, { n: '人气', v: 'hits' }, { n: '评分', v: 'score' }] };
  52. return JSON.stringify({
  53. class: _.map(classes, (cls) => {
  54. if (filterObj[cls.type_id]) {
  55. filterObj[cls.type_id].push(filYer, filBy);
  56. filterObj[cls.type_id][0]['init'] = filterObj[cls.type_id][0].value[0].v;
  57. } else {
  58. filterObj[cls.type_id] = [];
  59. filterObj[cls.type_id].push(filYer, filBy)
  60. }
  61. return cls;
  62. }),
  63. filters: filterObj,
  64. });
  65. }
  66. async function homeVod() {
  67. const link = host + '/vodshow/1--hits---------2023.html';
  68. const html = await request(link);
  69. const $ = load(html);
  70. const js2Base = await js2Proxy(true, siteType, siteKey, 'img/', {});
  71. const items = $('ul.stui-vodlist > li');
  72. let videos = _.map(items, (item) => {
  73. const a = $(item).find('a:first')[0];
  74. const remarks = $($(item).find('span.pic-text')[0]).text().trim();
  75. return {
  76. vod_id: a.attribs.href.replace(/.*?\/detail\/(.*).html/g, '$1'),
  77. vod_name: a.attribs.title,
  78. vod_pic: js2Base + base64Encode(a.attribs['data-original']),
  79. vod_remarks: remarks || '',
  80. };
  81. });
  82. return JSON.stringify({
  83. list: videos,
  84. });
  85. }
  86. async function category(tid, pg, filter, extend) {
  87. if (pg <= 0 || typeof (pg) == 'undefined') pg = 1;
  88. const link = host + '/vodshow/' + tid + '-' + (extend.area || '') + '-' + (extend.by || 'time') + '-' + (extend.class || '') + '-' + (extend.lang || '') + '-' + (extend.letter || '') + '---' + pg + '---' + (extend.year || '') + '.html';
  89. const html = await request(link);
  90. const $ = load(html);
  91. const js2Base = await js2Proxy(true, siteType, siteKey, 'img/', {});
  92. const items = $('ul.stui-vodlist > li');
  93. let videos = _.map(items, (item) => {
  94. const a = $(item).find('a:first')[0];
  95. const remarks = $($(item).find('span.pic-text')[0]).text().trim();
  96. return {
  97. vod_id: a.attribs.href.replace(/.*?\/detail\/(.*).html/g, '$1'),
  98. vod_name: a.attribs.title,
  99. vod_pic: js2Base + base64Encode(a.attribs['data-original']),
  100. vod_remarks: remarks || '',
  101. };
  102. });
  103. const hasMore = $('ul.stui-page__item > li > a:contains(下一页)').length > 0;
  104. const pgCount = hasMore ? parseInt(pg) + 1 : parseInt(pg);
  105. return JSON.stringify({
  106. page: parseInt(pg),
  107. pagecount: pgCount,
  108. limit: 24,
  109. total: 24 * pgCount,
  110. list: videos,
  111. });
  112. }
  113. async function detail(id) {
  114. const html = await request(host + '/detail/' + id + '.html');
  115. const $ = load(html);
  116. const js2Base = await js2Proxy(true, siteType, siteKey, 'img/', {});
  117. const vod = {
  118. vod_id: id,
  119. vod_name: $('h1:first').text().trim(),
  120. vod_type: $('.stui-content__detail p:first a').text(),
  121. vod_actor: $('.stui-content__detail p:nth-child(3)').text().replace('主演:', ''),
  122. vod_director: $('.stui-content__detail p:nth-child(4)').text().replace('导演:', ''),
  123. vod_pic: js2Base + base64Encode($('.stui-content__thumb img:first').attr('data-original')),
  124. vod_remarks: $('.stui-content__detail p:nth-child(5)').text() || '',
  125. vod_content: $('span.detail-content').text().trim(),
  126. };
  127. let playMap = {};
  128. const tabs = $('div.stui-vodlist__head > h3');
  129. const playlists = $('ul.stui-content__playlist');
  130. _.each(tabs, (tab, i) => {
  131. const from = tab.children[0].data;
  132. let list = playlists[i];
  133. list = $(list).find('a');
  134. _.each(list, (it) => {
  135. const title = it.children[0].data;
  136. const playUrl = it.attribs.href;
  137. if (title.length == 0) title = it.children[0].data.trim();
  138. if (!playMap.hasOwnProperty(from)) {
  139. playMap[from] = [];
  140. }
  141. playMap[from].push(title + '$' + playUrl);
  142. });
  143. });
  144. vod.vod_play_from = _.keys(playMap).join('$$$');
  145. const urls = _.values(playMap);
  146. let vod_play_url = _.map(urls, (urlist) => {
  147. return urlist.join('#');
  148. });
  149. vod.vod_play_url = vod_play_url.join('$$$');
  150. return JSON.stringify({
  151. list: [vod],
  152. });
  153. }
  154. async function play(flag, id, flags) {
  155. const html = await request(host + id);
  156. const mhtml = html.match(/r player_.*?=(.*?)</)[1];
  157. const json = JSON.parse(mhtml);
  158. const url = json.url;
  159. const from = json.from;
  160. if (json.encrypt == '1') {
  161. url = unescape(url)
  162. } else if (json.encrypt == '2') {
  163. url = unescape(base64Decode(url))
  164. }
  165. if (url.includes('m3u8') || url.includes('mp4')) {
  166. // console.debug('在线之家url =====>' + url); // js_debug.log
  167. return JSON.stringify({
  168. parse: 0,
  169. url: url,
  170. });
  171. } else if (from.includes('line3') || from.includes('line4') || from.includes('line5')) {
  172. const extHeader = {
  173. 'sec-fetch-mode': 'navigate',
  174. 'sec-fetch-site': 'cross-site',
  175. 'sec-fetch-dest': 'iframe',
  176. 'upgrade-insecure-requests': 1,
  177. };
  178. const ifrwy = await request(url, extHeader);
  179. const resultv2 = ifrwy.match(/var result_v2 = {(.*?)};/)[1];
  180. const data = JSON.parse('{' + resultv2 + '}').data;
  181. const code = data.split('').reverse();
  182. let temp = '';
  183. for (let i = 0x0; i < code.length; i = i + 0x2) {
  184. temp += String.fromCharCode(parseInt(code[i] + code[i + 0x1], 0x10))
  185. }
  186. const purl = temp.substring(0x0, (temp.length - 0x7) / 0x2) + temp.substring((temp.length - 0x7) / 0x2 + 0x7);
  187. // console.debug('在线之家purl =====>' + purl); // js_debug.log
  188. return JSON.stringify({
  189. parse: 0,
  190. url: purl,
  191. });
  192. } else {
  193. // console.debug('在线之家url =====>' + '空'); // js_debug.log
  194. return '{}';
  195. }
  196. }
  197. async function search(wd, quick) {
  198. var data = JSON.parse(await request(host + '/index.php/ajax/suggest?mid=1&wd=' + wd + '&limit=50')).list;
  199. const js2Base = await js2Proxy(true, siteType, siteKey, 'img/', {});
  200. let videos = _.map(data, (it) => {
  201. return {
  202. vod_id: it.id,
  203. vod_name: it.name,
  204. vod_pic: js2Base + base64Encode(it.pic),
  205. vod_remarks: '',
  206. }
  207. });
  208. return JSON.stringify({
  209. list: videos,
  210. limit: 50,
  211. });
  212. }
  213. function base64Encode(text) {
  214. return Crypto.enc.Base64.stringify(Crypto.enc.Utf8.parse(text));
  215. }
  216. function base64Decode(text) {
  217. return Crypto.enc.Utf8.stringify(Crypto.enc.Base64.parse(text));
  218. }
  219. async function proxy(segments, headers) {
  220. let what = segments[0];
  221. let url = base64Decode(segments[1]);
  222. if (what == 'img') {
  223. var resp = await req(url, {
  224. buffer: 2,
  225. headers: {
  226. Referer: 'https://api.douban.com/',
  227. 'User-Agent': MOBILE_UA,
  228. },
  229. });
  230. return JSON.stringify({
  231. code: resp.code,
  232. buffer: 2,
  233. content: resp.content,
  234. headers: resp.headers,
  235. });
  236. }
  237. return JSON.stringify({
  238. code: 500,
  239. content: '',
  240. });
  241. }
  242. export function __jsEvalReturn() {
  243. return {
  244. init: init,
  245. home: home,
  246. homeVod: homeVod,
  247. category: category,
  248. detail: detail,
  249. play: play,
  250. proxy: proxy,
  251. search: search,
  252. };
  253. }