Update lyric fetcher return types

This commit is contained in:
jeffvli 2023-06-05 02:42:25 -07:00 committed by Jeff
parent 007a099951
commit d38c846e80
5 changed files with 14 additions and 9 deletions

View File

@ -1,6 +1,7 @@
import axios, { AxiosResponse } from 'axios';
import { load } from 'cheerio';
import type { InternetProviderLyricResponse, QueueSong } from '/@/renderer/api/types';
import { LyricSource } from '../../../../renderer/types';
const SEARCH_URL = 'https://genius.com/api/search/song';
@ -8,7 +9,7 @@ const SEARCH_URL = 'https://genius.com/api/search/song';
interface GeniusResponse {
artist: string;
title: string;
name: string;
url: string;
}
@ -34,7 +35,7 @@ async function getSongURL(metadata: QueueSong): Promise<GeniusResponse | undefin
return {
artist: hit.artist_names,
title: hit.full_title,
name: hit.full_title,
url: hit.url,
};
}
@ -76,6 +77,7 @@ export async function query(metadata: QueueSong): Promise<InternetProviderLyricR
return {
artist: response.artist,
lyrics,
title: response.title,
name: response.name,
source: LyricSource.GENIUS,
};
}

View File

@ -1,5 +1,6 @@
import axios, { AxiosResponse } from 'axios';
import type { InternetProviderLyricResponse, QueueSong } from '/@/renderer/api/types';
import { LyricSource } from '../../../../renderer/types';
const SEARCH_URL = 'https://music.163.com/api/search/get';
const LYRICS_URL = 'https://music.163.com/api/song/lyric';
@ -9,7 +10,7 @@ const LYRICS_URL = 'https://music.163.com/api/song/lyric';
interface NetEaseResponse {
artist: string;
id: string;
title: string;
name: string;
}
async function getSongId(metadata: QueueSong): Promise<NetEaseResponse | undefined> {
@ -37,7 +38,7 @@ async function getSongId(metadata: QueueSong): Promise<NetEaseResponse | undefin
return {
artist,
id: song.id,
title: song.name,
name: song.name,
};
}
@ -75,6 +76,7 @@ export async function query(metadata: QueueSong): Promise<InternetProviderLyricR
return {
artist: response.artist,
lyrics,
title: response.title,
name: response.name,
source: LyricSource.NETEASE,
};
}

View File

@ -1032,7 +1032,8 @@ export type LyricsResponse = SynchronizedLyricsArray | string;
export type InternetProviderLyricResponse = {
artist: string;
lyrics: string;
title: string;
name: string;
source: string;
};
export type LyricOverride = Omit<InternetProviderLyricResponse, 'lyrics'>;

View File

@ -279,7 +279,7 @@ export const SynchronizedLyrics = ({
<>
<LyricLine
className="lyric-credit"
text={`(Matched as ${override.title} by ${override.artist})`}
text={`(Matched as ${override.name} by ${override.artist})`}
/>
<LyricSkip onClick={removeLyric} />
</>

View File

@ -37,7 +37,7 @@ export const UnsynchronizedLyrics = ({
<>
<LyricLine
className="lyric-credit"
text={`(Matched as ${override.title} by ${override.artist})`}
text={`(Matched as ${override.name} by ${override.artist})`}
/>
<LyricSkip onClick={onRemoveLyric} />
</>