mimiju_open.js 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. import { Crypto, load, _, jinja2 } from './lib/cat.js';
  2. let key = 'mimiju';
  3. let url = 'https://mimiju.com';
  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, agentSp) {
  8. let res = await req(reqUrl, {
  9. method: 'get',
  10. headers: {
  11. 'User-Agent': agentSp || UA,
  12. 'Referer': url
  13. },
  14. });
  15. return res.content;
  16. }
  17. // cfg = {skey: siteKey, ext: extend}
  18. async function init(cfg) {
  19. siteKey = cfg.skey;
  20. siteType = cfg.stype;
  21. }
  22. async function home(filter) {
  23. let classes = [{"type_id":20,"type_name":"短剧"}, {"type_id":21,"type_name":"电视剧"}];
  24. let filterObj = {
  25. "20": [{"key":"by","name":"排序","value":[{"n":"时间","v":"time"},{"n":"人气","v":"hits"},{"n":"评分","v":"score"}]}],
  26. "21": [{"key":"by","name":"排序","value":[{"n":"时间","v":"time"},{"n":"人气","v":"hits"},{"n":"评分","v":"score"}]}]};
  27. return JSON.stringify({
  28. class: classes,
  29. filters: filterObj,
  30. });
  31. }
  32. async function homeVod() {}
  33. async function category(tid, pg, filter, extend) {
  34. if (pg <= 0 || typeof(pg) == 'undefined') pg = 1;
  35. const link = url + '/vodshow/' + tid + '--' + (extend.by || 'time') + '---' + '---' + pg + '---' + '.html';//https://mimiju.com/vodshow/20--hits---------.html
  36. const html = await request(link);
  37. const $ = load(html);
  38. const items = $('ul.hl-vod-list > li');
  39. let videos = _.map(items, (item) => {
  40. const it = $(item).find('a:first')[0];
  41. const remarks = $($(item).find('span.hl-lc-1')[0]).text().trim();
  42. return {
  43. vod_id: it.attribs.href.replace(/.*?\/voddetail\/(.*).html/g, '$1'),
  44. vod_name: it.attribs.title,
  45. vod_pic: url + it.attribs['data-original'],
  46. vod_remarks: remarks || '',};
  47. });
  48. const hasMore = $('ul.hl-page-wrap > li > a >span:contains(下一页)').length > 0;
  49. const pgCount = hasMore ? parseInt(pg) + 1 : parseInt(pg);
  50. return JSON.stringify({
  51. page: parseInt(pg),
  52. pagecount: pgCount,
  53. limit: 20,
  54. total: 20 * pgCount,
  55. list: videos,
  56. });
  57. }
  58. async function detail(id) {
  59. var html = await request(url + '/voddetail/' + id + '.html');
  60. var $ = load(html);
  61. var vod = {
  62. vod_id: id,
  63. vod_name: $('h1:first').text().trim(),
  64. vod_type: $('.stui-content__detail p:first a').text(),
  65. vod_actor: $('.stui-content__detail p:nth-child(3)').text().replace('主演:', ''),
  66. vod_pic: $('.stui-content__thumb img:first').attr('data-original'),
  67. vod_remarks: $('.stui-content__detail p:nth-child(5)').text() || '',
  68. vod_content: $('span.detail-content').text().trim(),
  69. };
  70. var playMap = {};
  71. var tabs = $('ul.hl-from-list > li >span');
  72. var playlists = $('ul#hl-plays-list');
  73. _.each(tabs, (tab, i) => {
  74. var from = tab.children[0].data;
  75. var list = playlists[i];
  76. list = $(list).find('a');
  77. _.each(list, (it) => {
  78. var title = it.children[0].data;
  79. var playUrl = it.attribs.href.replace(/\/vodplay\/(.*).html/g, '$1');
  80. if (!playMap.hasOwnProperty(from)) {
  81. playMap[from] = [];
  82. }
  83. playMap[from].push(title + '$' + playUrl);
  84. });
  85. });
  86. vod.vod_play_from = _.keys(playMap).join('$$$');
  87. var urls = _.values(playMap);
  88. var vod_play_url = _.map(urls, (urlist) => {
  89. return urlist.join('#');
  90. });
  91. vod.vod_play_url = vod_play_url.join('$$$');
  92. return JSON.stringify({
  93. list: [vod],
  94. });
  95. }
  96. async function play(flag, id, flags) {
  97. const link = url + '/vodplay/' + id + '.html';
  98. const html = await request(link);
  99. const $ = load(html);
  100. const js = JSON.parse($('script:contains(player_a)').html().replace('var player_aaaa=', ''));
  101. const playUrl = js.url;
  102. return JSON.stringify({
  103. parse: 0,
  104. url: playUrl,
  105. });
  106. }
  107. async function search(wd, quick) {
  108. let data = JSON.parse(await request(url + '/index.php/ajax/suggest?mid=1&wd=' + wd)).list;
  109. let videos = [];
  110. for (const vod of data) {
  111. videos.push({
  112. vod_id: vod.id,
  113. vod_name: vod.name,
  114. vod_pic: vod.pic,
  115. vod_remarks: '',
  116. });
  117. }
  118. return JSON.stringify({
  119. list: videos,
  120. });
  121. }
  122. export function __jsEvalReturn() {
  123. return {
  124. init: init,
  125. home: home,
  126. homeVod: homeVod,
  127. category: category,
  128. detail: detail,
  129. play: play,
  130. search: search,
  131. };
  132. }