(server)
| 13 | name: 'revideo:exporter', |
| 14 | |
| 15 | configureServer(server) { |
| 16 | server.middlewares.use((req, res, next) => { |
| 17 | if (req.url === '/__open-output-path') { |
| 18 | if (!fs.existsSync(outputPath)) { |
| 19 | fs.mkdirSync(outputPath, {recursive: true}); |
| 20 | } |
| 21 | openInExplorer(outputPath); |
| 22 | res.end(); |
| 23 | return; |
| 24 | } |
| 25 | |
| 26 | next(); |
| 27 | }); |
| 28 | |
| 29 | server.ws.on( |
| 30 | 'revideo:export', |
| 31 | async ( |
| 32 | {data, frame, sceneFrame, subDirectories, mimeType, groupByScene}, |
| 33 | client, |
| 34 | ) => { |
| 35 | const name = (groupByScene ? sceneFrame : frame) |
| 36 | .toString() |
| 37 | .padStart(6, '0'); |
| 38 | const extension = mime.extension(mimeType); |
| 39 | const outputFilePath = path.join( |
| 40 | outputPath, |
| 41 | ...subDirectories, |
| 42 | `${name}.${extension}`, |
| 43 | ); |
| 44 | const outputDirectory = path.dirname(outputFilePath); |
| 45 | |
| 46 | if (!fs.existsSync(outputDirectory)) { |
| 47 | fs.mkdirSync(outputDirectory, {recursive: true}); |
| 48 | } |
| 49 | |
| 50 | const base64Data = data.slice(data.indexOf(',') + 1); |
| 51 | await fs.promises.writeFile(outputFilePath, base64Data, { |
| 52 | encoding: 'base64', |
| 53 | }); |
| 54 | client.send('revideo:export-ack', {frame}); |
| 55 | }, |
| 56 | ); |
| 57 | }, |
| 58 | }; |
| 59 | } |
nothing calls this directly
no test coverage detected