mirror of
https://github.com/jeffvli/feishin.git
synced 2026-05-09 20:29:36 +02:00
include transcode settings and server features in api context
This commit is contained in:
@@ -67,13 +67,28 @@ const getPathReplaceSettings = () => {
|
|||||||
return { pathReplace, pathReplaceWith };
|
return { pathReplace, pathReplaceWith };
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const getTranscodeSettings = () => {
|
||||||
|
const transcode = useSettingsStore.getState().playback.transcode;
|
||||||
|
return transcode;
|
||||||
|
};
|
||||||
|
|
||||||
|
const getServerFeatures = () => {
|
||||||
|
const serverFeatures = useAuthStore.getState().currentServer?.features;
|
||||||
|
return serverFeatures;
|
||||||
|
};
|
||||||
|
|
||||||
const addContext = <T extends { apiClientProps: any; context?: any }>(args: T): T => {
|
const addContext = <T extends { apiClientProps: any; context?: any }>(args: T): T => {
|
||||||
const pathSettings = getPathReplaceSettings();
|
const pathSettings = getPathReplaceSettings();
|
||||||
|
const transcodeSettings = getTranscodeSettings();
|
||||||
|
const serverFeatures = getServerFeatures();
|
||||||
|
|
||||||
return {
|
return {
|
||||||
...args,
|
...args,
|
||||||
context: {
|
context: {
|
||||||
...(args.context || {}),
|
...(args.context || {}),
|
||||||
...pathSettings,
|
...pathSettings,
|
||||||
|
serverFeatures: serverFeatures,
|
||||||
|
transcode: transcodeSettings,
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -410,16 +410,24 @@ export type Song = {
|
|||||||
userRating: null | number;
|
userRating: null | number;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
type ApiContext = {
|
||||||
|
pathReplace?: string;
|
||||||
|
pathReplaceWith?: string;
|
||||||
|
serverFeatures?: ServerFeatures;
|
||||||
|
transcode?: {
|
||||||
|
bitrate?: number;
|
||||||
|
enabled?: boolean;
|
||||||
|
format?: string[];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
type BaseEndpointArgs = {
|
type BaseEndpointArgs = {
|
||||||
apiClientProps: {
|
apiClientProps: {
|
||||||
server?: null | ServerListItemWithCredential;
|
server?: null | ServerListItemWithCredential;
|
||||||
serverId: string;
|
serverId: string;
|
||||||
signal?: AbortSignal;
|
signal?: AbortSignal;
|
||||||
};
|
};
|
||||||
context?: {
|
context?: ApiContext;
|
||||||
pathReplace?: string;
|
|
||||||
pathReplaceWith?: string;
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
type GenreListSortMap = {
|
type GenreListSortMap = {
|
||||||
@@ -1563,7 +1571,7 @@ export type InternalControllerEndpoint = {
|
|||||||
getSongDetail: (args: ReplaceApiClientProps<SongDetailArgs>) => Promise<SongDetailResponse>;
|
getSongDetail: (args: ReplaceApiClientProps<SongDetailArgs>) => Promise<SongDetailResponse>;
|
||||||
getSongList: (args: ReplaceApiClientProps<SongListArgs>) => Promise<SongListResponse>;
|
getSongList: (args: ReplaceApiClientProps<SongListArgs>) => Promise<SongListResponse>;
|
||||||
getSongListCount: (args: ReplaceApiClientProps<SongListCountArgs>) => Promise<number>;
|
getSongListCount: (args: ReplaceApiClientProps<SongListCountArgs>) => Promise<number>;
|
||||||
getStreamUrl: (args: ReplaceApiClientProps<StreamArgs>) => string;
|
getStreamUrl: (args: ReplaceApiClientProps<StreamArgs>) => Promise<string>;
|
||||||
getStructuredLyrics?: (
|
getStructuredLyrics?: (
|
||||||
args: ReplaceApiClientProps<StructuredLyricsArgs>,
|
args: ReplaceApiClientProps<StructuredLyricsArgs>,
|
||||||
) => Promise<StructuredLyric[]>;
|
) => Promise<StructuredLyric[]>;
|
||||||
@@ -1673,7 +1681,6 @@ export type StreamQuery = {
|
|||||||
mediaType?: 'podcast' | 'song';
|
mediaType?: 'podcast' | 'song';
|
||||||
offset?: number;
|
offset?: number;
|
||||||
transcode: boolean;
|
transcode: boolean;
|
||||||
transcodeParams?: string;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
export type StructuredLyric = (StructuredSyncedLyric | StructuredUnsyncedLyric) & {
|
export type StructuredLyric = (StructuredSyncedLyric | StructuredUnsyncedLyric) & {
|
||||||
@@ -1780,8 +1787,5 @@ type BaseEndpointArgsWithServer = {
|
|||||||
serverId: string;
|
serverId: string;
|
||||||
signal?: AbortSignal;
|
signal?: AbortSignal;
|
||||||
};
|
};
|
||||||
context?: {
|
context?: ApiContext;
|
||||||
pathReplace?: string;
|
|
||||||
pathReplaceWith?: string;
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user