liumingye_music_open.js 5.6 KB

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