diff options
author | Chocobozzz <me@florianbigard.com> | 2022-10-10 15:33:32 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2022-10-10 15:33:32 +0200 |
commit | 5cc2f0ea0a0af82333d673db1ad6461ed5cb4233 (patch) | |
tree | c68ebbbd03f17ae8dafecd0e2ca5f00a3579e9f9 /server/helpers/youtube-dl | |
parent | c43ed8e8624383db5a0cf22b210cee202bae323c (diff) | |
download | PeerTube-5cc2f0ea0a0af82333d673db1ad6461ed5cb4233.tar.gz PeerTube-5cc2f0ea0a0af82333d673db1ad6461ed5cb4233.tar.zst PeerTube-5cc2f0ea0a0af82333d673db1ad6461ed5cb4233.zip |
Fix channel import with some channels
Diffstat (limited to 'server/helpers/youtube-dl')
-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 | } |