From 8704acf49efc770d73bf07c10468ed8c74d28a83 Mon Sep 17 00:00:00 2001 From: Rigel Kent Date: Thu, 13 Sep 2018 14:27:44 +0200 Subject: one cli to unite them all MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Ash nazg thrakatulûk agh burzum-ishi krimpatul - refactor import-videos to use the youtubeDL helper - add very basic tests for the cli --- server/helpers/youtube-dl.ts | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) (limited to 'server/helpers') diff --git a/server/helpers/youtube-dl.ts b/server/helpers/youtube-dl.ts index 6738090f3..8b2bc1782 100644 --- a/server/helpers/youtube-dl.ts +++ b/server/helpers/youtube-dl.ts @@ -14,9 +14,9 @@ export type YoutubeDLInfo = { thumbnailUrl?: string } -function getYoutubeDLInfo (url: string): Promise { +function getYoutubeDLInfo (url: string, opts?: string[]): Promise { return new Promise(async (res, rej) => { - const options = [ '-j', '--flat-playlist' ] + const options = opts || [ '-j', '--flat-playlist' ] const youtubeDL = await safeGetYoutubeDL() youtubeDL.getInfo(url, options, (err, info) => { @@ -48,15 +48,6 @@ function downloadYoutubeDLVideo (url: string) { }) } -// --------------------------------------------------------------------------- - -export { - downloadYoutubeDLVideo, - getYoutubeDLInfo -} - -// --------------------------------------------------------------------------- - async function safeGetYoutubeDL () { let youtubeDL @@ -71,6 +62,16 @@ async function safeGetYoutubeDL () { return youtubeDL } +// --------------------------------------------------------------------------- + +export { + downloadYoutubeDLVideo, + getYoutubeDLInfo, + safeGetYoutubeDL +} + +// --------------------------------------------------------------------------- + function normalizeObject (obj: any) { const newObj: any = {} -- cgit v1.2.3