File size: 1,081 Bytes
8dd5bba
 
 
 
 
 
 
 
 
dba0530
 
 
 
8dd5bba
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
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));
      }
    }
  }
}