Skip to content

Commit

Permalink
Use MediaStream type for subtitle stream processing
Browse files Browse the repository at this point in the history
  • Loading branch information
3flex committed Dec 7, 2024
1 parent 9b7cbb0 commit cb2897a
Showing 1 changed file with 21 additions and 10 deletions.
31 changes: 21 additions & 10 deletions src/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -415,8 +415,7 @@ export function createStreamInfo(
}) ?? [];
const subtitleTracks: framework.messages.Track[] = [];

// eslint-disable-next-line @typescript-eslint/no-explicit-any
subtitleStreams.forEach((subtitleStream: any) => {
subtitleStreams.forEach((subtitleStream) => {
if (subtitleStream.DeliveryUrl === undefined) {
/* The CAF v3 player only supports vtt currently,
* SRT subs can be "transcoded" to vtt by jellyfin.
Expand All @@ -427,10 +426,6 @@ export function createStreamInfo(
return;
}

const textStreamUrl = subtitleStream.IsExternalUrl
? subtitleStream.DeliveryUrl
: JellyfinApi.createUrl(subtitleStream.DeliveryUrl);

if (!info.subtitleStreamIndex) {
return;
}
Expand All @@ -440,10 +435,26 @@ export function createStreamInfo(
cast.framework.messages.TrackType.TEXT
);

track.trackId = subtitleStream.Index;
track.trackContentId = textStreamUrl;
track.language = subtitleStream.Language;
track.name = subtitleStream.DisplayTitle;
if (subtitleStream.IsExternal && subtitleStream.DeliveryUrl) {
track.trackContentId = subtitleStream.DeliveryUrl;
} else if (subtitleStream.DeliveryUrl) {
track.trackContentId = JellyfinApi.createUrl(
subtitleStream.DeliveryUrl
);
}

if (subtitleStream.Index) {
track.trackId = subtitleStream.Index;
}

if (subtitleStream.Language) {
track.language = subtitleStream.Language;
}

if (subtitleStream.DisplayTitle) {
track.name = subtitleStream.DisplayTitle;
}

// TODO this should not be hardcoded but we only support VTT currently
track.trackContentType = 'text/vtt';
track.subtype = cast.framework.messages.TextTrackType.SUBTITLES;
Expand Down

0 comments on commit cb2897a

Please sign in to comment.