index.ts 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. import axios from "axios";
  2. import { load } from "cheerio";
  3. async function search(query, page, type){
  4. if (type !== 'lyric') {
  5. return;
  6. }
  7. const result = (await axios.get('https://so.lrcgc.com/', {
  8. params: {
  9. q: query,
  10. }
  11. })).data;
  12. const $ = load(result);
  13. const results = $('.resultWrap').children();
  14. const data = [];
  15. if (results.first().prop('tagName') === 'DL') {
  16. const title = results.first().find('dt > a');
  17. const desc = results.first().find('dd > small');
  18. const descText = desc.text().replace(/[\s|\n]/g, '').split(/[歌手:|专辑:]/).filter(it => it.trim() !== '');
  19. data.push({
  20. title: title.text(),
  21. id: title.attr('href'),
  22. artist: descText?.[0],
  23. album: descText?.[1]
  24. })
  25. }
  26. return {
  27. isEnd: true,
  28. data
  29. }
  30. }
  31. async function getLyric(musicItem) {
  32. const res = (await axios.get(musicItem.id)).data;
  33. const $ = load(res);
  34. const rawLrc = $('p#J_lyric').text().replace(/\n/g, '');
  35. return {
  36. rawLrc: rawLrc,
  37. };
  38. }
  39. module.exports = {
  40. platform: "歌词千寻",
  41. version: "0.0.0",
  42. srcUrl: 'https://gitee.com/maotoumao/MusicFreePlugins/raw/v0.1/dist/geciqianxun/index.js',
  43. cacheControl: "no-store",
  44. supportedSearchType: ['lyric'],
  45. search,
  46. getLyric
  47. };