aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/helpers/youtube-dl/youtube-dl-cli.ts
diff options
context:
space:
mode:
Diffstat (limited to 'server/helpers/youtube-dl/youtube-dl-cli.ts')
-rw-r--r--server/helpers/youtube-dl/youtube-dl-cli.ts27
1 files changed, 25 insertions, 2 deletions
diff --git a/server/helpers/youtube-dl/youtube-dl-cli.ts b/server/helpers/youtube-dl/youtube-dl-cli.ts
index 13c990a1e..5a87b99b4 100644
--- a/server/helpers/youtube-dl/youtube-dl-cli.ts
+++ b/server/helpers/youtube-dl/youtube-dl-cli.ts
@@ -87,6 +87,7 @@ export class YoutubeDLCLI {
87 return result.concat([ 87 return result.concat([
88 'bestvideo[vcodec!*=av01][vcodec!*=vp9.2]+bestaudio', 88 'bestvideo[vcodec!*=av01][vcodec!*=vp9.2]+bestaudio',
89 'best[vcodec!*=av01][vcodec!*=vp9.2]', // case fallback for known formats 89 'best[vcodec!*=av01][vcodec!*=vp9.2]', // case fallback for known formats
90 'bestvideo[ext=mp4]+bestaudio[ext=m4a]',
90 'best' // Ultimate fallback 91 'best' // Ultimate fallback
91 ]).join('/') 92 ]).join('/')
92 } 93 }
@@ -103,11 +104,14 @@ export class YoutubeDLCLI {
103 timeout?: number 104 timeout?: number
104 additionalYoutubeDLArgs?: string[] 105 additionalYoutubeDLArgs?: string[]
105 }) { 106 }) {
107 let args = options.additionalYoutubeDLArgs || []
108 args = args.concat([ '--merge-output-format', 'mp4', '-f', options.format, '-o', options.output ])
109
106 return this.run({ 110 return this.run({
107 url: options.url, 111 url: options.url,
108 processOptions: options.processOptions, 112 processOptions: options.processOptions,
109 timeout: options.timeout, 113 timeout: options.timeout,
110 args: (options.additionalYoutubeDLArgs || []).concat([ '-f', options.format, '-o', options.output ]) 114 args
111 }) 115 })
112 } 116 }
113 117
@@ -129,6 +133,25 @@ export class YoutubeDLCLI {
129 : info 133 : info
130 } 134 }
131 135
136 getListInfo (options: {
137 url: string
138 latestVideosCount?: number
139 processOptions: execa.NodeOptions
140 }): Promise<{ upload_date: string, webpage_url: string }[]> {
141 const additionalYoutubeDLArgs = [ '--skip-download', '--playlist-reverse' ]
142
143 if (options.latestVideosCount !== undefined) {
144 additionalYoutubeDLArgs.push('--playlist-end', options.latestVideosCount.toString())
145 }
146
147 return this.getInfo({
148 url: options.url,
149 format: YoutubeDLCLI.getYoutubeDLVideoFormat([], false),
150 processOptions: options.processOptions,
151 additionalYoutubeDLArgs
152 })
153 }
154
132 async getSubs (options: { 155 async getSubs (options: {
133 url: string 156 url: string
134 format: 'vtt' 157 format: 'vtt'
@@ -175,7 +198,7 @@ export class YoutubeDLCLI {
175 198
176 const output = await subProcess 199 const output = await subProcess
177 200
178 logger.debug('Runned youtube-dl command.', { command: output.command, ...lTags() }) 201 logger.debug('Run youtube-dl command.', { command: output.command, ...lTags() })
179 202
180 return output.stdout 203 return output.stdout
181 ? output.stdout.trim().split(/\r?\n/) 204 ? output.stdout.trim().split(/\r?\n/)