+ try {
+ accessSync(options.tmpdir, constants.R_OK | constants.W_OK)
+ } catch (e) {
+ exitError('--tmpdir %s: directory does not exist or is not accessible', options.tmpdir)
+ }
+
+ url = normalizeTargetUrl(url)
+ options.targetUrl = normalizeTargetUrl(options.targetUrl)
+
+ run(url, username, password)
+ .catch(err => exitError(err))
+ })
+ .catch(err => console.error(err))
+
+async function run (url: string, username: string, password: string) {
+ if (!password) password = await promptPassword()
+
+ const youtubeDLBinary = await YoutubeDLCLI.safeGet()
+
+ let info = await getYoutubeDLInfo(youtubeDLBinary, options.targetUrl, command.args)
+
+ if (!Array.isArray(info)) info = [ info ]
+
+ // Try to fix youtube channels upload
+ const uploadsObject = info.find(i => !i.ie_key && !i.duration && i.title === 'Uploads')
+
+ if (uploadsObject) {
+ console.log('Fixing URL to %s.', uploadsObject.url)
+
+ info = await getYoutubeDLInfo(youtubeDLBinary, uploadsObject.url, command.args)