diff --git a/src/helperFuncs.js b/src/helperFuncs.js index 343d02c..4cf2301 100644 --- a/src/helperFuncs.js +++ b/src/helperFuncs.js @@ -2,6 +2,7 @@ module.exports = { getCurrentProgramAndTimeElapsed: getCurrentProgramAndTimeElapsed, createLineup: createLineup, getWatermark: getWatermark, + generateChannelContext: generateChannelContext, } let channelCache = require('./channel-cache'); @@ -10,6 +11,17 @@ const randomJS = require("random-js"); const Random = randomJS.Random; const random = new Random( randomJS.MersenneTwister19937.autoSeed() ); +const CHANNEL_CONTEXT_KEYS = [ + "disableFillerOverlay", + "watermark", + "icon", + "offlinePicture", + "offlineSoundtrack", + "name", + "transcoding", + "number", +]; + module.exports.random = random; function getCurrentProgramAndTimeElapsed(date, channel) { @@ -260,6 +272,7 @@ function pickRandomWithMaxDuration(channel, fillers, maxDuration) { } } +// any channel thing used here should be added to channel context function getWatermark( ffmpegSettings, channel, type) { if (! ffmpegSettings.enableFFMPEGTranscoding || ffmpegSettings.disableChannelOverlay ) { return null; @@ -301,3 +314,12 @@ function getWatermark( ffmpegSettings, channel, type) { return result; } + +function generateChannelContext(channel) { + let channelContext = {}; + for (let i = 0; i < CHANNEL_CONTEXT_KEYS.length; i++) { + let key = CHANNEL_CONTEXT_KEYS[i]; + channelContext[key] = JSON.parse( JSON.stringify(channel[key] ) ); + } + return channelContext; +} diff --git a/src/video.js b/src/video.js index 262559d..041cb48 100644 --- a/src/video.js +++ b/src/video.js @@ -308,7 +308,7 @@ function video( channelDB , fillerDB, db, programmingService, activeChannelServi }; } - let combinedChannel = JSON.parse( JSON.stringify(brandChannel) ); + let combinedChannel = helperFuncs.generateChannelContext(brandChannel); combinedChannel.transcoding = channel.transcoding; let playerContext = {