mgys_open2.js 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. import { Crypto, load, _ } from './lib/cat.js';
  2. let key = 'mgys';
  3. let HOST = 'https://www.moguys.xyz';
  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, timeout = 60000) {
  8. let res = await req(reqUrl, {
  9. method: 'get',
  10. headers: {
  11. 'User-Agent': UA,
  12. 'Referer': HOST
  13. },
  14. timeout: timeout,
  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. }
  23. async function home(filter) {
  24. let classes = [{"type_id":"1","type_name":"电影"},{"type_id":"2","type_name":"电视剧"},{"type_id":"3","type_name":"动漫"},{"type_id":"4","type_name":"综艺"}];
  25. let filterObj = {
  26. "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":"悬疑"},{"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":"其他"}]},{"key":"year","name":"年份","init":"","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"},{"n":"2010","v":"2010"}]},{"key":"lang","name":"语言","init":"","value":[{"n":"全部","v":""},{"n":"国语","v":"国语"},{"n":"英语","v":"英语"},{"n":"粤语","v":"粤语"},{"n":"闽南语","v":"闽南语"},{"n":"韩语","v":"韩语"},{"n":"日语","v":"日语"},{"n":"法语","v":"法语"},{"n":"德语","v":"德语"},{"n":"其它","v":"其它"}]},{"key":"by","name":"排序","init":"","value":[{"n":"时间","v":"time"},{"n":"人气","v":"hits"},{"n":"评分","v":"score"}]}],
  27. "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":"冒险"},{"n":"犯罪","v":"犯罪"}]},{"key":"area","name":"地区","init":"","value":[{"n":"全部","v":""},{"n":"大陆","v":"大陆"},{"n":"韩国","v":"韩国"},{"n":"美国","v":"美国"}]},{"key":"year","name":"年份","init":"","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"}]},{"key":"lang","name":"语言","init":"","value":[{"n":"全部","v":""},{"n":"国语","v":"国语"},{"n":"英语","v":"英语"},{"n":"粤语","v":"粤语"},{"n":"闽南语","v":"闽南语"},{"n":"韩语","v":"韩语"},{"n":"日语","v":"日语"},{"n":"其它","v":"其它"}]},{"key":"by","name":"排序","init":"","value":[{"n":"时间","v":"time"},{"n":"人气","v":"hits"},{"n":"评分","v":"score"}]}],
  28. "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":"财经"},{"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":"其他"}]},{"key":"year","name":"年份","init":"","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"}]},{"key":"lang","name":"语言","init":"","value":[{"n":"全部","v":""},{"n":"国语","v":"国语"},{"n":"英语","v":"英语"},{"n":"粤语","v":"粤语"},{"n":"闽南语","v":"闽南语"},{"n":"韩语","v":"韩语"},{"n":"日语","v":"日语"},{"n":"其它","v":"其它"}]},{"key":"by","name":"排序","init":"","value":[{"n":"时间","v":"time"},{"n":"人气","v":"hits"},{"n":"评分","v":"score"}]}],
  29. "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":"战争"},{"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":"其他"}]},{"key":"year","name":"年份","init":"","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"}]},{"key":"lang","name":"语言","init":"","value":[{"n":"全部","v":""},{"n":"国语","v":"国语"},{"n":"英语","v":"英语"},{"n":"粤语","v":"粤语"},{"n":"闽南语","v":"闽南语"},{"n":"韩语","v":"韩语"},{"n":"日语","v":"日语"},{"n":"其它","v":"其它"}]},{"key":"by","name":"排序","init":"","value":[{"n":"时间","v":"time"},{"n":"人气","v":"hits"},{"n":"评分","v":"score"}]}]
  30. };
  31. return JSON.stringify({
  32. class: classes,
  33. filters: filterObj,
  34. });
  35. }
  36. async function homeVod() {}
  37. async function category(tid, pg, filter, extend) {
  38. if (pg <= 0) pg = 1;
  39. let page = '';
  40. if (pg > 1) {
  41. page = pg;
  42. }
  43. const link = HOST + '/vodshow/' + tid + '-' + (extend.area || '') + '-' + (extend.by || '') + '-' + (extend.class || '') + '-' + (extend.lang || '') + '----' + page + '---' + (extend.year || '') + '.html';//https://www.moguys.xyz/vodshow/1-%E5%A4%A7%E9%99%86-time-%E5%8A%A8%E4%BD%9C-%E5%9B%BD%E8%AF%AD----2---2023.html
  44. const html = await request(link);
  45. const $ = load(html);
  46. const items = $('.leo-video-item');
  47. let videos = _.map(items, (item) => {
  48. const it = $(item).find('a:first')[0];
  49. const img = $(item).find('img:first')[0];
  50. const remarks = $($(item).find('div.leo-video-remark')[0]).text().trim();
  51. return {
  52. vod_id: it.attribs.href.replace(/.*?\/voddetail\/(.*).html/g, '$1'),
  53. vod_name: it.attribs.title,
  54. vod_pic: img.attribs['data-original'],
  55. vod_remarks: remarks || '',
  56. };
  57. });
  58. const hasMore = $('a.leo-page-elem:contains(下一页)').length > 0;
  59. const pgCount = hasMore ? parseInt(pg) + 1 : parseInt(pg);
  60. return JSON.stringify({
  61. page: parseInt(pg),
  62. pagecount: pgCount,
  63. limit: 24,
  64. total: 24 * pgCount,
  65. list: videos,
  66. });
  67. }
  68. async function detail(id) {
  69. const html = await request(HOST + '/voddetail/' + id + '.html');
  70. const $ = load(html);
  71. const vod = {
  72. vod_id: id,
  73. vod_name: $('font.leo-col-6').text(),
  74. vod_type: $('.leo-detail-media li:contains(分类:) a:eq(1)').text().trim(),
  75. vod_year: $('.leo-detail-media li:contains(年代:) a:first').text().trim(),
  76. vod_area: $('.leo-detail-media li:contains(地区:) a:first').text().trim(),
  77. vod_director: $('.leo-detail-media li:contains(导演:)').text().trim().substring(3),
  78. vod_actor: $('.leo-detail-media li:contains(主演:)').text().trim().substring(3),
  79. vod_pic: $('.leo-detail-cover').attr('data-original'),
  80. vod_remarks : $('.leo-detail-media h1:first').text().split('|')[1] || '',
  81. vod_content: $('#leo-detail-info').text().trim().substring(5).trim(),
  82. };
  83. let playMap = {};
  84. let tabs = $('.leo-source-cho li');
  85. let playlists = $('.leo-play-num');
  86. _.each(tabs, (tab, i) => {
  87. let from = tab.children[1].data;
  88. let list = playlists[i];
  89. list = $(list).find('a');
  90. _.each(list, (it) => {
  91. let title = 'HD';
  92. if (it.children.length > 0) {
  93. title = it.children[0].data.trim();
  94. }
  95. let playUrl = it.attribs.href.replace(/.*?\/vodplay\/(.*).html/g, '$1');
  96. if (!playMap.hasOwnProperty(from)) {
  97. playMap[from] = [];
  98. }
  99. playMap[from].push(title + '$' + playUrl);
  100. });
  101. });
  102. vod.vod_play_from = _.keys(playMap).join('$$$');
  103. let urls = _.values(playMap);
  104. let vod_play_url = _.map(urls, (urlist) => {
  105. return urlist.join('#');
  106. });
  107. vod.vod_play_url = vod_play_url.join('$$$');
  108. return JSON.stringify({
  109. list: [vod],
  110. });
  111. }
  112. async function play(flag, id, flags) {
  113. const link = HOST + '/vodplay/' + id + '.html';
  114. const html = await request(link);
  115. const $ = load(html);
  116. let json = $('script:contains(player_aaaa)').text().replace('var player_aaaa=','');
  117. let js = JSON.parse(json);
  118. let playUrl = js.url;
  119. if (js.encrypt == 1) {
  120. playUrl = unescape(playUrl);
  121. } else if (js.encrypt == 2) {
  122. playUrl = unescape(base64Decode(playUrl));
  123. }
  124. let playHtml = await request('https://player.moguys.work/player/ec.php?code=pl&if=1&url=' + playUrl);
  125. json = playHtml.match(/let ConFig = {([\w\W]*)},box/)[1];
  126. const jsConfig = JSON.parse('{' + json.trim() + '}');
  127. playUrl = decryptUrl(jsConfig);
  128. return JSON.stringify({
  129. parse: 0,
  130. url: playUrl,
  131. header: {
  132. 'User-Agent': UA,
  133. }
  134. });
  135. }
  136. function decryptUrl(jsConfig) {
  137. const key = Crypto.enc.Utf8.parse('2890' + jsConfig.config.uid + 'tB959C');
  138. const iv = Crypto.enc.Utf8.parse('2F131BE91247866E');
  139. const mode = Crypto.mode.CBC;
  140. const padding = Crypto.pad.Pkcs7;
  141. const decrypted = Crypto.AES.decrypt(jsConfig.url, key, {
  142. 'iv': iv,
  143. 'mode': mode,
  144. 'padding': padding
  145. });
  146. const decryptedUrl = Crypto.enc.Utf8.stringify(decrypted);
  147. return decryptedUrl;
  148. }
  149. function base64Decode(text) {
  150. return Crypto.enc.Utf8.stringify(Crypto.enc.Base64.parse(text));
  151. }
  152. async function search(wd, quick, pg) {
  153. let data = JSON.parse(await request(HOST + '/index.php/ajax/suggest?mid=1&limit=50&wd=' + wd)).list;
  154. let videos = [];
  155. for (const vod of data) {
  156. videos.push({
  157. vod_id: vod.id,
  158. vod_name: vod.name,
  159. vod_pic: vod.pic,
  160. vod_remarks: '',
  161. });
  162. }
  163. return JSON.stringify({
  164. list: videos,
  165. });
  166. }
  167. export function __jsEvalReturn() {
  168. return {
  169. init: init,
  170. home: home,
  171. homeVod: homeVod,
  172. category: category,
  173. detail: detail,
  174. play: play,
  175. search: search,
  176. };
  177. }