Browse Source

Fix weird file extension

Normalize file extension when getting download.
master
TheoryOfNekomata 1 year ago
parent
commit
099febf279
2 changed files with 6 additions and 1 deletions
  1. +5
    -0
      src/common.ts
  2. +1
    -1
      src/video-types/youtube.ts

+ 5
- 0
src/common.ts View File

@@ -4,11 +4,16 @@ type ProcessEventCallback = (event: ProcessEvent) => void;


type ErrorEventCallback = (event: Error) => void; type ErrorEventCallback = (event: Error) => void;


type SuccessEvent = { type: string, output: Buffer };

type SuccessEventCallback = (event: SuccessEvent) => void;

export interface VideoClipEventEmitter extends NodeJS.EventEmitter { export interface VideoClipEventEmitter extends NodeJS.EventEmitter {
process(): void; process(): void;
on(eventType: 'process', callback: ProcessEventCallback): this; on(eventType: 'process', callback: ProcessEventCallback): this;
on(eventType: 'error', callback: ErrorEventCallback): this; on(eventType: 'error', callback: ErrorEventCallback): this;
on(eventType: 'end', callback: ErrorEventCallback): this; on(eventType: 'end', callback: ErrorEventCallback): this;
on(eventType: 'success', callback: SuccessEventCallback): this;
} }


export const FILE_TYPES: Record<string, string> = { export const FILE_TYPES: Record<string, string> = {


+ 1
- 1
src/video-types/youtube.ts View File

@@ -35,7 +35,7 @@ const getFileExtension = (downloaderExecutablePath: string, url: string) => {
throw result.error; throw result.error;
} }


return result.stdout.toString('utf-8');
return result.stdout.toString('utf-8').trim();
}; };


const constructDownloadSectionsRegex = (start?: number | string, end?: number | string) => { const constructDownloadSectionsRegex = (start?: number | string, end?: number | string) => {


Loading…
Cancel
Save