mtsp_open.js 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201
  1. import { Crypto, _ } from './lib/cat.js';
  2. let key = 'mtsp';
  3. let main = 'https://mt77.pw/';
  4. let url = '';
  5. let siteKey = '';
  6. let siteType = 0;
  7. let searchKeys = [];
  8. let tags = 'JTVCJTIyJUU2JUI1JTkzJUU1JUFGJTg2JUU2JUJGJTgwJUU2JTgzJTg1JTIyJTJDJTIyJUU2JTkwJTlDJUU2JTlGJUE1JUU1JUFFJTk4JTIyJTJDJTIyJUU1JUE1JUIzJUU0JUJCJTg2JTIyJTJDJTIyJUU1JTkwJThFJUU1JTg1JUE1JTIyJTJDJTIyJUU3JUJFJThFJUU0JUI5JUIzJUU1JUI3JUE4JUU4JTgzJUI4JTIyJTJDJTIyJUU1JThGJUEzJUU0JUJBJUE0JUU1JThGJUEzJUU3JTg4JTg2JTIyJTJDJTIyJUU1JTg2JTg1JUU1JUIwJTg0JTIyJTJDJTIyJUU1JUE1JUIzJUU0JUI4JThBJTIyJTJDJTIyJUU3JUJFJThFJUU4JTg1JUJGJTIyJTJDJTIyJUU3JUIyJUJFJUU1JTkzJTgxJTIyJTJDJTIyJUU0JUI4JTlEJUU4JUEyJTlDJTIyJTJDJTIyJUU1JUIwJTkxJUU1JUE1JUIzJTIyJTJDJTIyJUU1JTg4JUI2JUU2JTlDJThEJTIyJTJDJTIyJUU3JUJFJUE0UCUyMiUyQyUyMiVFNyU5OSVCRCVFOCU5OSU4RSUyMiUyQyUyMiVFNiU4MyU4NSVFOCVCNiVBMyVFOCVBRiVCMSVFNiU4MyU5MSUyMiUyQyUyMiVFOSU4MSU5MyVFNSU4NSVCNyUyMiUyQyUyMiVFNSVBNSVCMyVFNyVBN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ThBJTgwJUU1JUI4JTg4JTIyJTJDJTIyJUU3JUIyJUJFJUU0JUI4JTlDJUU0JUJDJUEwJUU1JUFBJTkyJTIyJTJDJTIyJUU2JTk1JTk5JUU1JUFFJUE0JTIyJTJDJTIyJUU4JUJGJUI3JUU1JUE1JUI4JTIyJTJDJTIyJUU2JThEJUEyJUU1JUE2JUJCJTIyJTJDJTIyS1RWJTIyJTJDJTIyJUU2JTk4JTlGJUU3JUE5JUJBJUU0JUJDJUEwJUU1JUFBJTkyJTIyJTJDJTIyJUU2JThBJUE0JUU1JUEzJUFCJTIyJTJDJTIyJUU2JUFGJThEJUU1JUE1JUIzJTIyJTVE';
  9. const UA = 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/95.0.4638.54 Safari/537.36';
  10. async function request(reqUrl, agentSp) {
  11. const res = await req(reqUrl, {
  12. headers: {
  13. 'User-Agent': agentSp || UA,
  14. },
  15. });
  16. return res.content;
  17. }
  18. // cfg = {skey: siteKey, ext: extend}
  19. async function init(cfg) {
  20. siteKey = cfg.skey;
  21. siteType = cfg.stype;
  22. // 获取url
  23. let html = await request(main);
  24. url = html.match(/location\.href="(.*)"/)[1].replace('https', 'http');
  25. tags = JSON.parse(decodeURIComponent(base64Decode(tags)));
  26. searchKeys = cfg.tags || [];
  27. let mainJs = await request(url + '/main.js');
  28. url = mainJs.match(/apiurl = '(.*)'/)[1].replace('https', 'http');
  29. }
  30. async function home(filter) {
  31. let classes = [];
  32. let filterObj = {};
  33. let tagIdx = 1;
  34. _.each(_.chunk(tags, 24), (array) => {
  35. const subs = _.chunk(array, 8);
  36. let tid = '';
  37. let init = '';
  38. for (let i = 0; i < subs.length; i++) {
  39. let tt = {
  40. key: 'tag',
  41. name: '',
  42. init: '',
  43. value: _.map(subs[i], (e) => {
  44. return { n: e, v: e };
  45. }),
  46. };
  47. if (i == 0) {
  48. init = tt.value[0].v;
  49. tt['init'] = init;
  50. tid = tt.value[0].v;
  51. filterObj[tid] = [tt];
  52. } else {
  53. tt['init'] = init;
  54. filterObj[tid].push(tt);
  55. }
  56. }
  57. classes.push({
  58. type_id: tid,
  59. type_name: '综合' + tagIdx,
  60. land: 1,
  61. });
  62. tagIdx++;
  63. });
  64. _.each(searchKeys, (s) => {
  65. classes.push({
  66. type_id: 'sc_' + s,
  67. type_name: s,
  68. land: 1,
  69. });
  70. });
  71. return JSON.stringify({
  72. class: classes,
  73. filters: filterObj,
  74. });
  75. }
  76. async function homeVod() {
  77. return '{}';
  78. }
  79. async function category(tid, pg, filter, extend) {
  80. if (pg <= 0) pg = 1;
  81. let link = url;
  82. if (tid.startsWith('sc_')) {
  83. link = link + '/search?q=' + encodeURIComponent(tid.substr(3)) + '&page=' + pg + '&size=16';
  84. } else {
  85. link = link + '/vodList?&tag=' + (extend.tag || tid) + '&page=' + pg + '&size=16';
  86. }
  87. const data = decrypt(JSON.parse(await request(link)).data);
  88. let videos = [];
  89. for (const vod of data.movies) {
  90. if (!vod.id) continue;
  91. videos.push({
  92. vod_id: vod.id,
  93. vod_name: vod.name,
  94. vod_pic: vod.thumb,
  95. vod_remarks: vod.views,
  96. });
  97. }
  98. return JSON.stringify({
  99. page: parseInt(data.page),
  100. pagecount: _.ceil(data.totals / 16),
  101. limit: 16,
  102. total: data.totals,
  103. list: videos,
  104. });
  105. }
  106. async function detail(id) {
  107. const link = url + '/vodDetail?id=' + id;
  108. const data = decrypt(JSON.parse(await request(link)).data).info;
  109. let desc = data.name + '\n';
  110. if (data.views) {
  111. desc += '观看次数:' + data.views + '\n';
  112. }
  113. let vod = {
  114. vod_id: id,
  115. vod_name: data.name,
  116. vod_pic: data.thumb,
  117. type_name: (data.tag || []).join(','),
  118. vod_year: data.date,
  119. vod_content: desc,
  120. };
  121. vod.vod_play_from = 'm3u8';
  122. let urls = [];
  123. if (data.m3u8) {
  124. urls.push('主力$' + data.m3u8);
  125. }
  126. if (data.m3u8bak) {
  127. urls.push('备用$' + data.m3u8bak);
  128. }
  129. vod.vod_play_url = urls.join('#');
  130. return JSON.stringify({
  131. list: [vod],
  132. });
  133. }
  134. async function proxy(segments, headers) {}
  135. async function play(flag, id, flags) {
  136. return JSON.stringify({
  137. parse: 0,
  138. url: id,
  139. });
  140. }
  141. async function search(wd, quick, pg) {
  142. let page = pg || 1;
  143. if (page == 0) page = 1;
  144. let videos = [];
  145. let link = url + '/search?q=' + encodeURIComponent(wd) + '&page=' + page + '&size=16';
  146. const data = decrypt(JSON.parse(await request(link)).data);
  147. for (const vod of data.movies) {
  148. if (!vod.id) continue;
  149. videos.push({
  150. vod_id: vod.id,
  151. vod_name: vod.name,
  152. vod_pic: vod.thumb,
  153. vod_remarks: vod.views,
  154. });
  155. }
  156. return JSON.stringify({
  157. page: parseInt(data.page),
  158. pagecount: _.ceil(data.totals / 16),
  159. land: 1,
  160. list: videos,
  161. });
  162. }
  163. function decrypt(content) {
  164. return JSON.parse(aesX('AES/CBC/PKCS7', false, content, true, 'F31F2A75FBF94099', '12345BCA901ER456', false));
  165. }
  166. function base64Encode(text) {
  167. return Crypto.enc.Base64.stringify(Crypto.enc.Utf8.parse(text));
  168. }
  169. function base64Decode(text) {
  170. return Crypto.enc.Utf8.stringify(Crypto.enc.Base64.parse(text));
  171. }
  172. export function __jsEvalReturn() {
  173. return {
  174. init: init,
  175. home: home,
  176. homeVod: homeVod,
  177. category: category,
  178. detail: detail,
  179. play: play,
  180. search: search,
  181. };
  182. }