- // Normalize utf8 fields
- infoArray = [].concat(info)
- if (program['first']) {
- infoArray = infoArray.slice(0, program['first'])
- } else if (program['last']) {
- infoArray = infoArray.slice(-program['last'])
- }
- infoArray = infoArray.map(i => normalizeObject(i))
-
- log.info('Will download and upload %d videos.\n', infoArray.length)
-
- for (const info of infoArray) {
- try {
- await processVideo({
- cwd: program['tmpdir'],
- url,
- user,
- youtubeInfo: info
- })
- } catch (err) {
- console.error('Cannot process video.', { info, url })
+ if (uploadsObject) {
+ console.log('Fixing URL to %s.', uploadsObject.url)
+
+ info = await getYoutubeDLInfo(youtubeDLBinary, uploadsObject.url, command.args)
+ }
+
+ let infoArray: any[]
+
+ infoArray = [].concat(info)
+ if (options.first) {
+ infoArray = infoArray.slice(0, options.first)
+ } else if (options.last) {
+ infoArray = infoArray.slice(-options.last)
+ }
+ // Normalize utf8 fields
+ infoArray = infoArray.map(i => normalizeObject(i))
+
+ log.info('Will download and upload %d videos.\n', infoArray.length)
+
+ for (const [ index, info ] of infoArray.entries()) {
+ try {
+ if (index > 0 && options.waitInterval) {
+ log.info("Wait for %d seconds before continuing.", options.waitInterval / 1000)
+ await new Promise(res => setTimeout(res, options.waitInterval))