Update lyric fetcher return types
This commit is contained in:
parent
007a099951
commit
d38c846e80
5 changed files with 14 additions and 9 deletions
|
@ -1,6 +1,7 @@
|
||||||
import axios, { AxiosResponse } from 'axios';
|
import axios, { AxiosResponse } from 'axios';
|
||||||
import { load } from 'cheerio';
|
import { load } from 'cheerio';
|
||||||
import type { InternetProviderLyricResponse, QueueSong } from '/@/renderer/api/types';
|
import type { InternetProviderLyricResponse, QueueSong } from '/@/renderer/api/types';
|
||||||
|
import { LyricSource } from '../../../../renderer/types';
|
||||||
|
|
||||||
const SEARCH_URL = 'https://genius.com/api/search/song';
|
const SEARCH_URL = 'https://genius.com/api/search/song';
|
||||||
|
|
||||||
|
@ -8,7 +9,7 @@ const SEARCH_URL = 'https://genius.com/api/search/song';
|
||||||
|
|
||||||
interface GeniusResponse {
|
interface GeniusResponse {
|
||||||
artist: string;
|
artist: string;
|
||||||
title: string;
|
name: string;
|
||||||
url: string;
|
url: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,7 +35,7 @@ async function getSongURL(metadata: QueueSong): Promise<GeniusResponse | undefin
|
||||||
|
|
||||||
return {
|
return {
|
||||||
artist: hit.artist_names,
|
artist: hit.artist_names,
|
||||||
title: hit.full_title,
|
name: hit.full_title,
|
||||||
url: hit.url,
|
url: hit.url,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
@ -76,6 +77,7 @@ export async function query(metadata: QueueSong): Promise<InternetProviderLyricR
|
||||||
return {
|
return {
|
||||||
artist: response.artist,
|
artist: response.artist,
|
||||||
lyrics,
|
lyrics,
|
||||||
title: response.title,
|
name: response.name,
|
||||||
|
source: LyricSource.GENIUS,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
import axios, { AxiosResponse } from 'axios';
|
import axios, { AxiosResponse } from 'axios';
|
||||||
import type { InternetProviderLyricResponse, QueueSong } from '/@/renderer/api/types';
|
import type { InternetProviderLyricResponse, QueueSong } from '/@/renderer/api/types';
|
||||||
|
import { LyricSource } from '../../../../renderer/types';
|
||||||
|
|
||||||
const SEARCH_URL = 'https://music.163.com/api/search/get';
|
const SEARCH_URL = 'https://music.163.com/api/search/get';
|
||||||
const LYRICS_URL = 'https://music.163.com/api/song/lyric';
|
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 {
|
interface NetEaseResponse {
|
||||||
artist: string;
|
artist: string;
|
||||||
id: string;
|
id: string;
|
||||||
title: string;
|
name: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getSongId(metadata: QueueSong): Promise<NetEaseResponse | undefined> {
|
async function getSongId(metadata: QueueSong): Promise<NetEaseResponse | undefined> {
|
||||||
|
@ -37,7 +38,7 @@ async function getSongId(metadata: QueueSong): Promise<NetEaseResponse | undefin
|
||||||
return {
|
return {
|
||||||
artist,
|
artist,
|
||||||
id: song.id,
|
id: song.id,
|
||||||
title: song.name,
|
name: song.name,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -75,6 +76,7 @@ export async function query(metadata: QueueSong): Promise<InternetProviderLyricR
|
||||||
return {
|
return {
|
||||||
artist: response.artist,
|
artist: response.artist,
|
||||||
lyrics,
|
lyrics,
|
||||||
title: response.title,
|
name: response.name,
|
||||||
|
source: LyricSource.NETEASE,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
@ -1032,7 +1032,8 @@ export type LyricsResponse = SynchronizedLyricsArray | string;
|
||||||
export type InternetProviderLyricResponse = {
|
export type InternetProviderLyricResponse = {
|
||||||
artist: string;
|
artist: string;
|
||||||
lyrics: string;
|
lyrics: string;
|
||||||
title: string;
|
name: string;
|
||||||
|
source: string;
|
||||||
};
|
};
|
||||||
|
|
||||||
export type LyricOverride = Omit<InternetProviderLyricResponse, 'lyrics'>;
|
export type LyricOverride = Omit<InternetProviderLyricResponse, 'lyrics'>;
|
||||||
|
|
|
@ -279,7 +279,7 @@ export const SynchronizedLyrics = ({
|
||||||
<>
|
<>
|
||||||
<LyricLine
|
<LyricLine
|
||||||
className="lyric-credit"
|
className="lyric-credit"
|
||||||
text={`(Matched as ${override.title} by ${override.artist})`}
|
text={`(Matched as ${override.name} by ${override.artist})`}
|
||||||
/>
|
/>
|
||||||
<LyricSkip onClick={removeLyric} />
|
<LyricSkip onClick={removeLyric} />
|
||||||
</>
|
</>
|
||||||
|
|
|
@ -37,7 +37,7 @@ export const UnsynchronizedLyrics = ({
|
||||||
<>
|
<>
|
||||||
<LyricLine
|
<LyricLine
|
||||||
className="lyric-credit"
|
className="lyric-credit"
|
||||||
text={`(Matched as ${override.title} by ${override.artist})`}
|
text={`(Matched as ${override.name} by ${override.artist})`}
|
||||||
/>
|
/>
|
||||||
<LyricSkip onClick={onRemoveLyric} />
|
<LyricSkip onClick={onRemoveLyric} />
|
||||||
</>
|
</>
|
||||||
|
|
Reference in a new issue