X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Fhelpers%2Fyoutube-dl.ts;h=25e719cc3654d65e01ceedbfef03b96f3fd7e239;hb=0491173a61aed66205c017e0d7e0503ea316c144;hp=db2bddf78cc3af8acd1beae2d016b858b8c06163;hpb=606c946e74211c4123b16087288902226306198d;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/helpers/youtube-dl.ts b/server/helpers/youtube-dl.ts index db2bddf78..25e719cc3 100644 --- a/server/helpers/youtube-dl.ts +++ b/server/helpers/youtube-dl.ts @@ -18,9 +18,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) => { @@ -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 = {}