From 96f4c9027796b86ea31a2ff2426e763558368f4f Mon Sep 17 00:00:00 2001 From: Luca Armaroli Date: Wed, 9 Sep 2020 04:54:17 +0200 Subject: [PATCH] - removed useless function/properties - added filename property to Video type --- src/Types.ts | 10 ++++++++-- src/VideoUtils.ts | 41 +++++++++++++++++++++-------------------- 2 files changed, 29 insertions(+), 22 deletions(-) diff --git a/src/Types.ts b/src/Types.ts index 4fc5076..ebcc40e 100644 --- a/src/Types.ts +++ b/src/Types.ts @@ -6,6 +6,7 @@ export type Session = { export type Video = { + // the following properties are all for the title template title: string; duration: string; publishDate: string; @@ -13,11 +14,16 @@ export type Video = { author: string; authorEmail: string; uniqueId: string; - outPath: string; - totalChunks: number; // Abstraction of FFmpeg timemark + + // the following properties are all the urls neede for the download playbackUrl: string; posterImageUrl: string; captionsUrl?: string + + // final filename, already sanitized and unique + filename: string; + // complete path to save the video + outPath: string; } diff --git a/src/VideoUtils.ts b/src/VideoUtils.ts index 21cfdb9..804b1b2 100644 --- a/src/VideoUtils.ts +++ b/src/VideoUtils.ts @@ -36,18 +36,11 @@ function isoDurationToString(time: string): string { } -function durationToTotalChunks(duration: string): number { - const durationObj: any = parseDuration(duration); - const hrs: number = durationObj.hours ?? 0; - const mins: number = durationObj.minutes ?? 0; - const secs: number = Math.ceil(durationObj.seconds ?? 0); +export async function getVideosInfo(videoGuids: Array, + session: Session, subtitles?: boolean): Promise> { - return (hrs * 60) + mins + (secs / 60); -} - - -export async function getVideoInfo(videoGuids: Array, session: Session, subtitles?: boolean): Promise> { let metadata: Array