fix: sanitize jellyfin misc info formatting

This commit is contained in:
2026-03-01 20:05:19 -08:00
parent 7023a3263f
commit 68e5a7fef3
5 changed files with 110 additions and 2 deletions

View File

@@ -57,6 +57,26 @@ test('MpvIpcClient handles sub-text property change and broadcasts tokenized sub
assert.equal(events[0]!.isOverlayVisible, false);
});
test('MpvIpcClient clears cached media title when media path changes', async () => {
const client = new MpvIpcClient('/tmp/mpv.sock', makeDeps());
await invokeHandleMessage(client, {
event: 'property-change',
name: 'media-title',
data: '[Jellyfin/direct] Episode 1',
});
assert.equal(client.currentMediaTitle, '[Jellyfin/direct] Episode 1');
await invokeHandleMessage(client, {
event: 'property-change',
name: 'path',
data: '/tmp/new-episode.mkv',
});
assert.equal(client.currentVideoPath, '/tmp/new-episode.mkv');
assert.equal(client.currentMediaTitle, null);
});
test('MpvIpcClient parses JSON line protocol in processBuffer', () => {
const client = new MpvIpcClient('/tmp/mpv.sock', makeDeps());
const seen: Array<Record<string, unknown>> = [];

View File

@@ -134,6 +134,7 @@ export class MpvIpcClient implements MpvClient {
private firstConnection = true;
private hasConnectedOnce = false;
public currentVideoPath = '';
public currentMediaTitle: string | null = null;
public currentTimePos = 0;
public currentSubStart = 0;
public currentSubEnd = 0;
@@ -330,6 +331,7 @@ export class MpvIpcClient implements MpvClient {
this.emit('media-path-change', payload);
},
emitMediaTitleChange: (payload) => {
this.currentMediaTitle = payload.title;
this.emit('media-title-change', payload);
},
emitSubtitleMetricsChange: (patch) => {
@@ -364,6 +366,7 @@ export class MpvIpcClient implements MpvClient {
},
setCurrentVideoPath: (value: string) => {
this.currentVideoPath = value;
this.currentMediaTitle = null;
},
emitSecondarySubtitleVisibility: (payload) => {
this.emit('secondary-subtitle-visibility', payload);