mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-11-23 04:46:08 -08:00
fix(jellyfin): keep the episode playlist window at least 3 long
With a 2-episode window the episode just left falls outside the next window, so a queue run could remove it while the user stepped back to it. mpv's IPC cannot check-and-remove atomically; a window of 3 or more always keeps both immediate neighbors, so removals stay two steps from the playing entry. maxEpisodes now clamps to 3..25.
This commit is contained in:
8 files changed
+43
-8
No files matched your search
@@ -1114,7 +1114,7 @@
|
|||||||
"transcodeVideoCodec": "h264", // Preferred transcode video codec when direct play is unavailable.
|
"transcodeVideoCodec": "h264", // Preferred transcode video codec when direct play is unavailable.
|
||||||
"episodePlaylist": {
|
"episodePlaylist": {
|
||||||
"enabled": true, // Add the playing episode's neighbors from its Jellyfin series to the mpv playlist, so mpv's playlist controls and end-of-file advance move between episodes. Values: true | false
|
"enabled": true, // Add the playing episode's neighbors from its Jellyfin series to the mpv playlist, so mpv's playlist controls and end-of-file advance move between episodes. Values: true | false
|
||||||
"maxEpisodes": 5 // Most episodes kept in the mpv playlist, the playing one included, centered on it (2-25).
|
"maxEpisodes": 5 // Most episodes kept in the mpv playlist, the playing one included, centered on it (3-25).
|
||||||
} // Episode playlist setting.
|
} // Episode playlist setting.
|
||||||
}, // Optional Jellyfin integration for auth, browsing, and playback launch.
|
}, // Optional Jellyfin integration for auth, browsing, and playback launch.
|
||||||
|
|
||||||
|
|||||||
@@ -572,7 +572,7 @@ Log in to a Jellyfin server, browse libraries, and play or cast to SubMiner. Log
|
|||||||
| `jellyfin.directPlayPreferred` | `true` | Try direct play before transcoding |
|
| `jellyfin.directPlayPreferred` | `true` | Try direct play before transcoding |
|
||||||
| `jellyfin.transcodeVideoCodec` | `"h264"` | Codec requested when transcoding |
|
| `jellyfin.transcodeVideoCodec` | `"h264"` | Codec requested when transcoding |
|
||||||
| `jellyfin.episodePlaylist.enabled` | `true` | Queue the episodes around the playing one in mpv's playlist ([episode playlist](/jellyfin-integration#episode-playlist)) |
|
| `jellyfin.episodePlaylist.enabled` | `true` | Queue the episodes around the playing one in mpv's playlist ([episode playlist](/jellyfin-integration#episode-playlist)) |
|
||||||
| `jellyfin.episodePlaylist.maxEpisodes` | `5` | Most episodes in that playlist, the playing one included (2-25) |
|
| `jellyfin.episodePlaylist.maxEpisodes` | `5` | Most episodes in that playlist, the playing one included (3-25) |
|
||||||
|
|
||||||
### Discord rich presence
|
### Discord rich presence
|
||||||
|
|
||||||
|
|||||||
@@ -1114,7 +1114,7 @@
|
|||||||
"transcodeVideoCodec": "h264", // Preferred transcode video codec when direct play is unavailable.
|
"transcodeVideoCodec": "h264", // Preferred transcode video codec when direct play is unavailable.
|
||||||
"episodePlaylist": {
|
"episodePlaylist": {
|
||||||
"enabled": true, // Add the playing episode's neighbors from its Jellyfin series to the mpv playlist, so mpv's playlist controls and end-of-file advance move between episodes. Values: true | false
|
"enabled": true, // Add the playing episode's neighbors from its Jellyfin series to the mpv playlist, so mpv's playlist controls and end-of-file advance move between episodes. Values: true | false
|
||||||
"maxEpisodes": 5 // Most episodes kept in the mpv playlist, the playing one included, centered on it (2-25).
|
"maxEpisodes": 5 // Most episodes kept in the mpv playlist, the playing one included, centered on it (3-25).
|
||||||
} // Episode playlist setting.
|
} // Episode playlist setting.
|
||||||
}, // Optional Jellyfin integration for auth, browsing, and playback launch.
|
}, // Optional Jellyfin integration for auth, browsing, and playback launch.
|
||||||
|
|
||||||
|
|||||||
@@ -716,7 +716,7 @@ export function buildIntegrationConfigOptionRegistry(
|
|||||||
kind: 'number',
|
kind: 'number',
|
||||||
defaultValue: defaultConfig.jellyfin.episodePlaylist.maxEpisodes,
|
defaultValue: defaultConfig.jellyfin.episodePlaylist.maxEpisodes,
|
||||||
description:
|
description:
|
||||||
'Most episodes kept in the mpv playlist, the playing one included, centered on it (2-25).',
|
'Most episodes kept in the mpv playlist, the playing one included, centered on it (3-25).',
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
path: 'discordPresence.enabled',
|
path: 'discordPresence.enabled',
|
||||||
|
|||||||
@@ -388,13 +388,13 @@ export function applyIntegrationConfig(context: ResolveContext): void {
|
|||||||
|
|
||||||
const maxEpisodes = asNumber(episodePlaylist.maxEpisodes);
|
const maxEpisodes = asNumber(episodePlaylist.maxEpisodes);
|
||||||
if (maxEpisodes !== undefined) {
|
if (maxEpisodes !== undefined) {
|
||||||
const normalized = Math.min(25, Math.max(2, Math.floor(maxEpisodes)));
|
const normalized = Math.min(25, Math.max(3, Math.floor(maxEpisodes)));
|
||||||
if (normalized !== maxEpisodes) {
|
if (normalized !== maxEpisodes) {
|
||||||
warn(
|
warn(
|
||||||
'jellyfin.episodePlaylist.maxEpisodes',
|
'jellyfin.episodePlaylist.maxEpisodes',
|
||||||
episodePlaylist.maxEpisodes,
|
episodePlaylist.maxEpisodes,
|
||||||
normalized,
|
normalized,
|
||||||
'Out of range; clamped to 2..25.',
|
'Out of range; clamped to 3..25.',
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
resolved.jellyfin.episodePlaylist.maxEpisodes = normalized;
|
resolved.jellyfin.episodePlaylist.maxEpisodes = normalized;
|
||||||
|
|||||||
@@ -178,3 +178,13 @@ test('jellyfin episodePlaylist resolves the toggle and clamps the episode cap',
|
|||||||
assert.deepEqual(context.resolved.jellyfin.episodePlaylist, { enabled: false, maxEpisodes: 25 });
|
assert.deepEqual(context.resolved.jellyfin.episodePlaylist, { enabled: false, maxEpisodes: 25 });
|
||||||
assert.ok(warnings.some((warning) => warning.path === 'jellyfin.episodePlaylist.maxEpisodes'));
|
assert.ok(warnings.some((warning) => warning.path === 'jellyfin.episodePlaylist.maxEpisodes'));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('jellyfin episodePlaylist raises an episode cap below 3', () => {
|
||||||
|
const { context } = createResolveContext({
|
||||||
|
jellyfin: { episodePlaylist: { maxEpisodes: 2 } },
|
||||||
|
});
|
||||||
|
|
||||||
|
applyIntegrationConfig(context);
|
||||||
|
|
||||||
|
assert.equal(context.resolved.jellyfin.episodePlaylist.maxEpisodes, 3);
|
||||||
|
});
|
||||||
@@ -172,6 +172,20 @@ test('queueNeighbors never undoes a navigation that lands after its playlist rea
|
|||||||
assert.deepEqual(harness.filenames(), [url('e3'), url('e4'), url('e5')]);
|
assert.deepEqual(harness.filenames(), [url('e3'), url('e4'), url('e5')]);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('queueNeighbors keeps the episode just left even with the smallest configured window', async () => {
|
||||||
|
const harness = makeHarness({ enabled: true, maxEpisodes: 2 });
|
||||||
|
harness.playing('e3');
|
||||||
|
await harness.queue.queueNeighbors(null, entry('e3'));
|
||||||
|
harness.playing('e4');
|
||||||
|
// The read sees e4 playing; the user steps back to e3 before the edits arrive.
|
||||||
|
harness.setAfterRead(() => harness.playing('e3'));
|
||||||
|
|
||||||
|
await harness.queue.queueNeighbors(null, entry('e4'));
|
||||||
|
|
||||||
|
assert.equal(harness.playlist.find((item) => item.current)?.filename, url('e3'));
|
||||||
|
assert.ok(harness.filenames().includes(url('e3')));
|
||||||
|
});
|
||||||
|
|
||||||
test('queueNeighbors leaves the playlist alone once mpv has moved past the item', async () => {
|
test('queueNeighbors leaves the playlist alone once mpv has moved past the item', async () => {
|
||||||
const harness = makeHarness();
|
const harness = makeHarness();
|
||||||
harness.playing('e3');
|
harness.playing('e3');
|
||||||
|
|||||||
@@ -13,10 +13,17 @@ export type JellyfinPlaylistEntry = {
|
|||||||
|
|
||||||
export type JellyfinEpisodePlaylistSettings = {
|
export type JellyfinEpisodePlaylistSettings = {
|
||||||
enabled: boolean;
|
enabled: boolean;
|
||||||
/** Most entries kept in mpv's playlist, the current one included. */
|
/** Most entries kept in mpv's playlist, the current one included. Raised to at least 3. */
|
||||||
maxEpisodes: number;
|
maxEpisodes: number;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A window of 3 or more always holds the current episode's immediate neighbors (it only shifts
|
||||||
|
* at a series edge, where that neighbor does not exist). Removals then stay at least two steps
|
||||||
|
* from the playing entry, so a queue run cannot remove the episode a user just stepped back to.
|
||||||
|
*/
|
||||||
|
const MIN_WINDOW_EPISODES = 3;
|
||||||
|
|
||||||
export type JellyfinQueuedEpisode<Context, Entry> = {
|
export type JellyfinQueuedEpisode<Context, Entry> = {
|
||||||
context: Context;
|
context: Context;
|
||||||
entry: Entry;
|
entry: Entry;
|
||||||
@@ -110,7 +117,11 @@ export function createJellyfinEpisodePlaylist<Context, Entry extends JellyfinPla
|
|||||||
let windowIds = [current.itemId];
|
let windowIds = [current.itemId];
|
||||||
if (settings.enabled && current.seriesId) {
|
if (settings.enabled && current.seriesId) {
|
||||||
const episodeIds = await getSeriesEpisodeIds(context, current.seriesId);
|
const episodeIds = await getSeriesEpisodeIds(context, current.seriesId);
|
||||||
const window = selectEpisodeWindow(episodeIds, current.itemId, settings.maxEpisodes);
|
const window = selectEpisodeWindow(
|
||||||
|
episodeIds,
|
||||||
|
current.itemId,
|
||||||
|
Math.max(MIN_WINDOW_EPISODES, settings.maxEpisodes),
|
||||||
|
);
|
||||||
windowIds = [...window.previousIds, current.itemId, ...window.nextIds];
|
windowIds = [...window.previousIds, current.itemId, ...window.nextIds];
|
||||||
}
|
}
|
||||||
// Entries already queued stay where they are, so only the missing ones are resolved.
|
// Entries already queued stay where they are, so only the missing ones are resolved.
|
||||||
|
|||||||
Reference in new issue
Block a user