diff options
Diffstat (limited to 'server/helpers/youtube-dl/youtube-dl-cli.ts')
-rw-r--r-- | server/helpers/youtube-dl/youtube-dl-cli.ts | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/server/helpers/youtube-dl/youtube-dl-cli.ts b/server/helpers/youtube-dl/youtube-dl-cli.ts index 293acff43..d4a6dd9b3 100644 --- a/server/helpers/youtube-dl/youtube-dl-cli.ts +++ b/server/helpers/youtube-dl/youtube-dl-cli.ts | |||
@@ -90,11 +90,13 @@ export class YoutubeDLCLI { | |||
90 | format: string | 90 | format: string |
91 | output: string | 91 | output: string |
92 | processOptions: execa.NodeOptions | 92 | processOptions: execa.NodeOptions |
93 | timeout: number | ||
93 | additionalYoutubeDLArgs?: string[] | 94 | additionalYoutubeDLArgs?: string[] |
94 | }) { | 95 | }) { |
95 | return this.run({ | 96 | return this.run({ |
96 | url: options.url, | 97 | url: options.url, |
97 | processOptions: options.processOptions, | 98 | processOptions: options.processOptions, |
99 | timeout: options.timeout, | ||
98 | args: (options.additionalYoutubeDLArgs || []).concat([ '-f', options.format, '-o', options.output ]) | 100 | args: (options.additionalYoutubeDLArgs || []).concat([ '-f', options.format, '-o', options.output ]) |
99 | }) | 101 | }) |
100 | } | 102 | } |
@@ -145,16 +147,23 @@ export class YoutubeDLCLI { | |||
145 | private async run (options: { | 147 | private async run (options: { |
146 | url: string | 148 | url: string |
147 | args: string[] | 149 | args: string[] |
150 | timeout?: number | ||
148 | processOptions: execa.NodeOptions | 151 | processOptions: execa.NodeOptions |
149 | }) { | 152 | }) { |
150 | const { url, args, processOptions } = options | 153 | const { url, args, timeout, processOptions } = options |
151 | 154 | ||
152 | let completeArgs = this.wrapWithProxyOptions(args) | 155 | let completeArgs = this.wrapWithProxyOptions(args) |
153 | completeArgs = this.wrapWithIPOptions(completeArgs) | 156 | completeArgs = this.wrapWithIPOptions(completeArgs) |
154 | completeArgs = this.wrapWithFFmpegOptions(completeArgs) | 157 | completeArgs = this.wrapWithFFmpegOptions(completeArgs) |
155 | 158 | ||
156 | const { PYTHON_PATH } = CONFIG.IMPORT.VIDEOS.HTTP.YOUTUBE_DL_RELEASE | 159 | const { PYTHON_PATH } = CONFIG.IMPORT.VIDEOS.HTTP.YOUTUBE_DL_RELEASE |
157 | const output = await execa(PYTHON_PATH, [ youtubeDLBinaryPath, ...completeArgs, url ], processOptions) | 160 | const subProcess = execa(PYTHON_PATH, [ youtubeDLBinaryPath, ...completeArgs, url ], processOptions) |
161 | |||
162 | if (timeout) { | ||
163 | setTimeout(() => subProcess.cancel(), timeout) | ||
164 | } | ||
165 | |||
166 | const output = await subProcess | ||
158 | 167 | ||
159 | logger.debug('Runned youtube-dl command.', { command: output.command, ...lTags() }) | 168 | logger.debug('Runned youtube-dl command.', { command: output.command, ...lTags() }) |
160 | 169 | ||