+ // Process tags
+ const tags = videoObject.tag
+ .filter(isAPHashTagObject)
+ .map(t => t.name)
+ await setVideoTags({ video: videoCreated, tags, transaction: t })
+
+ // Process captions
+ const videoCaptionsPromises = videoObject.subtitleLanguage.map(c => {
+ const caption = new VideoCaptionModel({
+ videoId: videoCreated.id,
+ filename: VideoCaptionModel.generateCaptionName(c.identifier),
+ language: c.identifier,
+ fileUrl: c.url
+ }) as MVideoCaption
+
+ return VideoCaptionModel.insertOrReplaceLanguage(caption, t)
+ })
+ await Promise.all(videoCaptionsPromises)
+
+ // Process trackers
+ {
+ const trackers = getTrackerUrls(videoObject, videoCreated)
+ await setVideoTrackers({ video: videoCreated, trackers, transaction: t })
+ }
+
+ videoCreated.VideoFiles = videoFiles
+
+ if (videoCreated.isLive) {
+ const videoLive = new VideoLiveModel({
+ streamKey: null,
+ saveReplay: videoObject.liveSaveReplay,
+ permanentLive: videoObject.permanentLive,
+ videoId: videoCreated.id
+ })
+
+ videoCreated.VideoLive = await videoLive.save({ transaction: t })
+ }
+
+ const autoBlacklisted = await autoBlacklistVideoIfNeeded({
+ video: videoCreated,
+ user: undefined,
+ isRemote: true,
+ isNew: true,
+ transaction: t
+ })
+
+ logger.info('Remote video with uuid %s inserted.', videoObject.uuid)
+
+ return { autoBlacklisted, videoCreated }
+ } catch (err) {
+ // FIXME: Use rollback hook when https://github.com/sequelize/sequelize/pull/13038 is released
+ // Remove thumbnail
+ if (thumbnailModel) await thumbnailModel.removeThumbnail()