freeMusic_open.js 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235
  1. import { Crypto, load, _ } from './lib/cat.js';
  2. let siteKey = '';
  3. let siteType = 0;
  4. let headers = {
  5. 'Content-Type': 'application/json',
  6. 'origin': 'https://tool.liumingye.cn',
  7. 'User-Agent': 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/116.0.0.0 Safari/537.36'
  8. };
  9. async function request(reqUrl, postData, get) {
  10. let res = await req(reqUrl, {
  11. method: get ? 'get' : 'post',
  12. headers: headers,
  13. data: postData || {},
  14. });
  15. let content = res.content;
  16. return content;
  17. }
  18. async function init(cfg) {
  19. siteKey = cfg.skey;
  20. siteType = cfg.stype;
  21. }
  22. async function home(filter) {
  23. const classes = [{
  24. type_id: '1',
  25. type_name: '歌手'
  26. }];
  27. let filters = [];
  28. for(let i=0;i<=27;i++) {
  29. let name = String.fromCodePoint(i+64);
  30. if(i <= 0) name = '热门';
  31. if(i >= 27) name = '#';
  32. filters.push({
  33. 'v': String(i),
  34. 'n': name
  35. })
  36. }
  37. return JSON.stringify({
  38. class: classes,
  39. filters: {
  40. '1': [
  41. {
  42. 'key': 'word',
  43. 'name': '首字母',
  44. 'value': filters
  45. }
  46. ]
  47. }
  48. });
  49. }
  50. async function homeVod() {
  51. }
  52. async function category(tid, pg, filter, extend) {
  53. if(!pg || pg <=0) pg = 1;
  54. let url = 'https://api.liumingye.cn/m/api/artist/list';
  55. let param = {
  56. 'initial': extend['word'],
  57. 'page': pg,
  58. '_t': new Date().getTime()
  59. }
  60. param['token'] = genToken(param);
  61. let data = JSON.parse(await request(url, param)).data;
  62. let videos = [];
  63. for (const vod of data.list) {
  64. videos.push({
  65. vod_id: vod.name,
  66. vod_name: vod.name,
  67. vod_pic: vod.pic,
  68. vod_remarks: ``,
  69. });
  70. }
  71. return JSON.stringify({
  72. list: videos,
  73. page: pg,
  74. limit: 20,
  75. });
  76. }
  77. async function searchSongs(name,pg){
  78. if (!pg || pg <=0) pg = 1;
  79. let params = {
  80. "type":"YQM",
  81. "text":name,
  82. "page":pg,
  83. "v":"beta",
  84. "_t": new Date().getTime()
  85. }
  86. let token = genToken(params);
  87. params['token'] = token;
  88. let data = JSON.parse(await request('https://api.liumingye.cn/m/api/search', params)).data;
  89. //console.log(data);
  90. let videos = [];
  91. for (const vod of data.list) {
  92. if (vod.hash) {
  93. videos.push({
  94. vod_id: vod.hash,
  95. vod_name: vod.name,
  96. vod_pic: vod.pic || '',
  97. vod_remarks: `${Math.floor(vod.time/60)}:${vod.time % 60}`,
  98. });
  99. }
  100. }
  101. return videos;
  102. }
  103. async function detail(id) {
  104. try {
  105. let list1 = await searchSongs(id, 1);
  106. let list2 = await searchSongs(id, 2);
  107. let list3 = await searchSongs(id, 3);
  108. let videos = list1.concat(list2).concat(list3);
  109. let vod = {
  110. vod_id: id,
  111. vod_name: id,
  112. vod_play_from: 'Leospring',
  113. vod_content: '该影视由leospring采集分享,公众号【蚂蚁科技杂谈】,请勿传播分享,仅供技术学习使用,请在学习后24小时内删除;由此产生的任何法律风险自行承担,与本作者无关!',
  114. };
  115. vod.vod_play_url = _.map(videos, item => {
  116. return item.vod_name + '$' + item.vod_id;
  117. }).join('#');
  118. return JSON.stringify({
  119. list: [vod],
  120. });
  121. } catch (e) {
  122. console.log('err', e);
  123. }
  124. return null;
  125. }
  126. async function search(wd, quick, pg) {
  127. let videos = await searchSongs(wd, pg);
  128. return JSON.stringify({
  129. list: videos,
  130. });
  131. }
  132. async function play(flag, id, flags) {
  133. let url = getMp3(id);
  134. return JSON.stringify({
  135. parse: 0,
  136. url: url,
  137. });
  138. }
  139. function base64Encode(text) {
  140. return Crypto.enc.Base64.stringify(Crypto.enc.Utf8.parse(text));
  141. }
  142. function base64Decode(text) {
  143. return Crypto.enc.Utf8.stringify(Crypto.enc.Base64.parse(text));
  144. }
  145. const Es = "pW8jg/mke6cO1F4CTuaiswhZfQGzMyq5NJRLPVIvDxlA7=E3YrSUoH0b2BXKn9td+";
  146. const t= 'yGz4n9XE9xYy2Oj5Ub7E6u9a5p5aIWZYe53Orq5wE5UgnjbWq0410WTvmLBO1Z2N';
  147. function Bs(ee){
  148. let f=0,h='';
  149. do{
  150. let s=ee[f++],
  151. o=ee[f++],
  152. i=ee[f++],
  153. u=(s << 16 | o << 8) | i,
  154. a = ((u >> 18) & 63),
  155. l = (u >> 12) & 63,
  156. r = 63 & (u >> 6),
  157. c = (u & 63);
  158. h += (Es.charAt(a)+ Es.charAt(l)) + Es.charAt(r) + Es.charAt(c);
  159. } while(f<ee.length);
  160. if(ee.length % 3) {
  161. h = h.substring(0, h.length-2) + '==';
  162. }
  163. return h;
  164. }
  165. function genToken(data) {
  166. let res = encodeURIComponent(JSON.stringify(data));
  167. let arr = [];
  168. for(let i=0;i<res.length;i++) {
  169. arr[i] = res.charCodeAt(i) ^ t.charCodeAt(i%64);
  170. }
  171. return '20230327.' + md5X(Bs(arr));
  172. }
  173. async function getArtist(idx, pg) {
  174. if (!idx) idx = 0;
  175. if(!pg || pg <=0) pg = 1;
  176. let url = 'https://api.liumingye.cn/m/api/artist/list';
  177. let param = {
  178. 'initial': idx,
  179. 'page': pg,
  180. '_t': new Date().getTime()
  181. }
  182. param['token'] = genToken(param);
  183. let res = await request(url, param);
  184. console.log(res);
  185. }
  186. function getMp3(musicId) {
  187. let data = {
  188. id: musicId,
  189. quality: "128",
  190. _t: new Date().getTime()
  191. }
  192. let token = genToken(data);
  193. let url = `https://api.liumingye.cn/m/api/link?id=${data.id}&quality=${data.quality}&_t=${data._t}&token=${token}`
  194. //console.log(url);
  195. return url;
  196. }
  197. async function test() {
  198. //let res1 = await getMp3('m3f63OtUGNZoMDio1KqpStTc4npCYJPkofC76iVM7dWSL0qjZFeLha7Iv3BrPcpM');
  199. // let params1 = {"type":"YQM","text":"薛之谦","page":1,"v":"beta","_t":1708244430941,"token":"20230327.de4de6cd4fc6fb7420ef820ce0078974"}
  200. let res = await searchSongs('薛之谦', 1);
  201. await getArtist();
  202. }
  203. export function __jsEvalReturn() {
  204. return {
  205. init: init,
  206. home: home,
  207. homeVod: homeVod,
  208. category: category,
  209. detail: detail,
  210. play: play,
  211. search: search,
  212. //test: test,
  213. };
  214. }