From 16eff8788777a1c0cde0d9ad3260dcab0e18b2c3 Mon Sep 17 00:00:00 2001 From: Christian Benincasa Date: Sat, 11 Jan 2025 16:47:34 -0500 Subject: [PATCH] fix: show redirect programming properly in xmltv --- server/src/services/TvGuideService.ts | 19 +++++++++++++++++-- server/src/services/XmlTvWriter.ts | 9 ++------- 2 files changed, 19 insertions(+), 9 deletions(-) diff --git a/server/src/services/TvGuideService.ts b/server/src/services/TvGuideService.ts index 31e5b79d4..99b72572b 100644 --- a/server/src/services/TvGuideService.ts +++ b/server/src/services/TvGuideService.ts @@ -26,6 +26,7 @@ import duration, { Duration } from 'dayjs/plugin/duration.js'; import { compact, filter, + find, first, flatMap, inRange, @@ -71,6 +72,7 @@ type GuideItem = { index?: number; // Start time of the program in this guide generation startTimeMs: number; + redirectChannelId?: string; }; export type TvGuideChannel = { @@ -554,6 +556,7 @@ export class TVGuideService { index: playing.index, startTimeMs: start, lineupItem: program2, + redirectChannelId: channel2.channel.uuid, }; } } @@ -954,8 +957,8 @@ export class TVGuideService { const icon = isNonEmptyString(materializedItem.icon) ? materializedItem.icon : isNonEmptyString(channel.icon?.path) - ? channel.icon.path - : makeLocalUrl('/images/tunarr.png'); + ? channel.icon.path + : makeLocalUrl('/images/tunarr.png'); return match(materializedItem) .returnType() @@ -1000,6 +1003,18 @@ export class TVGuideService { channel, currentProgram.lineupItem, allChannels, + currentProgram.lineupItem.type === 'content' + ? find( + this.channelsById[ + isNonEmptyString(currentProgram.redirectChannelId) + ? currentProgram.redirectChannelId + : channel.uuid + ]?.channel.programs, + (p) => + currentProgram.lineupItem.type === 'content' && + p.uuid === currentProgram.lineupItem.id, + ) + : undefined, ), ); } diff --git a/server/src/services/XmlTvWriter.ts b/server/src/services/XmlTvWriter.ts index 3a4ed9315..4296836c9 100644 --- a/server/src/services/XmlTvWriter.ts +++ b/server/src/services/XmlTvWriter.ts @@ -175,6 +175,8 @@ export class XmlTvWriter { }, ]; } + } else { + console.log(program); } return partial; @@ -189,13 +191,6 @@ export class XmlTvWriter { return (channelIdCache[channel.uuid] = getChannelId(channel.number)); } - // private static titleExtractor = forProgramType({ - // custom: (program) => program.program?.title ?? 'Custom Program', - // content: (program) => program.title, - // redirect: (program) => `Redirect to Channel ${program.channel}`, - // flex: program => , - // }); - isWriting() { return lock.isLocked(); }