import { unlinkPromise } from './core-utils'
async function processImage (
- physicalFile: Express.Multer.File,
+ physicalFile: { path: string },
destination: string,
newSize: { width: number, height: number }
) {
}
function doRequestAndSaveToFile (requestOptions: request.CoreOptions & request.UriOptions, destPath: string) {
- return new Bluebird<request.RequestResponse>((res, rej) => {
+ return new Bluebird<void>((res, rej) => {
+ const file = createWriteStream(destPath)
+ file.on('finish', () => res())
+
request(requestOptions)
- .on('response', response => res(response as request.RequestResponse))
.on('error', err => rej(err))
- .pipe(createWriteStream(destPath))
+ .pipe(file)
})
}
console.log('Will download and upload %d videos.\n', videos.length)
for (const video of videos) {
- await processVideo(video, program['languageCode'])
+ await processVideo(video, program['language'])
}
console.log('I\'m finished!')
const licence = getLicence(videoInfo.license)
let tags = []
if (Array.isArray(videoInfo.tags)) {
- tags = videoInfo.tags.filter(t => t.length < CONSTRAINTS_FIELDS.VIDEOS.TAG.max).slice(0, 5)
+ tags = videoInfo.tags
+ .filter(t => t.length < CONSTRAINTS_FIELDS.VIDEOS.TAG.max)
+ .map(t => t.normalize())
+ .slice(0, 5)
}
let thumbnailfile
.option('-d, --video-description <description>', 'Video description')
.option('-t, --tags <tags>', 'Video tags', list)
.option('-b, --thumbnail <thumbnailPath>', 'Thumbnail path')
+ .option('-v, --preview <previewPath>', 'Preview path')
.option('-f, --file <file>', 'Video absolute file path')
.parse(process.argv)
tags: program['tags'],
commentsEnabled: program['commentsEnabled'],
fixture: program['file'],
- thumbnailfile: program['thumbnailPath']
+ thumbnailfile: program['thumbnailPath'],
+ previewfile: program['previewPath']
}
await uploadVideo(program['url'], accessToken, videoAttributes)