Spaces:
Running
Running
| import path from "path"; | |
| import { Plugin } from "./plugin.js"; | |
| export class FlattenPathsPlugin extends Plugin { | |
| constructor(name, options) { | |
| super(name, options); | |
| } | |
| async applyPrerender(originalManuscript, jobId) { | |
| let transcript = originalManuscript.transcript | |
| if (originalManuscript.bgMusic) { | |
| originalManuscript.bgMusic = path.join('public', path.basename(originalManuscript.bgMusic)); | |
| } | |
| for (let item of transcript) { | |
| if (item.mediaAbsPaths && item.mediaAbsPaths.length > 0) { | |
| item.mediaAbsPaths = item.mediaAbsPaths.map((mediaObj) => { | |
| let flattenedPath = path.join('public', path.basename(mediaObj.path)); | |
| return { | |
| ...mediaObj, | |
| path: flattenedPath, | |
| }; | |
| }); | |
| } | |
| if (item.audioCaptionFile) { | |
| item.audioCaptionFile = path.join('public', path.basename(item.audioCaptionFile)); | |
| } | |
| if (item.audioFullPath) { | |
| item.audioFullPath = path.join('public', path.basename(item.audioFullPath)); | |
| } | |
| } | |
| } | |
| } |