os lyrics

This commit is contained in:
Kendall Garner 2024-02-01 23:53:10 -08:00
parent 9e4664a54c
commit 73cd647486
No known key found for this signature in database
GPG key ID: 18D2767419676C87
9 changed files with 182 additions and 46 deletions

View file

@ -7,6 +7,7 @@ import {
FullLyricsMetadata,
LyricGetQuery,
SubsonicExtensions,
StructuredLyric,
} from '/@/renderer/api/types';
import { QueryHookArgs } from '/@/renderer/lib/react-query';
import { getServerById, useLyricsSettings } from '/@/renderer/store';
@ -81,7 +82,7 @@ export const useServerLyrics = (
export const useSongLyricsBySong = (
args: QueryHookArgs<LyricsQuery>,
song: QueueSong | undefined,
): UseQueryResult<FullLyricsMetadata> => {
): UseQueryResult<FullLyricsMetadata | StructuredLyric[]> => {
const { query } = args;
const { fetch } = useLyricsSettings();
const server = getServerById(song?.serverId);
@ -90,7 +91,7 @@ export const useSongLyricsBySong = (
cacheTime: Infinity,
enabled: !!song && !!server,
onError: () => {},
queryFn: async ({ signal }) => {
queryFn: async ({ signal }): Promise<FullLyricsMetadata | StructuredLyric[] | null> => {
if (!server) throw new Error('Server not found');
if (!song) return null;
@ -112,7 +113,16 @@ export const useSongLyricsBySong = (
};
}
} else if (server.features && SubsonicExtensions.SONG_LYRICS in server.features) {
console.log(1234);
const subsonicLyrics = await api.controller
.getStructuredLyrics({
apiClientProps: { server, signal },
query: { songId: song.id },
})
.catch(console.error);
if (subsonicLyrics) {
return subsonicLyrics;
}
} else if (song.lyrics) {
return {
artist: song.artists?.[0]?.name,