]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/helpers/youtube-dl.ts
one cli to unite them all
[github/Chocobozzz/PeerTube.git] / server / helpers / youtube-dl.ts
index 6738090f3613c91d996b48ecfd00e37f03c16782..8b2bc17824f511866ffc1509dc7fa8afc71b7b43 100644 (file)
@@ -14,9 +14,9 @@ export type YoutubeDLInfo = {
   thumbnailUrl?: string
 }
 
-function getYoutubeDLInfo (url: string): Promise<YoutubeDLInfo> {
+function getYoutubeDLInfo (url: string, opts?: string[]): Promise<YoutubeDLInfo> {
   return new Promise<YoutubeDLInfo>(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 = {}