address comments

This commit is contained in:
Kendall Garner 2023-06-03 07:15:02 -07:00 committed by Jeff
parent 9eef570740
commit 85a10c799a
5 changed files with 29 additions and 21 deletions

View file

@ -2,12 +2,14 @@ import axios, { AxiosResponse } from 'axios';
import { load } from 'cheerio';
import type { QueueSong } from '/@/renderer/api/types';
const search_url = 'https://genius.com/api/search/song';
const SEARCH_URL = 'https://genius.com/api/search/song';
// Adapted from https://github.com/NyaomiDEV/Sunamu/blob/master/src/main/lyricproviders/genius.ts
async function getSongURL(metadata: QueueSong) {
let result: AxiosResponse<any, any>;
try {
result = await axios.get(search_url, {
result = await axios.get(SEARCH_URL, {
params: {
per_page: '1',
q: `${metadata.artistName} ${metadata.name}`,

View file

@ -4,6 +4,8 @@ import type { QueueSong } from '/@/renderer/api/types';
const SEARCH_URL = 'https://music.163.com/api/search/get';
const LYRICS_URL = 'https://music.163.com/api/song/lyric';
// Adapted from https://github.com/NyaomiDEV/Sunamu/blob/master/src/main/lyricproviders/netease.ts
async function getSongId(metadata: QueueSong) {
let result: AxiosResponse<any, any>;
try {

View file

@ -1,17 +1,17 @@
import { IpcRendererEvent, ipcRenderer } from 'electron';
import { QueueSong } from '/@/renderer/api/types';
const fetchLyrics = (song: QueueSong) => {
const fetchRemoteLyrics = (song: QueueSong) => {
ipcRenderer.send('lyric-fetch', song);
};
const getLyrics = (
const retrieveRemoteLyrics = (
cb: (event: IpcRendererEvent, songName: string, source: string, lyric: string) => void,
) => {
ipcRenderer.on('lyric-get', cb);
};
export const lyrics = {
fetchLyrics,
getLyrics,
fetchRemoteLyrics,
retrieveRemoteLyrics,
};