Skip to content

Commit

Permalink
also look for followup and followup-short videos
Browse files Browse the repository at this point in the history
  • Loading branch information
mradamcox committed Apr 19, 2024
1 parent 4e5466b commit cb1f7e4
Showing 1 changed file with 24 additions and 2 deletions.
26 changes: 24 additions & 2 deletions scripts/update-cdn.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,8 @@ export interface PublicSubmission {
title: string
tags: string[]
shortPresent: boolean
followupPresent: boolean
followupShortPresent: boolean
}

async function main() {
Expand Down Expand Up @@ -120,6 +122,8 @@ async function main() {
}

const shortVideos: String[] = []
const followupVideos: String[] = []
const followupShortVideos: String[] = []

// loop through public files
// if missing from uplodas, this means they were delete
Expand All @@ -130,13 +134,25 @@ async function main() {
const fileType = '.' + Key?.split('.').slice(-1)[0]
if (fileType === ".vtt") continue

let vidId: String
// look for "...-short" videos, add to lookup array, and don't delete
if (Key?.includes("-short")) {
let vidId: String
vidId = id ? id.split("-")[0] : ""
vidId = id ? id.split("-short")[0] : ""
shortVideos.push(vidId)
continue
}
// look for "...-followup" videos, add to lookup array, and don't delete
if (Key?.includes("-followup")) {
vidId = id ? id.split("-followup")[0] : ""
followupVideos.push(vidId)
continue
}
// look for "...-followup-short" videos, add to lookup array, and don't delete
if (Key?.includes("-followup-short")) {
vidId = id ? id.split("-followup-short")[0] : ""
followupShortVideos.push(vidId)
continue
}

const uploadFile = uploadContents.find(
({ id: uploadId }) => uploadId === id
Expand Down Expand Up @@ -168,6 +184,8 @@ async function main() {
if (submission) {
const { title, fips, storyType, theme, tags } = submission
const shortPresent = shortVideos.includes(id);
const followupPresent = followupVideos.includes(id);
const followupShortPresent = followupShortVideos.includes(id);
return {
id,
title,
Expand All @@ -177,6 +195,8 @@ async function main() {
type: storyType,
fileType,
shortPresent,
followupPresent,
followupShortPresent,
}
} else {
return {
Expand All @@ -188,6 +208,8 @@ async function main() {
type: '',
fileType: '',
shortPresent: false,
followupPresent: false,
followupShortPresent: false,
}
}
})
Expand Down

0 comments on commit cb1f7e4

Please sign in to comment.