diff options
Diffstat (limited to 'server')
-rw-r--r-- | server/helpers/youtube-dl/youtube-dl-cli.ts | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/server/helpers/youtube-dl/youtube-dl-cli.ts b/server/helpers/youtube-dl/youtube-dl-cli.ts index fc4c40787..a2f630953 100644 --- a/server/helpers/youtube-dl/youtube-dl-cli.ts +++ b/server/helpers/youtube-dl/youtube-dl-cli.ts | |||
@@ -128,14 +128,14 @@ export class YoutubeDLCLI { | |||
128 | const data = await this.run({ url, args: completeArgs, processOptions }) | 128 | const data = await this.run({ url, args: completeArgs, processOptions }) |
129 | if (!data) return undefined | 129 | if (!data) return undefined |
130 | 130 | ||
131 | const info = data.map(this.parseInfo) | 131 | const info = data.map(d => JSON.parse(d)) |
132 | 132 | ||
133 | return info.length === 1 | 133 | return info.length === 1 |
134 | ? info[0] | 134 | ? info[0] |
135 | : info | 135 | : info |
136 | } | 136 | } |
137 | 137 | ||
138 | getListInfo (options: { | 138 | async getListInfo (options: { |
139 | url: string | 139 | url: string |
140 | latestVideosCount?: number | 140 | latestVideosCount?: number |
141 | processOptions: execa.NodeOptions | 141 | processOptions: execa.NodeOptions |
@@ -151,12 +151,17 @@ export class YoutubeDLCLI { | |||
151 | additionalYoutubeDLArgs.push('--playlist-end', options.latestVideosCount.toString()) | 151 | additionalYoutubeDLArgs.push('--playlist-end', options.latestVideosCount.toString()) |
152 | } | 152 | } |
153 | 153 | ||
154 | return this.getInfo({ | 154 | const result = await this.getInfo({ |
155 | url: options.url, | 155 | url: options.url, |
156 | format: YoutubeDLCLI.getYoutubeDLVideoFormat([], false), | 156 | format: YoutubeDLCLI.getYoutubeDLVideoFormat([], false), |
157 | processOptions: options.processOptions, | 157 | processOptions: options.processOptions, |
158 | additionalYoutubeDLArgs | 158 | additionalYoutubeDLArgs |
159 | }) | 159 | }) |
160 | |||
161 | if (!result) return result | ||
162 | if (!Array.isArray(result)) return [ result ] | ||
163 | |||
164 | return result | ||
160 | } | 165 | } |
161 | 166 | ||
162 | async getSubs (options: { | 167 | async getSubs (options: { |
@@ -241,8 +246,4 @@ export class YoutubeDLCLI { | |||
241 | 246 | ||
242 | return args | 247 | return args |
243 | } | 248 | } |
244 | |||
245 | private parseInfo (data: string) { | ||
246 | return JSON.parse(data) | ||
247 | } | ||
248 | } | 249 | } |