add getTranscodeDecision controller endpoint and types

This commit is contained in:
jeffvli
2026-03-09 21:50:03 -07:00
parent baf4e7bc0b
commit 52dea17d14
7 changed files with 238 additions and 26 deletions
@@ -1284,39 +1284,34 @@ export const JellyfinController: InternalControllerEndpoint = {
query: { ...query, limit: 1, startIndex: 0 },
}).then((result) => result!.totalRecordCount!),
getStreamUrl: ({ apiClientProps: { server }, query }) => {
const { bitrate, format, id, transcode } = query;
const { bitrate, format, id, offset = 0, transcode, transcodeParams } = query;
const deviceId = '';
let url = `${server?.url}/Items/${id}/Download?apiKey=${server?.credential}&playSessionId=${deviceId}`;
if (transcode) {
// Some format appears to be required. Fall back to trusty MP3 if not specified
// Otherwise, ffmpeg appears to crash
if (transcodeParams != null || transcode) {
const realFormat = format || 'mp3';
url =
let url =
`${server?.url}/audio` +
`/${id}/universal` +
`?userId=${server?.userId}` +
`&deviceId=${deviceId}` +
'&audioCodec=aac' +
`&apiKey=${server?.credential}` +
`&playSessionId=${deviceId}` +
'&container=opus,mp3,aac,m4a,m4b,flac,wav,ogg';
url += `&transcodingProtocol=http&transcodingContainer=${realFormat}`;
url = url.replace('audioCodec=aac', `audioCodec=${realFormat}`);
url = url.replace(
'&container=opus,mp3,aac,m4a,m4b,flac,wav,ogg',
`&container=${realFormat}`,
);
if (bitrate !== undefined) {
url += `&maxStreamingBitrate=${bitrate * 1000}`;
}
if (offset > 0) {
url += `&startTimeTicks=${Math.floor(offset * 10_000_000)}`;
}
return url;
}
return url;
return `${server?.url}/Items/${id}/Download?apiKey=${server?.credential}&playSessionId=${deviceId}`;
},
getTagList: async (args) => {
const { apiClientProps, query } = args;