zxzj_open.js 12 KB

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