+ videoUpdated.VideoStreamingPlaylists = []
+
+ for (const playlistAttributes of streamingPlaylistAttributes) {
+ const streamingPlaylistModel = await VideoStreamingPlaylistModel.upsert(playlistAttributes, { returning: true, transaction: t })
+ .then(([ streamingPlaylist ]) => streamingPlaylist)
+
+ const newVideoFiles: MVideoFile[] = videoFileActivityUrlToDBAttributes(streamingPlaylistModel, playlistAttributes.tagAPObject)
+ .map(a => new VideoFileModel(a))
+ const destroyTasks = deleteNonExistingModels(oldStreamingPlaylistFiles, newVideoFiles, t)
+ await Promise.all(destroyTasks)
+
+ // Update or add other one
+ const upsertTasks = newVideoFiles.map(f => VideoFileModel.customUpsert(f, 'streaming-playlist', t))
+ streamingPlaylistModel.VideoFiles = await Promise.all(upsertTasks)
+
+ videoUpdated.VideoStreamingPlaylists.push(streamingPlaylistModel)
+ }