]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - server/helpers/youtube-dl.ts
Merge branch 'develop' into cli-wrapper
[github/Chocobozzz/PeerTube.git] / server / helpers / youtube-dl.ts
index db2bddf78cc3af8acd1beae2d016b858b8c06163..25e719cc3654d65e01ceedbfef03b96f3fd7e239 100644 (file)
@@ -18,9 +18,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) => {
@@ -110,16 +110,6 @@ async function updateYoutubeDLBinary () {
   })
 }
 
-// ---------------------------------------------------------------------------
-
-export {
-  updateYoutubeDLBinary,
-  downloadYoutubeDLVideo,
-  getYoutubeDLInfo
-}
-
-// ---------------------------------------------------------------------------
-
 async function safeGetYoutubeDL () {
   let youtubeDL
 
@@ -134,6 +124,17 @@ async function safeGetYoutubeDL () {
   return youtubeDL
 }
 
+// ---------------------------------------------------------------------------
+
+export {
+  updateYoutubeDLBinary,
+  downloadYoutubeDLVideo,
+  getYoutubeDLInfo,
+  safeGetYoutubeDL
+}
+
+// ---------------------------------------------------------------------------
+
 function normalizeObject (obj: any) {
   const newObj: any = {}