remove serverFeatures and transcode from api context

This commit is contained in:
jeffvli
2026-03-31 11:30:32 -07:00
parent 833d4d3aac
commit 8b4bbc1ede
3 changed files with 9 additions and 28 deletions
-14
View File
@@ -67,28 +67,14 @@ const getPathReplaceSettings = () => {
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 pathSettings = getPathReplaceSettings();
const transcodeSettings = getTranscodeSettings();
const serverFeatures = getServerFeatures();
return {
...args,
context: {
...(args.context || {}),
...pathSettings,
serverFeatures: serverFeatures,
transcode: transcodeSettings,
},
};
};
@@ -1951,10 +1951,9 @@ export const SubsonicController: InternalControllerEndpoint = {
return totalRecordCount;
},
getStreamUrl: async ({ apiClientProps, context, query }) => {
getStreamUrl: async ({ apiClientProps, query }) => {
const { server } = apiClientProps;
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}`;
@@ -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 (serverFeatures?.[ServerFeature.OS_TRANSCODE_DECISION]) {
const maxTranscodingAudioBitrate = transcodeSettings?.bitrate || 0;
if (hasFeature(server, ServerFeature.OS_TRANSCODE_DECISION)) {
const maxTranscodingAudioBitrate = 0;
const transcodingProfiles = format?.split(',').map((f) => {
const trimmedFormat = f.trim();
const transcodingProfiles = (transcodeSettings?.format || []).map((format) => {
return {
audioCodec: format,
container: format,
audioCodec: trimmedFormat,
container: trimmedFormat,
maxAudioChannels: 2,
protocol: 'http',
};
@@ -1980,7 +1981,7 @@ export const SubsonicController: InternalControllerEndpoint = {
body: {
codecProfiles: [],
directPlayProfiles: TRANSCODE_DIRECT_PLAY_PROFILES,
maxAudioBitrate: 512000,
maxAudioBitrate: 0,
maxTranscodingAudioBitrate,
name: 'Feishin',
platform: 'Web',
-6
View File
@@ -413,12 +413,6 @@ export type Song = {
type ApiContext = {
pathReplace?: string;
pathReplaceWith?: string;
serverFeatures?: ServerFeatures;
transcode?: {
bitrate?: number;
enabled?: boolean;
format?: string[];
};
};
type BaseEndpointArgs = {