nm_open.js 9.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240
  1. import { Crypto, load, _ } from './lib/cat.js';
  2. //let siteUrl = 'https://m.xiangdao.me';
  3. let siteUrl ='https://v.nmvod.cn';
  4. let siteKey = '';
  5. let siteType = 0;
  6. let headers = {
  7. 'User-Agent': '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',
  8. 'Referer': siteUrl + '/'
  9. };
  10. let jxUrl = ['https://api.cnmcom.com/webcloud/nmsvip.php?url=','https://api.cnmcom.com/webcloud/nmsssvip.php?vid=', 'https://api.cnmcom.com/webcloud/nmssvip.php?url=', 'https://api.cnmcom.com/webcloud/m3u8.php?url='];
  11. async function request(reqUrl, postData, post) {
  12. let res = await req(reqUrl, {
  13. method: post ? 'post' : 'get',
  14. headers: headers,
  15. data: postData || {},
  16. postType: post ? 'form' : '',
  17. });
  18. let content = res.content;
  19. return content;
  20. }
  21. async function init(cfg) {
  22. siteKey = cfg.skey;
  23. siteType = cfg.stype;
  24. if (cfg.ext) {
  25. siteUrl = cfg.ext;
  26. }
  27. }
  28. async function home(filter) {
  29. let classes = [{
  30. type_id: '1',
  31. type_name: '电影',
  32. },{
  33. type_id: '2',
  34. type_name: '剧集',
  35. },{
  36. type_id: '3',
  37. type_name: '综艺',
  38. },{
  39. type_id: '4',
  40. type_name: '动漫',
  41. },{
  42. type_id: '26',
  43. type_name: '短剧',
  44. }];
  45. let filterObj = genFilterObj();
  46. return JSON.stringify({
  47. class: classes,
  48. filters: filterObj
  49. });
  50. }
  51. async function homeVod() {
  52. let url = siteUrl;
  53. let videos = await getRecommend(url);
  54. return JSON.stringify({
  55. list: videos,
  56. });
  57. }
  58. async function category(tid, pg, filter, ext) {
  59. if (!pg) pg = 1;
  60. if (pg <= 0) pg = 1;
  61. let id = ext['id'] || tid;
  62. let year = ext['year'] || '';
  63. let area = ext['area'] || '';
  64. let url = siteUrl + '/index.php?m=vod-list-id-'+id+'-pg-'+pg+'-order--by-time-class-0-year-'+year+'-letter--area-'+area+'-lang-.html';
  65. let videos = await getVideos(url);
  66. return JSON.stringify({
  67. list: videos,
  68. page: pg,
  69. });
  70. }
  71. async function detail(id) {
  72. try {
  73. const html = await request(siteUrl + id);
  74. let $ = load(html);
  75. let content = $('article > p').text();
  76. let director = _.map($('section.page-bd > div:nth-child(2) > a'), (n) => {
  77. return $(n).text();
  78. }).join(' ');
  79. let actor = _.map($('section.page-bd > div:nth-child(3) > a'), (n) => {
  80. return $(n).text();
  81. }).join(' ');
  82. let play1Url = siteUrl + $('div.page-btn > span:nth-child(1) > a').attr('href');
  83. $ = load(await request(play1Url));
  84. let nameUrls = $('section.main > div > script:nth-child(1)').text().split("mac_url='")[1].split("';")[0];
  85. let playUrls = [];
  86. let playFroms = [];
  87. if($('div.hd > ul > li > a').text().indexOf('云播') >= 0) {
  88. playFroms.push('云播');
  89. playUrls.push(nameUrls.replaceAll('$', '$' + jxUrl[3]));
  90. } else {
  91. for(let i=1;i<=3;i++) {
  92. playFroms.push('线路' + i);
  93. playUrls.push(nameUrls.replaceAll('$', '$'+jxUrl[i-1]));
  94. }
  95. }
  96. const video = {
  97. vod_play_from: playFroms.join('$$$'),
  98. vod_play_url: playUrls.join('$$$'),
  99. vod_content: content,
  100. vod_director: director,
  101. vod_actor: actor,
  102. };
  103. const list = [video];
  104. const result = { list };
  105. return JSON.stringify(result);
  106. } catch (e) {
  107. console.log('err', e);
  108. }
  109. return null;
  110. }
  111. async function search(wd, quick, pg) {
  112. let url = siteUrl + '/index.php?m=vod-search';
  113. const html = await request(url, {wd: wd}, true);
  114. const $ = load(html);
  115. let data = $('#data_list > li');
  116. let videos = _.map(data, (n) => {
  117. let id = $($(n).find('div.pic > a')[0]).attr('href');
  118. let pic = $($(n).find('div.pic > a > img')[0]).attr('data-src');
  119. let name = $($(n).find(' span.sTit')[0]).text();
  120. return {
  121. vod_id: id,
  122. vod_name: name,
  123. vod_pic: pic,
  124. vod_remarks: '',
  125. };
  126. });
  127. return JSON.stringify({
  128. list: videos,
  129. });
  130. }
  131. async function play(flag, id, flags) {
  132. let playUrl = id;
  133. const html = await request(playUrl);
  134. const $ = load(html);
  135. for(const n of $('script')) {
  136. if($(n).text().indexOf("url: '") >= 0) {
  137. let url = $(n).text().split("url: '")[1].split("'")[0];
  138. if(url) {
  139. playUrl = url;
  140. }
  141. return JSON.stringify({
  142. parse: 0,
  143. url: playUrl,
  144. });
  145. }
  146. if($(n).text().indexOf("var url='") >= 0) {
  147. let url = $(n).text().split("var url='")[1].split("';")[0];
  148. if(url) {
  149. playUrl = url;
  150. }
  151. return JSON.stringify({
  152. parse: 0,
  153. url: playUrl,
  154. });
  155. }
  156. }
  157. return JSON.stringify({
  158. parse: 1,
  159. url: playUrl,
  160. });
  161. }
  162. function genFilterObj() {
  163. return {
  164. '1': [{'key': 'id', 'name': '类型', 'value': [{'n': '全部类型', 'v': '1'}, {'n': '动作', 'v': '5'}, {'n': '喜剧', 'v': '6'}, {'n': '爱情', 'v': '7'}, {'n': '科幻', 'v': '8'}, {'n': '恐怖', 'v': '9'}, {'n': '剧情', 'v': '10'}, {'n': '战争', 'v': '11'},{'n': '惊悚', 'v': '16'},{'n': '奇幻', 'v': '17'}]},
  165. {'key': 'area', 'name': '地区', 'value': [{'n': '全部地区', 'v': ''}, {'n': '大陆', 'v': '大陆'}, {'n': '香港', 'v': '香港'}, {'n': '台湾', 'v': '台湾'}, {'n': '美国', 'v': '美国'}, {'n': '韩国', 'v': '韩国'},{'n': '日本', 'v': '日本'}]},
  166. {'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'}, {'n': '2010', 'v': '2010'}]}
  167. ],
  168. '2': [{'key': 'id', 'name': '类型', 'value': [{'n': '全部类型', 'v': '2'}, {'n': '国产剧', 'v': '12'}, {'n': '港台剧', 'v': '13'},{'n': '日韩剧', 'v': '14'}, {'n': '欧美剧', 'v': '15'}]},
  169. {'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': '其他'}]},
  170. {'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'}, {'n': '2010', 'v': '2010'}, {'n': '2009', 'v': '2009'}, {'n': '2008', 'v': '2008'}, {'n': '2006', 'v': '2006'}, {'n': '2005', 'v': '2005'}]}
  171. ]
  172. };
  173. }
  174. async function getRecommend(url) {
  175. const html = await request(url);
  176. const $ = load(html);
  177. const cards = $('div > ul.resize_list > li:nth-child(2)')
  178. let videos = _.map(cards, (n) => {
  179. let id = $($(n).find('a')[0]).attr('href');
  180. let name = $($(n).find('a')[0]).attr('title');
  181. let pic = $($(n).find('img')[0]).attr('src');
  182. let remarks = $($(n).find('span.sBottom > span')[0]).text().trim().replaceAll('0.0', '');
  183. return {
  184. vod_id: id,
  185. vod_name: name,
  186. vod_pic: pic,
  187. vod_remarks: remarks,
  188. };
  189. });
  190. return videos;
  191. }
  192. async function getVideos(url) {
  193. const html = await request(url);
  194. const $ = load(html);
  195. const cards = $('div > ul.resize_list > li')
  196. let videos = _.map(cards, (n) => {
  197. let id = $($(n).find('a')[0]).attr('href');
  198. let name = $($(n).find('a')[0]).attr('title');
  199. let pic = $($(n).find('img')[0]).attr('src');
  200. let remarks = $($(n).find('span.sBottom > span > em')[0]).text().trim();
  201. return {
  202. vod_id: id,
  203. vod_name: name,
  204. vod_pic: pic,
  205. vod_remarks: remarks,
  206. };
  207. });
  208. return videos;
  209. }
  210. export function __jsEvalReturn() {
  211. return {
  212. init: init,
  213. home: home,
  214. homeVod: homeVod,
  215. category: category,
  216. detail: detail,
  217. play: play,
  218. search: search,
  219. };
  220. }