|
|
@@ -6,18 +6,18 @@ export enum VideoType { |
|
|
|
YOUTUBE = 'youtube', |
|
|
|
} |
|
|
|
|
|
|
|
interface ClipVideoBaseParams { |
|
|
|
interface CreateBaseClipperParams { |
|
|
|
url: string; |
|
|
|
start?: number | string; |
|
|
|
end?: number | string; |
|
|
|
postprocessorExecutablePath?: string; |
|
|
|
} |
|
|
|
|
|
|
|
interface ClipYouTubeVideoParams extends ClipVideoBaseParams { |
|
|
|
interface CreateYouTubeClipperParams extends CreateBaseClipperParams { |
|
|
|
downloaderExecutablePath?: string; |
|
|
|
} |
|
|
|
|
|
|
|
interface ClipVideoParams extends ClipYouTubeVideoParams { |
|
|
|
export interface CreateVideoClipperParams extends CreateYouTubeClipperParams { |
|
|
|
type: VideoType, |
|
|
|
} |
|
|
|
|
|
|
@@ -54,12 +54,12 @@ const getCacheFilename = () => { |
|
|
|
return `output-${time}.mkv`; |
|
|
|
}; |
|
|
|
|
|
|
|
export interface ClipEventEmitter extends EventEmitter { |
|
|
|
export interface VideoClipEventEmitter extends EventEmitter { |
|
|
|
process(): void; |
|
|
|
} |
|
|
|
|
|
|
|
class YouTubeVideoClipEventEmitter extends EventEmitter implements ClipEventEmitter { |
|
|
|
constructor(private readonly params: ClipYouTubeVideoParams) { |
|
|
|
class YouTubeVideoClipEventEmitter extends EventEmitter implements VideoClipEventEmitter { |
|
|
|
constructor(private readonly params: CreateYouTubeClipperParams) { |
|
|
|
super(); |
|
|
|
} |
|
|
|
|
|
|
@@ -140,6 +140,7 @@ class YouTubeVideoClipEventEmitter extends EventEmitter implements ClipEventEmit |
|
|
|
const output = readFileSync(cacheFilename); |
|
|
|
unlinkSync(cacheFilename); |
|
|
|
this.emit('success', { |
|
|
|
type: 'video/webm', |
|
|
|
output, |
|
|
|
}); |
|
|
|
this.emit('end'); |
|
|
@@ -224,6 +225,7 @@ class YouTubeVideoClipEventEmitter extends EventEmitter implements ClipEventEmit |
|
|
|
const output = readFileSync(cacheFilename); |
|
|
|
unlinkSync(cacheFilename); |
|
|
|
this.emit('success', { |
|
|
|
type: 'video/webm', |
|
|
|
output, |
|
|
|
}); |
|
|
|
this.emit('end'); |
|
|
@@ -244,7 +246,7 @@ class YouTubeVideoClipEventEmitter extends EventEmitter implements ClipEventEmit |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
export const createVideoClipper = (params: ClipVideoParams) => { |
|
|
|
export const createVideoClipper = (params: CreateVideoClipperParams) => { |
|
|
|
const { |
|
|
|
type: videoType, |
|
|
|
url, |
|
|
|