+
+ 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
+ }
+
+ Object.assign(videoAttributes, booleanAttributes)
+
+ if (command['channelName']) {
+ const res = await getVideoChannel(url, command['channelName'])
+ const videoChannel: VideoChannel = res.body
+
+ Object.assign(videoAttributes, { channelId: videoChannel.id })
+
+ if (!videoAttributes.support && videoChannel.support) {
+ Object.assign(videoAttributes, { support: videoChannel.support })
+ }
+ }
+
+ return videoAttributes
+}
+
+function getServerCredentials (program: any) {
+ return Promise.all([ getSettings(), getNetrc() ])
+ .then(([ settings, netrc ]) => {
+ return getRemoteObjectOrDie(program, settings, netrc)
+ })
+}
+
+function getLogger (logLevel = 'info') {
+ const logLevels = {
+ 0: 0,
+ error: 0,
+ 1: 1,
+ warn: 1,
+ 2: 2,
+ info: 2,
+ 3: 3,
+ verbose: 3,
+ 4: 4,
+ debug: 4
+ }
+
+ const logger = createLogger({
+ levels: logLevels,
+ format: format.combine(
+ format.splat(),
+ format.simple()
+ ),
+ transports: [
+ new (transports.Console)({
+ level: logLevel
+ })
+ ]
+ })
+
+ return logger