-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Vova Stelmashchuk
committed
Aug 5, 2024
1 parent
5e91a77
commit cb9d993
Showing
12 changed files
with
227 additions
and
55 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
import { updateMontageStatusBySlug } from '../core/episodeRepo.js'; | ||
import { applyFFmpegToFileInMinio } from '../minio/ffmpegApply.js'; | ||
|
||
async function createPublicAudioJob(podcast) { | ||
const chapters = podcast.charters; | ||
|
||
let complexFilterString = ''; | ||
let publicIndex = 1; | ||
|
||
chapters.forEach((chapter, index) => { | ||
if (chapter.isPublic !== false) { | ||
const chapterStartSecond = chapter.timeInSeconds; | ||
const chapterEndSecond = chapters[index + 1]?.timeInSeconds; | ||
|
||
const filterStart = `[0]atrim=start=${chapterStartSecond}`; | ||
|
||
let filterMainPart = '' | ||
|
||
if (chapterEndSecond !== undefined) { | ||
filterMainPart = `${filterStart}:end=${chapterEndSecond}`; | ||
} else { | ||
filterMainPart = `${filterStart}`; | ||
} | ||
|
||
complexFilterString += `${filterMainPart},asetpts=PTS-STARTPTS[a${publicIndex}]; `; | ||
publicIndex++; | ||
} | ||
}); | ||
|
||
// add part with [a0]...[a<publicIndex>] | ||
for (let i = 1; i < publicIndex; i++) { | ||
complexFilterString += `[a${i}]`; | ||
} | ||
|
||
complexFilterString += `concat=n=${publicIndex - 1}:v=0:a=1`; | ||
|
||
await applyFFmpegToFileInMinio(podcast.origin_file, `episodes/${podcast.slug}.mp3`, complexFilterString) | ||
} | ||
|
||
export async function createPublicAudio(podcast) { | ||
await modifyPodcastStatus(podcast.slug, 'in_progress'); | ||
|
||
createPublicAudioJob(podcast) | ||
.then(async () => { | ||
await modifyPodcastStatus(podcast.slug, 'success'); | ||
console.log('Public audio creation successful.'); | ||
}) | ||
.catch(async (error) => { | ||
await modifyPodcastStatus(podcast.slug, 'failure'); | ||
console.error('Public audio creation failed:', error); | ||
}); | ||
|
||
return { status: 'in-progress' }; | ||
} | ||
|
||
async function modifyPodcastStatus(slug, status) { | ||
updateMontageStatusBySlug(slug, status); | ||
console.log(`Updating podcast status to ${status} for ${slug}`); | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,18 @@ | ||
<html> | ||
|
||
<head> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>Android story podcast</title> | ||
<link href="/public/styles.css" rel="stylesheet"> | ||
<script src="https://unpkg.com/[email protected]"></script> | ||
<meta charset="UTF-8"> | ||
<meta name="viewport" content="width=device-width, initial-scale=1.0"> | ||
<title>Android story podcast</title> | ||
<link href="/public/styles.css" rel="stylesheet"> | ||
<script src="https://unpkg.com/[email protected]"></script> | ||
</head> | ||
|
||
<body class="bg-gray-100 text-gray-900 font-sans"> | ||
{{> head}} | ||
<div class="container max-w-screen-xl mx-auto py-8"> | ||
{{> head}} | ||
<div class="container max-w-screen-xl mx-auto py-8"> | ||
{{{ content }}} | ||
</div> | ||
</div> | ||
</body> | ||
</html> | ||
|
||
</html> |
Oops, something went wrong.