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.ts25
1 files changed, 13 insertions, 12 deletions
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 = {
18 thumbnailUrl?: string 18 thumbnailUrl?: string
19} 19}
20 20
21function getYoutubeDLInfo (url: string): Promise<YoutubeDLInfo> { 21function getYoutubeDLInfo (url: string, opts?: string[]): Promise<YoutubeDLInfo> {
22 return new Promise<YoutubeDLInfo>(async (res, rej) => { 22 return new Promise<YoutubeDLInfo>(async (res, rej) => {
23 const options = [ '-j', '--flat-playlist' ] 23 const options = opts || [ '-j', '--flat-playlist' ]
24 24
25 const youtubeDL = await safeGetYoutubeDL() 25 const youtubeDL = await safeGetYoutubeDL()
26 youtubeDL.getInfo(url, options, (err, info) => { 26 youtubeDL.getInfo(url, options, (err, info) => {
@@ -110,16 +110,6 @@ async function updateYoutubeDLBinary () {
110 }) 110 })
111} 111}
112 112
113// ---------------------------------------------------------------------------
114
115export {
116 updateYoutubeDLBinary,
117 downloadYoutubeDLVideo,
118 getYoutubeDLInfo
119}
120
121// ---------------------------------------------------------------------------
122
123async function safeGetYoutubeDL () { 113async function safeGetYoutubeDL () {
124 let youtubeDL 114 let youtubeDL
125 115
@@ -134,6 +124,17 @@ async function safeGetYoutubeDL () {
134 return youtubeDL 124 return youtubeDL
135} 125}
136 126
127// ---------------------------------------------------------------------------
128
129export {
130 updateYoutubeDLBinary,
131 downloadYoutubeDLVideo,
132 getYoutubeDLInfo,
133 safeGetYoutubeDL
134}
135
136// ---------------------------------------------------------------------------
137
137function normalizeObject (obj: any) { 138function normalizeObject (obj: any) {
138 const newObj: any = {} 139 const newObj: any = {}
139 140