From a4ac0f01465553803afe8324b9a76a1f1f5ae456 Mon Sep 17 00:00:00 2001 From: Adam Mischke Date: Thu, 19 Aug 2021 18:12:53 -0500 Subject: [PATCH] add filePath to Downloader --- src/core/Downloader.ts | 7 +++++-- src/core/TikTok.ts | 1 + src/entry.ts | 2 +- src/types/Downloader.ts | 1 + 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/core/Downloader.ts b/src/core/Downloader.ts index 9058bbad..caa917ed 100644 --- a/src/core/Downloader.ts +++ b/src/core/Downloader.ts @@ -27,18 +27,21 @@ export class Downloader { public filepath: string; + public fileName: string; + public bulk: boolean; public headers: Headers; public cookieJar: CookieJar; - constructor({ progress, proxy, noWaterMark, headers, filepath, bulk, cookieJar }: DownloaderConstructor) { + constructor({ progress, proxy, noWaterMark, headers, filepath, fileName, bulk, cookieJar }: DownloaderConstructor) { this.progress = true || progress; this.progressBar = []; this.noWaterMark = noWaterMark; this.headers = headers; this.filepath = filepath; + this.fileName = fileName this.mbars = new MultipleBar(); this.proxy = proxy; this.bulk = bulk; @@ -209,6 +212,6 @@ export class Downloader { const result = await rp(options); - await fromCallback(cb => writeFile(`${this.filepath}/${post.id}.mp4`, result, cb)); + await fromCallback(cb => writeFile(`${this.filepath}/${this.fileName || post.id}.mp4`, result, cb)); } } diff --git a/src/core/TikTok.ts b/src/core/TikTok.ts index fe098905..677eccfd 100644 --- a/src/core/TikTok.ts +++ b/src/core/TikTok.ts @@ -212,6 +212,7 @@ export class TikTokScraper extends EventEmitter { noWaterMark, headers, filepath: process.env.SCRAPING_FROM_DOCKER ? '/usr/app/files' : filepath || '', + fileName: fileName, bulk, }); this.webHookUrl = webHookUrl; diff --git a/src/entry.ts b/src/entry.ts index 77401ada..1386486e 100644 --- a/src/entry.ts +++ b/src/entry.ts @@ -251,7 +251,7 @@ export const video = async (input: string, options = {} as Options): Promise