mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-10-22 05:01:24 -07:00
fix(jellyfin): keep selecting subtitles when a track download fails (#272)
This commit is contained in:
1 parent
63eb228e4f
commit
b24008237b
5 files changed
+91
-18
No files matched your search
@@ -377,6 +377,14 @@ test('listSubtitleTracks returns all subtitle streams with delivery urls', async
|
||||
DeliveryUrl: 'https://cdn.example.com/subs.srt',
|
||||
IsExternalUrl: true,
|
||||
},
|
||||
{
|
||||
Type: 'Subtitle',
|
||||
Index: 5,
|
||||
Codec: 'PGSSUB',
|
||||
Language: 'eng',
|
||||
DisplayTitle: 'English PGS',
|
||||
DeliveryMethod: 'Embed',
|
||||
},
|
||||
],
|
||||
},
|
||||
],
|
||||
@@ -395,10 +403,10 @@ test('listSubtitleTracks returns all subtitle streams with delivery urls', async
|
||||
clientInfo,
|
||||
'movie-1',
|
||||
);
|
||||
assert.equal(tracks.length, 3);
|
||||
assert.equal(tracks.length, 4);
|
||||
assert.deepEqual(
|
||||
tracks.map((track) => track.index),
|
||||
[2, 3, 4],
|
||||
[2, 3, 4, 5],
|
||||
);
|
||||
assert.equal(
|
||||
tracks[0]!.deliveryUrl,
|
||||
@@ -409,6 +417,7 @@ test('listSubtitleTracks returns all subtitle streams with delivery urls', async
|
||||
'http://jellyfin.local/Videos/movie-1/ms-1/Subtitles/3/Stream.srt?ApiKey=token',
|
||||
);
|
||||
assert.equal(tracks[2]!.deliveryUrl, 'https://cdn.example.com/subs.srt');
|
||||
assert.equal(tracks[3]!.deliveryUrl, null, 'bitmap subtitles cannot be fetched as text');
|
||||
} finally {
|
||||
globalThis.fetch = originalFetch;
|
||||
}
|
||||
|
||||
@@ -146,6 +146,17 @@ function setApiKeyParam(url: URL, accessToken: string): void {
|
||||
url.searchParams.set('ApiKey', accessToken);
|
||||
}
|
||||
|
||||
const IMAGE_SUBTITLE_CODECS = new Set([
|
||||
'pgssub',
|
||||
'pgs',
|
||||
'hdmv_pgs_subtitle',
|
||||
'dvdsub',
|
||||
'dvd_subtitle',
|
||||
'dvbsub',
|
||||
'dvb_subtitle',
|
||||
'xsub',
|
||||
]);
|
||||
|
||||
function resolveDeliveryUrl(
|
||||
session: JellyfinAuthSession,
|
||||
stream: JellyfinMediaStream,
|
||||
@@ -163,6 +174,8 @@ function resolveDeliveryUrl(
|
||||
const streamIndex = asIntegerOrNull(stream.Index);
|
||||
if (streamIndex === null || !itemId || !mediaSourceId) return null;
|
||||
const codec = ensureString(stream.Codec).toLowerCase();
|
||||
// Jellyfin cannot convert bitmap subtitles to text, so requesting them always fails.
|
||||
if (IMAGE_SUBTITLE_CODECS.has(codec)) return null;
|
||||
const ext =
|
||||
codec === 'subrip'
|
||||
? 'srt'
|
||||
|
||||
Reference in new issue
Block a user