Clip Web videos.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

28 lines
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. };