music_open.js 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. import { Crypto, load, _ } from './lib/cat.js';
  2. //let siteUrl = 'https://m.xiangdao.me';
  3. let siteUrl ='https://v.nmvod.cn/api.php';
  4. let siteKey = '';
  5. let siteType = 0;
  6. const MOBILE_UA = 'Mozilla/5.0 (Linux; Android 11; M2007J3SC Build/RKQ1.200826.002; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/77.0.3865.120 MQQBrowser/6.2 TBS/045714 Mobile Safari/537.36';
  7. let headers = {
  8. 'User-Agent': MOBILE_UA,
  9. 'Referer': siteUrl + '/'
  10. };
  11. 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='];
  12. async function request(reqUrl, postData) {
  13. let res = await req(reqUrl, {
  14. method: 'post',
  15. headers: headers,
  16. data: postData || {},
  17. postType: 'form',
  18. });
  19. let content = res.content;
  20. return content;
  21. }
  22. async function init(cfg) {
  23. siteKey = cfg.skey;
  24. siteType = cfg.stype;
  25. if (cfg.ext) {
  26. siteUrl = cfg.ext;
  27. }
  28. }
  29. async function home(filter) {
  30. let classes = [{
  31. type_id: '3778678',
  32. type_name: '热歌榜',
  33. },{
  34. type_id: '19723756',
  35. type_name: '飙升榜',
  36. },{
  37. type_id: '3779629',
  38. type_name: '新歌榜',
  39. },{
  40. type_id: '2884035',
  41. type_name: '原创歌曲榜',
  42. },{
  43. type_id: '5213356842',
  44. type_name: '新说唱热歌榜',
  45. },{
  46. type_id: '991319590',
  47. type_name: '说唱榜',
  48. },{
  49. type_id: '2250011882',
  50. type_name: '抖音排行榜',
  51. },{
  52. type_id: '745956260',
  53. type_name: '韩语榜',
  54. },{
  55. type_id: '2809513713',
  56. type_name: '欧美热歌榜',
  57. },{
  58. type_id: '2809577409',
  59. type_name: '欧美新歌榜',
  60. },{
  61. type_id: '5059644681',
  62. type_name: '日语榜',
  63. },{
  64. type_id: '3112516681',
  65. type_name: '中国新乡村音乐排行榜',
  66. }];
  67. return JSON.stringify({
  68. class: classes,
  69. });
  70. }
  71. async function homeVod() {
  72. }
  73. async function category(tid, pg, filter, ext) {
  74. let playList = JSON.parse(await request(siteUrl, {
  75. 'types': 'playlist',
  76. 'id': tid,
  77. })).playlist;
  78. let videos = _.map(playList.tracks, n => {
  79. return {
  80. vod_id: n.id,
  81. vod_name: n.name,
  82. vod_pic: n.al.picUrl,
  83. vod_remarks: n.ar[0].name
  84. }
  85. });
  86. return JSON.stringify({
  87. list: videos,
  88. page: pg,
  89. total: videos.length
  90. });
  91. }
  92. async function detail(id) {
  93. try {
  94. let playUrl = JSON.parse(await request(siteUrl, {
  95. 'types': 'url',
  96. 'id': id,
  97. 'source': 'netease',
  98. })).url;
  99. const video = {
  100. vod_play_from: 'Leospring',
  101. vod_play_url: playUrl,
  102. vod_content: '该作品由leospring采集分享,公众号【蚂蚁科技杂谈】,请勿传播分享,仅供技术学习使用,请在学习后24小时内删除;由此产生的任何法律风险自行承担,与本作者无关!',
  103. };
  104. const list = [video];
  105. const result = { list };
  106. return JSON.stringify(result);
  107. } catch (e) {
  108. console.log('err', e);
  109. }
  110. return null;
  111. }
  112. async function search(wd, quick, pg) {
  113. let playList = JSON.parse(await request(siteUrl, {
  114. 'types': 'search',
  115. 'name': wd,
  116. 'source':'netease',
  117. 'count': '20',
  118. 'pages': pg
  119. }));
  120. const js2Base = await js2Proxy(true, siteType, siteKey, 'img/', {});
  121. let videos = _.map(playList, n => {
  122. return {
  123. vod_id: n.id,
  124. vod_name: n.name,
  125. vod_pic: js2Base + base64Encode(n.pic_id),
  126. vod_remarks: ''
  127. }
  128. });
  129. return JSON.stringify({
  130. list: videos,
  131. page: pg,
  132. total: videos.length
  133. });
  134. }
  135. async function play(flag, id, flags) {
  136. return JSON.stringify({
  137. parse: 0,
  138. url: id,
  139. });
  140. }
  141. function base64Encode(text) {
  142. return Crypto.enc.Base64.stringify(Crypto.enc.Utf8.parse(text));
  143. }
  144. function base64Decode(text) {
  145. return Crypto.enc.Utf8.stringify(Crypto.enc.Base64.parse(text));
  146. }
  147. async function proxy(segments, headers) {
  148. let what = segments[0];
  149. let url = base64Decode(segments[1]);
  150. if (what == 'img') {
  151. let picUrl = JSON.parse(await request(siteUrl, {
  152. 'types': 'pic',
  153. 'id': url,
  154. 'source': 'netease',
  155. })).url
  156. var resp = await req(picUrl, {
  157. buffer: 2,
  158. headers: {
  159. Referer: 'https://api.douban.com/',
  160. 'User-Agent': MOBILE_UA,
  161. },
  162. });
  163. return JSON.stringify({
  164. code: resp.code,
  165. buffer: 2,
  166. content: resp.content,
  167. headers: resp.headers,
  168. });
  169. }
  170. return JSON.stringify({
  171. code: 500,
  172. content: '',
  173. });
  174. }
  175. export function __jsEvalReturn() {
  176. return {
  177. init: init,
  178. home: home,
  179. homeVod: homeVod,
  180. category: category,
  181. detail: detail,
  182. play: play,
  183. proxy: proxy,
  184. search: search,
  185. };
  186. }