diff options
Diffstat (limited to 'server/helpers')
-rw-r--r-- | server/helpers/youtube-dl.ts | 23 |
1 files changed, 12 insertions, 11 deletions
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 = { | |||
14 | thumbnailUrl?: string | 14 | thumbnailUrl?: string |
15 | } | 15 | } |
16 | 16 | ||
17 | function getYoutubeDLInfo (url: string): Promise<YoutubeDLInfo> { | 17 | function getYoutubeDLInfo (url: string, opts?: string[]): Promise<YoutubeDLInfo> { |
18 | return new Promise<YoutubeDLInfo>(async (res, rej) => { | 18 | return new Promise<YoutubeDLInfo>(async (res, rej) => { |
19 | const options = [ '-j', '--flat-playlist' ] | 19 | const options = opts || [ '-j', '--flat-playlist' ] |
20 | 20 | ||
21 | const youtubeDL = await safeGetYoutubeDL() | 21 | const youtubeDL = await safeGetYoutubeDL() |
22 | youtubeDL.getInfo(url, options, (err, info) => { | 22 | youtubeDL.getInfo(url, options, (err, info) => { |
@@ -48,15 +48,6 @@ function downloadYoutubeDLVideo (url: string) { | |||
48 | }) | 48 | }) |
49 | } | 49 | } |
50 | 50 | ||
51 | // --------------------------------------------------------------------------- | ||
52 | |||
53 | export { | ||
54 | downloadYoutubeDLVideo, | ||
55 | getYoutubeDLInfo | ||
56 | } | ||
57 | |||
58 | // --------------------------------------------------------------------------- | ||
59 | |||
60 | async function safeGetYoutubeDL () { | 51 | async function safeGetYoutubeDL () { |
61 | let youtubeDL | 52 | let youtubeDL |
62 | 53 | ||
@@ -71,6 +62,16 @@ async function safeGetYoutubeDL () { | |||
71 | return youtubeDL | 62 | return youtubeDL |
72 | } | 63 | } |
73 | 64 | ||
65 | // --------------------------------------------------------------------------- | ||
66 | |||
67 | export { | ||
68 | downloadYoutubeDLVideo, | ||
69 | getYoutubeDLInfo, | ||
70 | safeGetYoutubeDL | ||
71 | } | ||
72 | |||
73 | // --------------------------------------------------------------------------- | ||
74 | |||
74 | function normalizeObject (obj: any) { | 75 | function normalizeObject (obj: any) { |
75 | const newObj: any = {} | 76 | const newObj: any = {} |
76 | 77 | ||