nmys_open.js 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191
  1. import {
  2. Crypto, load, _
  3. }
  4. from 'assets://js/lib/cat.js';
  5. let key = '农民影视';
  6. let HOST = 'https://v.nmvod.cn';
  7. let siteKey = '';
  8. let siteType = 0;
  9. const MACURL = /mac_url\s*=\s*'([^']+)'/;
  10. const PLAYURL = /<video[^>]*src\s*=\s*"([^"]+)"[^>]*>/;
  11. 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';
  12. async function request(reqUrl, agentSp) {
  13. let res = await req(reqUrl, {
  14. method: 'get',
  15. headers: {
  16. 'User-Agent': agentSp || UA,
  17. 'Referer': HOST
  18. },
  19. });
  20. return res.content;
  21. }
  22. // cfg = {skey: siteKey, ext: extend}
  23. async function init(cfg) {
  24. siteKey = cfg.skey;
  25. siteType = cfg.stype;
  26. }
  27. async function home(filter) {
  28. let classes = [{
  29. 'type_id': '1',
  30. 'type_name': '电影'
  31. }, {
  32. 'type_id': '2',
  33. 'type_name': '电视剧'
  34. }, {
  35. 'type_id': '3',
  36. 'type_name': '综艺'
  37. }, {
  38. 'type_id': '4',
  39. 'type_name': '动漫'
  40. }, {
  41. 'type_id': '26',
  42. 'type_name': '短剧'
  43. }];
  44. let filterObj = {};
  45. return JSON.stringify({
  46. class: classes,
  47. filters: filterObj,
  48. });
  49. }
  50. async function homeVod() {}
  51. async function category(tid, pg, filter, extend) {
  52. const area = getFilterUrlPart(extend, 'area');
  53. const clazz = getFilterUrlPart(extend, 'class');
  54. const by = getFilterUrlPart(extend, 'by');
  55. const lang = getFilterUrlPart(extend, 'lang');
  56. const letter = getFilterUrlPart(extend, 'letter');
  57. const year = getFilterUrlPart(extend, 'year');
  58. const link = HOST + "/vod-list-id-"+tid+"-pg-"+pg+"-order--by-time-class-0-year-0-letter--area--lang-.html";
  59. const html = await request(link);
  60. const $ = load(html);
  61. const items = $('.globalPicList > .resize_list > li');
  62. let videos = _.map(items, (item) => {
  63. const $item = $(item);
  64. const it = $item.find('li > a:first')[0];
  65. return {
  66. vod_id: it.attribs.href,
  67. vod_name: it.attribs.title,
  68. vod_pic: $item.find('li > a > div.pic > img:first')[0].attribs.src,
  69. vod_remarks: '',
  70. };
  71. });
  72. return JSON.stringify({
  73. page: parseInt(pg),
  74. pagecount: 0,
  75. limit: 0,
  76. total: 0,
  77. list: videos,
  78. });
  79. }
  80. function getFilterUrlPart(extend, part) {
  81. let result = '';
  82. if (extend[part]) {
  83. result = '/' + part + '/' + extend[part];
  84. }
  85. return result;
  86. }
  87. async function detail(id) {
  88. const html = await request(HOST + id);
  89. const $ = load(html);
  90. const vod = {
  91. vod_id: id,
  92. vod_name: $('section.page-hd > a:first').attr('title').trim(),
  93. vod_pic: $('section.page-hd > a > img').attr('src'),
  94. vod_remarks: $('div.desc_item > font').text(),
  95. vod_content: '[关注公众号:影视资源站] ' + $('div.mod-box-5 > article > p').text(),
  96. };
  97. const playlists = $('div.numList > ul > li > a');
  98. vod.vod_play_from = '公众号|影视资源站';
  99. const playurl = [];
  100. _.each(playlists, (playlist) => {
  101. let item = $(playlist);
  102. let title = item.text();
  103. let url = item.attr('href');
  104. playurl.push(title +"$"+ url);
  105. });
  106. vod.vod_play_url = playurl.join('#');
  107. return JSON.stringify({
  108. list: [vod],
  109. });
  110. }
  111. async function play(flag, id, flags) {
  112. const link = HOST + id;
  113. let html = await request(link);
  114. let match = html.match(MACURL);
  115. let macUrl = match ? match[1] : null;
  116. let encUrl = macUrl.split("$")[1];
  117. let url = "https://api.cnmcom.com/webcloud/nmm.php?url=" + encUrl;
  118. html = await request(url);
  119. const $ = load(html);
  120. const lines = $('#lines > ul > a');
  121. const ids = [];
  122. _.map(lines, (line) => {
  123. let item = $(line);
  124. let id = item.attr('id');
  125. ids.push(id);
  126. });
  127. let palyUrl = "";
  128. for(const id of ids){
  129. try{
  130. console.debug(id);
  131. html = await request(id);
  132. match = html.match(PLAYURL);
  133. palyUrl = match ? match[1] : null;
  134. if(palyUrl.startsWith('http')) break;
  135. }catch(e){
  136. //TODO handle the exception
  137. console.debug(e);
  138. }
  139. }
  140. return JSON.stringify({
  141. parse: 0,
  142. url: palyUrl,
  143. header: {
  144. 'User-Agent': UA,
  145. },
  146. });
  147. }
  148. async function search(wd, quick) {
  149. let html = await request(HOST + '/index.php?m=vod-search&wd=' + wd);
  150. const $ = load(html);
  151. const items = $('ul#data_list > li');
  152. let videos = _.map(items, (item) => {
  153. const $item = $(item);
  154. const it = $item.find('div.pic > a:first')[0];
  155. return {
  156. vod_id: it.attribs.href,
  157. vod_name: $item.find('div.txt > span.sTit').text(),
  158. vod_pic: $(it).find('img').attr('data-src'),
  159. vod_remarks: '',
  160. };
  161. });
  162. return JSON.stringify({
  163. list: videos,
  164. });
  165. }
  166. export function __jsEvalReturn() {
  167. return {
  168. init: init,
  169. home: home,
  170. homeVod: homeVod,
  171. category: category,
  172. detail: detail,
  173. play: play,
  174. search: search,
  175. };
  176. }