diff --git a/src/core/episodeRepo.js b/src/core/episodeRepo.js index 5f13d0f..2860c1e 100644 --- a/src/core/episodeRepo.js +++ b/src/core/episodeRepo.js @@ -65,6 +65,29 @@ export function updateVideoPathBySlug(showSlug, episodeSlug, videoPath) { } ); } +export function updatePublicAudio(showSlug, episodeSlug, publicAudioFile) { + return Database.collection('posts').updateOne( + { + showSlug: showSlug, + slug: episodeSlug + }, + { + $set: { publicAudioFile: publicAudioFile } + } + ); +} + +export function updateAudioPathBySlug(showSlug, episodeSlug, audioPath) { + return Database.collection('posts').updateOne( + { + showSlug: showSlug, + slug: episodeSlug + }, + { + $set: { audioPath: audioPath } + } + ); +} export function updateTimeCodeBySlug(showSlug, episodeSlug, index, time, description, isPublicValue) { const timeInSeconds = time.split(':').reduce((acc, time) => (60 * acc) + +time, 0); @@ -107,9 +130,6 @@ export function updateMontageStatusBySlug(showSlug, episodeSlug, status) { return Database.collection('posts').updateOne({ slug: episodeSlug, showSlug: showSlug }, { $set: { montage_status: status } }); } -export function updatePublicAudio(showSlug, episodeSlug, publicAudioFile) { - return Database.collection('posts').updateOne({ showSlug: showSlug, slug: episodeSlug }, { $set: { publicAudioFile: publicAudioFile } }); -} export function publishPodcast(showSlug, episodeSlug) { return Database.collection('posts').updateOne({ showSlug: showSlug, slug: episodeSlug }, { $set: { visibility: 'public' } }); diff --git a/src/montage/publicAudioGenerator.js b/src/montage/publicAudioGenerator.js index fe6c8bd..15f9318 100644 --- a/src/montage/publicAudioGenerator.js +++ b/src/montage/publicAudioGenerator.js @@ -34,7 +34,7 @@ async function createPublicAudioJob(podcast) { complexFilterString += `concat=n=${publicIndex - 1}:v=0:a=1`; - await applyFFmpegToFileInMinio(podcast.originFilePath, podcast.publicAudioFile, complexFilterString) + await applyFFmpegToFileInMinio(podcast.audioPath, podcast.publicAudioFile, complexFilterString) } export async function createPublicAudio(podcast) { diff --git a/src/routers/admin/detail/getDetails.js b/src/routers/admin/detail/getDetails.js index 4bbd3c9..ab711fe 100644 --- a/src/routers/admin/detail/getDetails.js +++ b/src/routers/admin/detail/getDetails.js @@ -12,18 +12,9 @@ async function getPodcastDetails(request, h) { showAudio: false, showVideo: false, showUploadVideoButton: true, - audioUrl: buildObjectURL(podcast.originFilePath), + audioUrl: buildObjectURL(podcast.audioPath), uploadUrl: `/admin/show/${showSlug}/episode/${episodeSlug}/upload`, } - if (podcast.videoPath && podcast.originFilePath) { - media = { - showAudio: true, - showVideo: true, - showUploadVideoButton: false, - videoUrl: buildObjectURL(podcast.videoPath), - audioUrl: buildObjectURL(podcast.originFilePath), - } - } if (podcast.videoPath) { media = { showAudio: false, @@ -40,6 +31,15 @@ async function getPodcastDetails(request, h) { audioUrl: buildObjectURL(podcast.originFilePath), } } + if (podcast.videoPath && podcast.audioPath) { + media = { + showAudio: true, + showVideo: true, + showUploadVideoButton: false, + videoUrl: buildObjectURL(podcast.videoPath), + audioUrl: buildObjectURL(podcast.audioPath), + } + } media.showSlug = showSlug; media.episodeSlug = episodeSlug; diff --git a/src/routers/admin/detail/mediaMontage.js b/src/routers/admin/detail/mediaMontage.js index 7085fe3..da5d02b 100644 --- a/src/routers/admin/detail/mediaMontage.js +++ b/src/routers/admin/detail/mediaMontage.js @@ -1,5 +1,6 @@ -import { getPostBySlug } from "../../../core/episodeRepo.js"; +import { getPostBySlug, updateAudioPathBySlug } from "../../../core/episodeRepo.js"; import { applyFFmpegToFileInMinio } from "../../../minio/ffmpegApply.js"; +import { buildObjectURL } from "../../../minio/utils.js"; async function buildAudio(request, h) { const showSlug = request.params.showSlug; @@ -7,8 +8,24 @@ async function buildAudio(request, h) { const episode = await getPostBySlug(showSlug, episodeSlug); const audioPath = `${showSlug}/episodes/${episodeSlug}/full-audio.wav`; await applyFFmpegToFileInMinio(episode.videoPath, audioPath); + await updateAudioPathBySlug(showSlug, episodeSlug, audioPath); console.log('Building audio for episode', showSlug, episodeSlug); + return h.view( + 'media_component', + { + showSlug: showSlug, + episodeSlug: episodeSlug, + showAudio: true, + showVideo: true, + audioUrl: buildObjectURL(audioPath), + videoUrl: buildObjectURL(episode.videoPath), + showUploadVideoButton: false, + }, + { + layout: false + } + ) } export function media(server) { diff --git a/src/templates/widgets/media_component.html b/src/templates/widgets/media_component.html index 3c53625..e15b3fa 100644 --- a/src/templates/widgets/media_component.html +++ b/src/templates/widgets/media_component.html @@ -1,36 +1,39 @@ -{{#if showAudio}} -