Просмотр исходного кода

Update package name, rename types

Use appropriate names for some things.
master
TheoryOfNekomata 1 год назад
Родитель
Сommit
016cb99175
3 измененных файлов: 13 добавлений и 11 удалений
  1. +1
    -1
      package.json
  2. +9
    -7
      src/index.ts
  3. +3
    -3
      test/index.test.ts

+ 1
- 1
package.json Просмотреть файл

@@ -1,5 +1,5 @@
{
"name": "youtube-clip-core",
"name": "@modal/webvideo-clip-core",
"version": "0.0.0",
"files": [
"dist",


+ 9
- 7
src/index.ts Просмотреть файл

@@ -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,


+ 3
- 3
test/index.test.ts Просмотреть файл

@@ -4,7 +4,7 @@ import {
import { spawnSync } from 'child_process';
import { readFileSync, unlinkSync } from 'fs';
import * as webVideoClipCore from '../src';
import { ClipEventEmitter } from '../src';
import { VideoClipEventEmitter } from '../src';

vi.mock('child_process', () => ({
spawnSync: vi.fn(),
@@ -21,7 +21,7 @@ describe('createVideoClipper', () => {
});

describe('with postprocessing', () => {
let clipper: ClipEventEmitter;
let clipper: VideoClipEventEmitter;
beforeEach(() => {
clipper = webVideoClipCore.createVideoClipper({
downloaderExecutablePath: 'yt-dlp',
@@ -107,7 +107,7 @@ describe('createVideoClipper', () => {
});

describe('without postprocessing', () => {
let clipper: ClipEventEmitter;
let clipper: VideoClipEventEmitter;
beforeEach(() => {
clipper = webVideoClipCore.createVideoClipper({
downloaderExecutablePath: 'yt-dlp',


Загрузка…
Отмена
Сохранить