Clip Web videos.
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

28 行
881 B

  1. import * as YouTubeImpl from './video-types/youtube';
  2. const SUPPORTED_VIDEO_TYPES = [
  3. YouTubeImpl,
  4. ] as const;
  5. export type CreateClipperParams = (
  6. YouTubeImpl.CreateClipperParams
  7. );
  8. export type VideoType = typeof YouTubeImpl.VIDEO_TYPE;
  9. export * as YouTube from './video-types/youtube';
  10. export * from './common';
  11. export const createVideoClipper = (params: CreateClipperParams) => {
  12. const { type: videoType, ...etcParams } = params;
  13. const theVideoTypeModule = SUPPORTED_VIDEO_TYPES
  14. .find((videoTypeModule) => videoTypeModule.VIDEO_TYPE === videoType);
  15. if (!theVideoTypeModule) {
  16. const validVideoTypes = SUPPORTED_VIDEO_TYPES.map((videoTypeModule) => videoTypeModule.VIDEO_TYPE).join(', ');
  17. throw new TypeError(`Invalid video type: "${videoType}". Valid values are: ${validVideoTypes}`);
  18. }
  19. return theVideoTypeModule.createVideoClipper(etcParams);
  20. };