import * as prompt from 'prompt'
import { remove } from 'fs-extra'
import { sha256 } from '../helpers/core-utils'
-import { safeGetYoutubeDL } from '../helpers/youtube-dl'
+import { safeGetYoutubeDL, buildOriginallyPublishedAt } from '../helpers/youtube-dl'
import { getSettings, netrc } from './cli'
let accessToken: string
password: program['password']
}
- run(user, program['url']).catch(err => console.error(err))
+ run(user, program['url'])
+ .catch(err => {
+ console.error(err)
+ process.exit(-1)
+ })
})
async function promptPassword () {
secret: res.body.client_secret
}
- const res2 = await login(url, client, user)
- accessToken = res2.body.access_token
+ try {
+ const res = await login(program[ 'url' ], client, user)
+ accessToken = res.body.access_token
+ } catch (err) {
+ throw new Error('Cannot authenticate. Please check your username/password.')
+ }
const youtubeDL = await safeGetYoutubeDL()
}, thumbnailfile)
}
+ const originallyPublishedAt = buildOriginallyPublishedAt(videoInfo)
+
const videoAttributes = {
name: truncate(videoInfo.title, {
'length': CONSTRAINTS_FIELDS.VIDEOS.NAME.max,
nsfw: isNSFW(videoInfo),
waitTranscoding: true,
commentsEnabled: true,
+ downloadEnabled: true,
description: videoInfo.description || undefined,
support: undefined,
tags,
privacy: VideoPrivacy.PUBLIC,
fixture: videoPath,
thumbnailfile,
- previewfile: thumbnailfile
+ previewfile: thumbnailfile,
+ originallyPublishedAt: originallyPublishedAt ? originallyPublishedAt.toISOString() : null
}
console.log('\nUploading on PeerTube video "%s".', videoAttributes.name)