provide transcoding support

This commit is contained in:
Kendall Garner 2024-09-01 08:26:30 -07:00
parent da95a644c8
commit 528bef01f0
No known key found for this signature in database
GPG key ID: 18D2767419676C87
24 changed files with 347 additions and 69 deletions

View file

@ -55,6 +55,7 @@ import {
Song,
MoveItemArgs,
DownloadArgs,
TranscodingArgs,
} from '/@/renderer/api/types';
import { jfApiClient } from '/@/renderer/api/jellyfin/jellyfin-api';
import { jfNormalize } from './jellyfin-normalize';
@ -1050,6 +1051,20 @@ const getDownloadUrl = (args: DownloadArgs) => {
return `${apiClientProps.server?.url}/items/${query.id}/download?api_key=${apiClientProps.server?.credential}`;
};
const getTranscodingUrl = (args: TranscodingArgs) => {
const { base, format, bitrate } = args.query;
let url = base.replace('transcodingProtocol=hls', 'transcodingProtocol=http');
if (format) {
url = url.replace('audioCodec=aac', `audioCodec=${format}`);
url = url.replace('transcodingContainer=ts', `transcodingContainer=${format}`);
}
if (bitrate !== undefined) {
url += `&maxStreamingBitrate=${bitrate * 1000}`;
}
return url;
};
export const jfController = {
addToPlaylist,
authenticate,
@ -1075,6 +1090,7 @@ export const jfController = {
getSongDetail,
getSongList,
getTopSongList,
getTranscodingUrl,
movePlaylistItem,
removeFromPlaylist,
scrobble,

View file

@ -34,7 +34,7 @@ const getStreamUrl = (args: {
`&playSessionId=${deviceId}` +
'&container=opus,mp3,aac,m4a,m4b,flac,wav,ogg' +
'&transcodingContainer=ts' +
'&transcodingProtocol=hls'
'&transcodingProtocol=http'
);
};