zz123_book_open2.js 4.4 KB

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