zzmusic_open.js 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  1. import { Crypto, load, _ } from './lib/cat.js';
  2. //代理地址
  3. let siteUrl = 'https://gh.7761.cf/https://zz123.com';
  4. let imgUrl = 'https://music.jsbaidu.com';
  5. let siteKey = '';
  6. let siteType = 0;
  7. let headers = {};
  8. async function request(reqUrl, postData, agentSp, get) {
  9. let res = await req(reqUrl, {
  10. method: get ? 'get' : 'post',
  11. headers: headers,
  12. data: postData || {},
  13. postType: get ? '' : 'form',
  14. });
  15. let content = res.content;
  16. return content;
  17. }
  18. async function init(cfg) {
  19. siteKey = cfg.skey;
  20. siteType = cfg.stype;
  21. if (cfg.ext) {
  22. siteUrl = cfg.ext;
  23. }
  24. }
  25. async function home(filter) {
  26. const html = await request(siteUrl);
  27. const $ = load(html);
  28. const cates = $('ul.aside-menu-list.channel > li')
  29. let classes = _.map(cates, (n) => {
  30. let id = n.attribs['data-id'];
  31. let name = $($(n).find('a > span')[0]).text();
  32. return {
  33. type_id: id,
  34. type_name: name
  35. };
  36. });
  37. return JSON.stringify({
  38. class: classes
  39. });
  40. }
  41. async function homeVod() {
  42. const html = await request(siteUrl);
  43. const $ = load(html);
  44. const cards = $('div.page-main-wrap > div > div > div.card-list.d-none.d-md-block > div');
  45. let videos = _.map(cards, (n) => {
  46. let id = n.attribs['data-id'];
  47. let name = $($(n).find('div.item-info > div > div.songname.text-ellipsis.color-link-content-primary > a')[0]).text();
  48. let pic = $($(n).find('div.item-cover-wrap > a > img')[0]).attr('data-src').replace('/img', imgUrl);
  49. let remark = $($(n).find('div.item-cover-wrap > div.item-time')[0]).text();
  50. return {
  51. vod_id: id,
  52. vod_name: name,
  53. vod_pic: pic,
  54. vod_remarks: remark
  55. };
  56. });
  57. return JSON.stringify({
  58. list: videos
  59. });
  60. }
  61. async function category(tid, pg, filter, extend) {
  62. if (pg <= 0) pg = 1;
  63. let url = siteUrl + '/ajax/';
  64. let res = await req(url, {
  65. method: 'post',
  66. data: {
  67. act: 'tag_music',
  68. type: 'tuijian',
  69. tid: tid,
  70. page: pg,
  71. lang: ''
  72. },
  73. postType: 'form'
  74. });
  75. //console.log('catedata:', res);
  76. let data = JSON.parse(res.content).data;
  77. let videos = [];
  78. for(let i=0;i<data.length;i++){
  79. const item = data[i];
  80. videos.push({
  81. vod_id: item['mp3'],
  82. vod_name: item['mname'],
  83. vod_pic: item['pic'].replace('/img', imgUrl),
  84. vod_remarks: item['play_time']
  85. })
  86. }
  87. return JSON.stringify({
  88. list: videos
  89. });
  90. }
  91. async function detail(id) {
  92. try {
  93. let playUrl = id;
  94. if(!id.startsWith('http')) {
  95. playUrl = siteUrl + '/xplay/?act=songplay&id=' + id;
  96. }
  97. const video = {
  98. vod_id: id,
  99. vod_actor: 'Leospring',
  100. vod_play_from: 'Leospring',
  101. vod_play_url: '播放$' + playUrl,
  102. vod_director: 'Leospring',
  103. vod_content: '该音乐由公众号【蚂蚁科技杂谈】用爱发电制作,欢迎收听!',
  104. };
  105. const list = [video];
  106. const result = { list };
  107. return JSON.stringify(result);
  108. } catch (e) {}
  109. return null;
  110. }
  111. async function play(flag, id, flags) {
  112. return JSON.stringify({
  113. parse: 0,
  114. url: id,
  115. });
  116. }
  117. async function search(wd, quick, pg) {
  118. let url = siteUrl + '/search/?key=' + wd;
  119. const html = await request(url);
  120. const $ = load(html);
  121. const cards = $('div.tab-item.tab-song > div.card-list.d-none.d-md-block > div')
  122. let videos = _.map(cards, (n) => {
  123. let id = n.attribs['data-id'];
  124. let name = $($(n).find('div.item-info > div > div.songname.text-ellipsis.color-link-content-primary > a')[0]).text();
  125. let pic = $($(n).find('div.item-cover-wrap > a > img')[0]).attr('data-src').replace('/img', imgUrl);
  126. let remark = $($(n).find('div.item-cover-wrap > div.item-time')[0]).text();
  127. return {
  128. vod_id: id,
  129. vod_name: name,
  130. vod_pic: pic,
  131. vod_remarks: remark,
  132. };
  133. });
  134. return JSON.stringify({
  135. list: videos,
  136. });
  137. }
  138. export function __jsEvalReturn() {
  139. return {
  140. init: init,
  141. home: home,
  142. homeVod: homeVod,
  143. category: category,
  144. detail: detail,
  145. play: play,
  146. search: search,
  147. };
  148. }