Skip to content

Commit

Permalink
remove DefaultExtractor test as it's already incompatible with LocalE…
Browse files Browse the repository at this point in the history
…xtractProcessor (#39)
  • Loading branch information
EverettSummer authored Jan 18, 2023
1 parent ab45795 commit a93d2bb
Showing 1 changed file with 60 additions and 57 deletions.
117 changes: 60 additions & 57 deletions src/processors/LocalExtractProcessor.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import { LocalExtractProcessor } from './LocalExtractProcessor';
import { Vertex } from '../entity/Vertex';
import { ActionType } from '../domains/ActionType';
import { DefaultExtractor } from './extractors/DefaultExtractor';
import { rm } from 'fs/promises';
import { copyFile, rm } from 'fs/promises';
import { JobMessage } from '../domains/JobMessage';
import { randomUUID } from 'crypto';

Expand Down Expand Up @@ -69,62 +69,62 @@ test.after(async(t) => {
// }
// });

test('DefaultExtractor', async (t) => {
const context = t.context as Cxt;
const fileManager = context.container.get<FileManageService>(FileManageService);
const videoProcessor1 = context.container.get<VideoProcessor>(LocalExtractProcessor);

videoProcessor1.registerLogHandler((log, ch) => {
if (ch === 'stderr') {
console.error(log);
} else {
console.log(log);
}
});

const jobMessage = prepareJobMessage(testVideoFile, [testSubtitleFile]);

const videoExtractAction = new ExtractAction();
videoExtractAction.extractorId = DefaultExtractor.Id;
videoExtractAction.extractTarget = ExtractTarget.KeepContainer;
videoExtractAction.extractFrom = ExtractSource.VideoFile;

const videoExtractVertex = new Vertex();
videoExtractVertex.actionType = ActionType.Extract;
videoExtractVertex.action = videoExtractAction;
videoExtractVertex.jobId = jobMessage.jobId;

await videoProcessor1.prepare(jobMessage, videoExtractVertex);
await videoProcessor1.process(videoExtractVertex);
console.log(videoExtractVertex.outputPath);
t.true(await fileManager.checkExists(basename(videoExtractVertex.outputPath), jobMessage.id));

// subtitle extraction
const videoProcessor2 = context.container.get<VideoProcessor>(LocalExtractProcessor);

videoProcessor2.registerLogHandler((log, ch) => {
if (ch === 'stderr') {
console.error(log);
} else {
console.log(log);
}
});
const subExtractAction = new ExtractAction();
subExtractAction.extractorId = 'Default';
subExtractAction.extractTarget = ExtractTarget.Subtitle;
subExtractAction.extractFrom = ExtractSource.OtherFiles;
subExtractAction.outputExtname = 'ass'

const subExtractVertex = new Vertex();
subExtractVertex.actionType = ActionType.Extract;
subExtractVertex.action = subExtractAction;
subExtractVertex.jobId = jobMessage.jobId;

await videoProcessor2.prepare(jobMessage, subExtractVertex);
await videoProcessor2.process(subExtractVertex);
console.log(subExtractVertex.outputPath);
t.true(await fileManager.checkExists(basename(subExtractVertex.outputPath), jobMessage.id));
});
// test('DefaultExtractor', async (t) => {
// const context = t.context as Cxt;
// const fileManager = context.container.get<FileManageService>(FileManageService);
// const videoProcessor1 = context.container.get<VideoProcessor>(LocalExtractProcessor);
//
// videoProcessor1.registerLogHandler((log, ch) => {
// if (ch === 'stderr') {
// console.error(log);
// } else {
// console.log(log);
// }
// });
//
// const jobMessage = prepareJobMessage(testVideoFile, [testSubtitleFile]);
//
// const videoExtractAction = new ExtractAction();
// videoExtractAction.extractorId = DefaultExtractor.Id;
// videoExtractAction.extractTarget = ExtractTarget.KeepContainer;
// videoExtractAction.extractFrom = ExtractSource.VideoFile;
//
// const videoExtractVertex = new Vertex();
// videoExtractVertex.actionType = ActionType.Extract;
// videoExtractVertex.action = videoExtractAction;
// videoExtractVertex.jobId = jobMessage.jobId;
//
// await videoProcessor1.prepare(jobMessage, videoExtractVertex);
// await videoProcessor1.process(videoExtractVertex);
// console.log(videoExtractVertex.outputPath);
// t.true(videoExtractVertex.outputPath === fileManager.getLocalPath(jobMessage.videoFile.filename, jobMessage.id));
//
// // subtitle extraction
// const videoProcessor2 = context.container.get<VideoProcessor>(LocalExtractProcessor);
//
// videoProcessor2.registerLogHandler((log, ch) => {
// if (ch === 'stderr') {
// console.error(log);
// } else {
// console.log(log);
// }
// });
// const subExtractAction = new ExtractAction();
// subExtractAction.extractorId = 'Default';
// subExtractAction.extractTarget = ExtractTarget.Subtitle;
// subExtractAction.extractFrom = ExtractSource.OtherFiles;
// subExtractAction.outputExtname = 'ass'
//
// const subExtractVertex = new Vertex();
// subExtractVertex.actionType = ActionType.Extract;
// subExtractVertex.action = subExtractAction;
// subExtractVertex.jobId = jobMessage.jobId;
//
// await videoProcessor2.prepare(jobMessage, subExtractVertex);
// await videoProcessor2.process(subExtractVertex);
// console.log(subExtractVertex.outputPath);
// t.true(subExtractVertex.outputPath === fileManager.getLocalPath(jobMessage.otherFiles[0].filename, jobMessage.id));
// });

test('DefaultExtractor extract ass from mkv', async (t) => {
const context = t.context as Cxt;
Expand All @@ -139,6 +139,9 @@ test('DefaultExtractor extract ass from mkv', async (t) => {
});
const jobMessage = prepareJobMessage('test-video-with-sub.mkv');

// copy file to temp folder
await fileManager.downloadFile(jobMessage.videoFile, jobMessage.downloadAppId, jobMessage.id);

const action = new ExtractAction();
action.extractorId = DefaultExtractor.Id;
action.extractTarget = ExtractTarget.Subtitle;
Expand Down

0 comments on commit a93d2bb

Please sign in to comment.