+ getVideoIdFromUUID,
+ prepareResumableUpload
+}
+
+// ---------------------------------------------------------------------------
+
+function buildUploadReq (req: request.Test, attributes: VideoAttributes) {
+
+ for (const key of [ 'name', 'support', 'channelId', 'description', 'originallyPublishedAt' ]) {
+ if (attributes[key] !== undefined) {
+ req.field(key, attributes[key])
+ }
+ }
+
+ for (const key of [ 'nsfw', 'commentsEnabled', 'downloadEnabled', 'waitTranscoding' ]) {
+ if (attributes[key] !== undefined) {
+ req.field(key, JSON.stringify(attributes[key]))
+ }
+ }
+
+ for (const key of [ 'language', 'privacy', 'category', 'licence' ]) {
+ if (attributes[key] !== undefined) {
+ req.field(key, attributes[key].toString())
+ }
+ }
+
+ const tags = attributes.tags || []
+ for (let i = 0; i < tags.length; i++) {
+ req.field('tags[' + i + ']', attributes.tags[i])
+ }
+
+ for (const key of [ 'thumbnailfile', 'previewfile' ]) {
+ if (attributes[key] !== undefined) {
+ req.attach(key, buildAbsoluteFixturePath(attributes[key]))
+ }
+ }
+
+ if (attributes.scheduleUpdate) {
+ if (attributes.scheduleUpdate.updateAt) {
+ req.field('scheduleUpdate[updateAt]', attributes.scheduleUpdate.updateAt)
+ }
+
+ if (attributes.scheduleUpdate.privacy) {
+ req.field('scheduleUpdate[privacy]', attributes.scheduleUpdate.privacy)
+ }
+ }