mirror of
https://github.com/jeffvli/feishin.git
synced 2026-06-16 16:34:24 +02:00
remove serverFeatures and transcode from api context
This commit is contained in:
@@ -67,28 +67,14 @@ 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,
|
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1951,10 +1951,9 @@ export const SubsonicController: InternalControllerEndpoint = {
|
|||||||
|
|
||||||
return totalRecordCount;
|
return totalRecordCount;
|
||||||
},
|
},
|
||||||
getStreamUrl: async ({ apiClientProps, context, query }) => {
|
getStreamUrl: async ({ apiClientProps, query }) => {
|
||||||
const { server } = apiClientProps;
|
const { server } = apiClientProps;
|
||||||
const { bitrate, format, id, mediaType = 'song', transcode } = query;
|
const { bitrate, format, id, mediaType = 'song', transcode } = query;
|
||||||
const { serverFeatures, transcode: transcodeSettings } = context || {};
|
|
||||||
|
|
||||||
const streamUrl = `${server?.url}/rest/stream.view?id=${id}&v=1.13.0&c=Feishin&${server?.credential}`;
|
const streamUrl = `${server?.url}/rest/stream.view?id=${id}&v=1.13.0&c=Feishin&${server?.credential}`;
|
||||||
|
|
||||||
@@ -1964,13 +1963,15 @@ export const SubsonicController: InternalControllerEndpoint = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// If the server supports transcoding decision, always use it to determine if we need to transcode
|
// If the server supports transcoding decision, always use it to determine if we need to transcode
|
||||||
if (serverFeatures?.[ServerFeature.OS_TRANSCODE_DECISION]) {
|
if (hasFeature(server, ServerFeature.OS_TRANSCODE_DECISION)) {
|
||||||
const maxTranscodingAudioBitrate = transcodeSettings?.bitrate || 0;
|
const maxTranscodingAudioBitrate = 0;
|
||||||
|
|
||||||
|
const transcodingProfiles = format?.split(',').map((f) => {
|
||||||
|
const trimmedFormat = f.trim();
|
||||||
|
|
||||||
const transcodingProfiles = (transcodeSettings?.format || []).map((format) => {
|
|
||||||
return {
|
return {
|
||||||
audioCodec: format,
|
audioCodec: trimmedFormat,
|
||||||
container: format,
|
container: trimmedFormat,
|
||||||
maxAudioChannels: 2,
|
maxAudioChannels: 2,
|
||||||
protocol: 'http',
|
protocol: 'http',
|
||||||
};
|
};
|
||||||
@@ -1980,7 +1981,7 @@ export const SubsonicController: InternalControllerEndpoint = {
|
|||||||
body: {
|
body: {
|
||||||
codecProfiles: [],
|
codecProfiles: [],
|
||||||
directPlayProfiles: TRANSCODE_DIRECT_PLAY_PROFILES,
|
directPlayProfiles: TRANSCODE_DIRECT_PLAY_PROFILES,
|
||||||
maxAudioBitrate: 512000,
|
maxAudioBitrate: 0,
|
||||||
maxTranscodingAudioBitrate,
|
maxTranscodingAudioBitrate,
|
||||||
name: 'Feishin',
|
name: 'Feishin',
|
||||||
platform: 'Web',
|
platform: 'Web',
|
||||||
|
|||||||
@@ -413,12 +413,6 @@ export type Song = {
|
|||||||
type ApiContext = {
|
type ApiContext = {
|
||||||
pathReplace?: string;
|
pathReplace?: string;
|
||||||
pathReplaceWith?: string;
|
pathReplaceWith?: string;
|
||||||
serverFeatures?: ServerFeatures;
|
|
||||||
transcode?: {
|
|
||||||
bitrate?: number;
|
|
||||||
enabled?: boolean;
|
|
||||||
format?: string[];
|
|
||||||
};
|
|
||||||
};
|
};
|
||||||
|
|
||||||
type BaseEndpointArgs = {
|
type BaseEndpointArgs = {
|
||||||
|
|||||||
Reference in New Issue
Block a user