An item can carry several credits blocks with mid- and post-credit scenes between them, and Plex flags the one that really ends it. The player left at the first block. Now the Plex-final block moves on (by the auto-skip or the Skip button), an earlier block is only skipped to its end by the button, and with no final flag the last block ends the item by the button alone.
48 lines
2.1 KiB
TypeScript
48 lines
2.1 KiB
TypeScript
// Which credits block ends an item, and what skipping each marker does. An item can carry several
|
|
// credits blocks — mid- and post-credit scenes play between them — and only the last one may move
|
|
// on to the next item; only the one Plex itself flags as the end may do so on its own.
|
|
import { describe, it, expect } from "vitest";
|
|
|
|
import type { PlexMarker } from "./api";
|
|
import { markerSkip } from "./plexMarkers";
|
|
|
|
const credits = (start_s: number, end_s: number, final = false): PlexMarker => ({
|
|
type: "credits",
|
|
start_s,
|
|
end_s,
|
|
final,
|
|
});
|
|
const intro: PlexMarker = { type: "intro", start_s: 10, end_s: 60, final: false };
|
|
|
|
describe("markerSkip", () => {
|
|
it("an intro jumps to its end, on its own when the viewer wants that", () => {
|
|
expect(markerSkip(intro, [intro])).toEqual({ leaves: false, auto: true });
|
|
});
|
|
|
|
it("only the credits Plex flags final leave the item, and only they may do it on their own", () => {
|
|
const first = credits(6811, 6831);
|
|
const middle = credits(7039, 7507);
|
|
const end = credits(7549, 7559, true);
|
|
const all = [intro, first, middle, end];
|
|
expect(markerSkip(first, all)).toEqual({ leaves: false, auto: false });
|
|
expect(markerSkip(middle, all)).toEqual({ leaves: false, auto: false });
|
|
expect(markerSkip(end, all)).toEqual({ leaves: true, auto: true });
|
|
});
|
|
|
|
it("with no credits flagged final the last one is the end, but leaves only when asked", () => {
|
|
const first = credits(2000, 2100);
|
|
const last = credits(2900, 2995);
|
|
// listed out of order on purpose: "last" is by time, not by position in the list
|
|
expect(markerSkip(last, [last, first])).toEqual({ leaves: true, auto: false });
|
|
expect(markerSkip(first, [last, first])).toEqual({ leaves: false, auto: false });
|
|
expect(markerSkip(last, [last])).toEqual({ leaves: true, auto: false });
|
|
});
|
|
|
|
it("a final flag on an earlier block wins over a later block", () => {
|
|
const end = credits(2000, 2100, true);
|
|
const later = credits(2900, 2995);
|
|
expect(markerSkip(end, [end, later])).toEqual({ leaves: true, auto: true });
|
|
expect(markerSkip(later, [end, later])).toEqual({ leaves: false, auto: false });
|
|
});
|
|
});
|