Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update develop with staging #98

Merged
merged 7 commits into from
Apr 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,5 @@ RUN apk add --no-cache tzdata git
COPY . /opt/sofie-inews-gateway
WORKDIR /opt/sofie-inews-gateway
RUN yarn install --production
EXPOSE 3007
CMD ["yarn", "start"]
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@tv2media/inews-gateway",
"version": "46.3.0-staging",
"version": "46.3.2-staging",
"description": "",
"main": "dist/index.js",
"contributors": [
Expand Down
60 changes: 60 additions & 0 deletions src/helpers/ResolveRundownIntoPlaylist.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,13 @@ export function ResolveRundownIntoPlaylist(
let klarOnAirStoryFound = false

for (const segment of segments) {
if (shouldLookForShowstyleVariant(segment, resolvedRundown)) {
const showstyleVariantsForSegment = getOrderedShowstyleVariants(segment)
if (showstyleVariantsForSegment.length > 0) {
setShowstyleVariant(resolvedRundown, showstyleVariantsForSegment[0])
}
}

resolvedRundown.segments.push(segment.externalId)

const isFloated = segment.iNewsStory.meta.float ?? false
Expand All @@ -51,6 +58,59 @@ export function ResolveRundownIntoPlaylist(
return { resolvedRundown, untimedSegments }
}

function shouldLookForShowstyleVariant(segment: UnrankedSegment, rundown: ResolvedPlaylistRundown): boolean {
const isFloated: boolean = !!segment.iNewsStory.meta.float ?? false
const hasShowstyleVariant: boolean = rundown.payload?.showstyleVariant !== undefined
return !isFloated && !hasShowstyleVariant
}

function getOrderedShowstyleVariants(segment: UnrankedSegment): string[] {
const cueOrder: number[] = getCueOrder(segment)
const orderedShowstyleVariants: string[] = []
cueOrder.forEach((cueIndex: number) => {
const parsedProfile: string | null = parseShowstyleVariant(segment.iNewsStory.cues[cueIndex] ?? [])
if (parsedProfile) {
orderedShowstyleVariants.push(parsedProfile)
}
})
return orderedShowstyleVariants
}

function parseShowstyleVariant(cue: string[]): string | null {
const numberOfCueLines: number = cue.length

// Kommando cue (ignoring timing)
const showstyleVariantPattern: RegExp = /^\s*SOFIE\s*=\s*SHOWSTYLEVARIANT/i
if (numberOfCueLines >= 2 && showstyleVariantPattern.test(cue![0])) {
return cue![1].trim()
}
return null
}

/**
*
* @param segment The segment for which the cue order should be retrieved
* @returns A list of indicies representing the cue order.
*/
function getCueOrder(segment: UnrankedSegment): number[] {
const body = segment.iNewsStory.body ?? ''
const refPattern = /<a\s+idref="(?<id>\d+)"\s*\/?>/gi
const order: number[] = []
let match: RegExpExecArray | null
while ((match = refPattern.exec(body))) {
let id = parseInt(match.groups!.id, 10)
order.push(id)
}
return order
}

function setShowstyleVariant(rundown: ResolvedPlaylistRundown, showstyleVariant: string) {
rundown.payload = {
...(rundown.payload ?? null),
showstyleVariant,
}
}

function isKlarOnAir(segment: UnrankedSegment): boolean {
const klarOnAirPattern = /klar[\s-]*on[\s-]*air/im
return !!segment.name?.match(klarOnAirPattern)
Expand Down