+ url: program['url'],
+ username: program['username'],
+ password: program['password']
+ }
+}
+
+function buildCommonVideoOptions (command: Command) {
+ function list (val) {
+ return val.split(',')
+ }
+
+ return command
+ .option('-n, --video-name <name>', 'Video name')
+ .option('-c, --category <category_number>', 'Category number')
+ .option('-l, --licence <licence_number>', 'Licence number')
+ .option('-L, --language <language_code>', 'Language ISO 639 code (fr or en...)')
+ .option('-t, --tags <tags>', 'Video tags', list)
+ .option('-N, --nsfw', 'Video is Not Safe For Work')
+ .option('-d, --video-description <description>', 'Video description')
+ .option('-P, --privacy <privacy_number>', 'Privacy')
+ .option('-C, --channel-name <channel_name>', 'Channel name')
+ .option('-m, --comments-enabled', 'Enable comments')
+ .option('-s, --support <support>', 'Video support text')
+ .option('-w, --wait-transcoding', 'Wait transcoding before publishing the video')
+ .option('-v, --verbose <verbose>', 'Verbosity, from 0/\'error\' to 4/\'debug\'', 'info')
+}
+
+async function buildVideoAttributesFromCommander (url: string, command: Command, defaultAttributes: any = {}) {
+ const defaultBooleanAttributes = {
+ nsfw: false,
+ commentsEnabled: true,
+ downloadEnabled: true,
+ waitTranscoding: true
+ }
+
+ const booleanAttributes: { [id in keyof typeof defaultBooleanAttributes]: boolean } | {} = {}
+
+ for (const key of Object.keys(defaultBooleanAttributes)) {
+ if (command[key] !== undefined) {
+ booleanAttributes[key] = command[key]
+ } else if (defaultAttributes[key] !== undefined) {
+ booleanAttributes[key] = defaultAttributes[key]
+ } else {
+ booleanAttributes[key] = defaultBooleanAttributes[key]
+ }
+ }
+
+ const videoAttributes = {
+ name: command['videoName'] || defaultAttributes.name,
+ category: command['category'] || defaultAttributes.category || undefined,
+ licence: command['licence'] || defaultAttributes.licence || undefined,
+ language: command['language'] || defaultAttributes.language || undefined,
+ privacy: command['privacy'] || defaultAttributes.privacy || VideoPrivacy.PUBLIC,
+ support: command['support'] || defaultAttributes.support || undefined,
+ description: command['videoDescription'] || defaultAttributes.description || undefined,
+ tags: command['tags'] || defaultAttributes.tags || undefined