add processVideo env

This commit is contained in:
waveringana 2025-05-11 19:16:02 -04:00
parent 3605a3f3a5
commit 170479b585
8 changed files with 89 additions and 27 deletions

View file

@ -11,10 +11,12 @@ class ProgressManager {
private static instance: ProgressManager;
private emitter: EventEmitter;
private activeJobs: Map<string, ProgressUpdate>;
private processVideo: boolean;
private constructor() {
this.emitter = new EventEmitter();
this.activeJobs = new Map();
this.processVideo = process.env["EB_PROCESS_VIDEO"] === "true";
}
static getInstance(): ProgressManager {
@ -25,19 +27,27 @@ class ProgressManager {
}
updateProgress(update: ProgressUpdate) {
if (!this.processVideo) return;
this.activeJobs.set(update.filename, update);
this.emitter.emit('progress', update);
}
subscribeToUpdates(callback: (update: ProgressUpdate) => void) {
if (!this.processVideo) return;
this.emitter.on('progress', callback);
}
unsubscribeFromUpdates(callback: (update: ProgressUpdate) => void) {
if (!this.processVideo) return;
this.emitter.off('progress', callback);
}
getJobStatus(filename: string): ProgressUpdate | undefined {
if (!this.processVideo) return undefined;
return this.activeJobs.get(filename);
}
}