import { makeGetRequest } from './requests'
import { readFilePromise } from './miscs'
import { ServerInfo } from './servers'
+import { getMyUserInformation } from './users'
type VideoAttributes = {
name?: string
nsfw?: boolean
description?: string
tags?: string[]
+ channelId?: number
fixture?: string
}
}
}
-function uploadVideo (url: string, accessToken: string, videoAttributesArg: VideoAttributes, specialStatus = 204) {
+async function uploadVideo (url: string, accessToken: string, videoAttributesArg: VideoAttributes, specialStatus = 204) {
const path = '/api/v1/videos/upload'
+ let defaultChannelId = '1'
+
+ try {
+ const res = await getMyUserInformation(url, accessToken)
+ defaultChannelId = res.body.videoChannels[0].id
+ } catch (e) { /* empty */ }
// Default attributes
let attributes = {
category: 5,
licence: 4,
language: 3,
+ channelId: defaultChannelId,
nsfw: true,
description: 'my super description',
tags: [ 'tag' ],
.field('licence', attributes.licence.toString())
.field('nsfw', JSON.stringify(attributes.nsfw))
.field('description', attributes.description)
+ .field('channelId', attributes.channelId)
if (attributes.language !== undefined) {
req.field('language', attributes.language.toString())