Skip to content
Snippets Groups Projects
Commit 966236a1 authored by Tianyi Liang's avatar Tianyi Liang
Browse files

[SD-235] trial

parent 219159f3
No related branches found
No related tags found
1 merge request!562Resolve SD-235 "Feat/ booth screen video"
......@@ -293,9 +293,7 @@ export class VideosService {
teamID,
TeamArtifactType.PROJECT_PROMOTION,
)
).find(
(video) => video.value.language === 'en',
)
).find((video) => video.value.language === 'en')
if (promotionVideo == null) {
continue
}
......@@ -307,6 +305,10 @@ export class VideosService {
continue
}
if (!fs.existsSync('./tmp')) {
await fs.promises.mkdir('./tmp', { recursive: true })
}
await this.downloadFile(
`https://static.igem.org/${videoFileKey}`,
`./tmp/${teamID}-${slug}.mp4`,
......@@ -360,4 +362,82 @@ export class VideosService {
throw e
}
}
async generateBoothVideoByTeamID(
teamID: number,
author: AccountUUID,
event: ActivityLogEvent,
): Promise<void> {
try {
const { year, slug } = await this.teams.findOne(teamID)
const promotionVideo = (
await this.videoSubmissions.fetchAllByTeam(
teamID,
TeamArtifactType.PROJECT_PROMOTION,
)
).find((video) => video.value.language === 'en')
if (promotionVideo == null) {
return
}
const { videoFileKey, captionFileKeys } = promotionVideo.value
const mainCaptionFileKey = captionFileKeys?.find((key) =>
key.includes('en'),
)
if (mainCaptionFileKey == null) {
return
}
await this.downloadFile(
`https://static.igem.org/${videoFileKey}`,
`./tmp/${teamID}-${slug}.mp4`,
)
await this.downloadFile(
`https://static.igem.org/${mainCaptionFileKey}`,
`./tmp/${teamID}-${slug}.vtt`,
)
await this.downloadFile(
`https://static.igem.org/websites/jamboree/2024/overlays/${teamID}-${slug}.png`,
`./tmp/${teamID}-${slug}-overlay.png`,
)
await this.embedCaption(teamID, slug).then(async () => {
fs.unlinkSync(`./tmp/${teamID}-${slug}.mp4`)
fs.unlinkSync(`./tmp/${teamID}-${slug}.vtt`)
})
await this.embedOverlay(teamID, slug).then(async () => {
const file = fs.readFileSync(`./tmp/overlayed-${teamID}-${slug}.mp4`)
const key = `websites/jamboree/2024/videos/${year}/${teamID}-${slug}.mp4`
await this.s3
.uploadObject({
key,
body: file,
contentType: 'video/mp4',
})
.then(async () => {
fs.unlinkSync(`./tmp/${teamID}-${slug}-overlay.png`)
fs.unlinkSync(`./tmp/overlayed-${teamID}-${slug}.mp4`)
})
})
await this.activityLogs.insert(
{
event,
status: ActivityLogEventStatus.COMPLETED,
},
author,
)
} catch (e) {
await this.activityLogs.insert(
{
event,
status: ActivityLogEventStatus.FAILED,
metadata: { e },
},
author,
)
throw e
}
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment