aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/helpers/youtube-dl.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/helpers/youtube-dl.ts')
-rw-r--r--server/helpers/youtube-dl.ts23
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
17function getYoutubeDLInfo (url: string): Promise<YoutubeDLInfo> { 17function 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
53export {
54 downloadYoutubeDLVideo,
55 getYoutubeDLInfo
56}
57
58// ---------------------------------------------------------------------------
59
60async function safeGetYoutubeDL () { 51async 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
67export {
68 downloadYoutubeDLVideo,
69 getYoutubeDLInfo,
70 safeGetYoutubeDL
71}
72
73// ---------------------------------------------------------------------------
74
74function normalizeObject (obj: any) { 75function normalizeObject (obj: any) {
75 const newObj: any = {} 76 const newObj: any = {}
76 77