mirror of
https://github.com/antebudimir/feishin.git
synced 2026-01-01 10:23:33 +00:00
support .txt
This commit is contained in:
parent
58f38b2655
commit
9eef570740
5 changed files with 20 additions and 13 deletions
|
|
@ -47,7 +47,7 @@ import type {
|
|||
SearchArgs,
|
||||
SearchResponse,
|
||||
LyricsArgs,
|
||||
SynchronizedLyricsArray,
|
||||
LyricsResponse,
|
||||
} from '/@/renderer/api/types';
|
||||
import { ServerType } from '/@/renderer/types';
|
||||
import { DeletePlaylistResponse, RandomSongListArgs } from './types';
|
||||
|
|
@ -78,7 +78,7 @@ export type ControllerEndpoint = Partial<{
|
|||
getFolderList: () => void;
|
||||
getFolderSongs: () => void;
|
||||
getGenreList: (args: GenreListArgs) => Promise<GenreListResponse>;
|
||||
getLyrics: (args: LyricsArgs) => Promise<SynchronizedLyricsArray>;
|
||||
getLyrics: (args: LyricsArgs) => Promise<LyricsResponse>;
|
||||
getMusicFolderList: (args: MusicFolderListArgs) => Promise<MusicFolderListResponse>;
|
||||
getPlaylistDetail: (args: PlaylistDetailArgs) => Promise<PlaylistDetailResponse>;
|
||||
getPlaylistList: (args: PlaylistListArgs) => Promise<PlaylistListResponse>;
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ import {
|
|||
RandomSongListResponse,
|
||||
RandomSongListArgs,
|
||||
LyricsArgs,
|
||||
SynchronizedLyricsArray,
|
||||
LyricsResponse,
|
||||
} from '/@/renderer/api/types';
|
||||
import { jfApiClient } from '/@/renderer/api/jellyfin/jellyfin-api';
|
||||
import { jfNormalize } from './jellyfin-normalize';
|
||||
|
|
@ -849,7 +849,7 @@ const getRandomSongList = async (args: RandomSongListArgs): Promise<RandomSongLi
|
|||
};
|
||||
};
|
||||
|
||||
const getLyrics = async (args: LyricsArgs): Promise<SynchronizedLyricsArray> => {
|
||||
const getLyrics = async (args: LyricsArgs): Promise<LyricsResponse> => {
|
||||
const { query, apiClientProps } = args;
|
||||
|
||||
if (!apiClientProps.server?.userId) {
|
||||
|
|
@ -867,7 +867,11 @@ const getLyrics = async (args: LyricsArgs): Promise<SynchronizedLyricsArray> =>
|
|||
throw new Error('Failed to get lyrics');
|
||||
}
|
||||
|
||||
return res.body.Lyrics.map((lyric) => [lyric.Start / 1e4, lyric.Text]);
|
||||
if (res.body.Lyrics.length > 0 && res.body.Lyrics[0].Start === undefined) {
|
||||
return res.body.Lyrics[0].Text;
|
||||
}
|
||||
|
||||
return res.body.Lyrics.map((lyric) => [lyric.Start! / 1e4, lyric.Text]);
|
||||
};
|
||||
|
||||
export const jfController = {
|
||||
|
|
|
|||
|
|
@ -632,7 +632,7 @@ const searchParameters = paginationParameters.merge(baseParameters);
|
|||
const search = z.any();
|
||||
|
||||
const lyricText = z.object({
|
||||
Start: z.number(),
|
||||
Start: z.number().optional(),
|
||||
Text: z.string(),
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -1027,6 +1027,8 @@ export type LyricsArgs = {
|
|||
|
||||
export type SynchronizedLyricsArray = Array<[number, string]>;
|
||||
|
||||
export type LyricsResponse = SynchronizedLyricsArray | string;
|
||||
|
||||
export const instanceOfCancellationError = (error: any) => {
|
||||
return 'revert' in error;
|
||||
};
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue