fix(anime): thread episode metadata through stream playback and fix seas

- Split anime browser stream titles into series/season/episode fields (episode-metadata.ts) instead of one joined string, so stats grouping, the mpv title, and the Jimaku/TsukiHime modals all get real values instead of a filename-derived "m3u8"
- Fix AniList season resolver to walk through split-cour sequels and specials without counting them as a season, and to surface rate-limit/network failures instead of falling through to a wrong air-order guess
- Add a Season field to the TsukiHime modal and include later seasons in its search query
- Rewrite WebVTT subtitle tracks as SRT before handing them to alass, since alass has no VTT support and streams serve VTT
- Update CHANGELOG and troubleshooting docs
This commit is contained in:
2026-08-01 23:34:23 -07:00
parent 558e00cb44
commit 722222c651
25 changed files with 1719 additions and 69 deletions
@@ -0,0 +1,77 @@
import test from 'node:test';
import assert from 'node:assert/strict';
import {
createStreamPlaybackMetadataStore,
toAnilistMediaGuess,
toJimakuMediaInfo,
} from './stream-playback-metadata';
import type { AnimeStreamMetadata } from '../../anime-bridge/episode-metadata';
function metadata(overrides: Partial<AnimeStreamMetadata> = {}): AnimeStreamMetadata {
return {
mediaPath: 'http://127.0.0.1:41234/video/abc.m3u8',
statsPath: 'animebrowser://9001/%2Fanime%2Fmushoku/%2Fwatch%2Fep-4',
seriesTitle: 'Mushoku Tensei: Jobless Reincarnation',
seasonNumber: 3,
episodeNumber: 4,
episodeTitle: null,
displayTitle: 'Mushoku Tensei: Jobless Reincarnation S03E04',
...overrides,
};
}
test('the store answers for the stream URL and for the stats path', () => {
const store = createStreamPlaybackMetadataStore();
const current = metadata();
store.set(current);
assert.equal(store.match(current.mediaPath), current);
assert.equal(store.match(current.statsPath), current);
assert.equal(store.match(` ${current.mediaPath} `), current);
});
test('the store stops answering once the player moves on', () => {
const store = createStreamPlaybackMetadataStore();
store.set(metadata());
assert.equal(store.match('/home/user/Videos/local.mkv'), null);
assert.equal(store.match(null), null);
assert.equal(store.match(''), null);
store.clear();
assert.equal(store.match(metadata().mediaPath), null);
});
test('toJimakuMediaInfo prefills the modals with the source-reported fields', () => {
assert.deepEqual(toJimakuMediaInfo(metadata()), {
title: 'Mushoku Tensei: Jobless Reincarnation',
season: 3,
episode: 4,
confidence: 'high',
filename: 'Mushoku Tensei: Jobless Reincarnation S03E04',
rawTitle: 'Mushoku Tensei: Jobless Reincarnation S03E04',
});
});
test('toJimakuMediaInfo drops to low confidence when there is no episode', () => {
const info = toJimakuMediaInfo(metadata({ episodeNumber: null, seasonNumber: null }));
assert.equal(info.episode, null);
assert.equal(info.confidence, 'low');
assert.equal(info.title, 'Mushoku Tensei: Jobless Reincarnation');
});
test('toAnilistMediaGuess reports the stream fields verbatim', () => {
assert.deepEqual(toAnilistMediaGuess(metadata()), {
title: 'Mushoku Tensei: Jobless Reincarnation',
season: 3,
episode: 4,
source: 'stream',
});
});
test('toAnilistMediaGuess declines a special so the caller can fall back', () => {
// AniList progress counts whole episodes; a 6.5 special is not one of them.
assert.equal(toAnilistMediaGuess(metadata({ episodeNumber: 6.5 })), null);
assert.equal(toAnilistMediaGuess(metadata({ episodeNumber: null })), null);
assert.equal(toAnilistMediaGuess(metadata({ seriesTitle: '' })), null);
});