-
- for (const row of rows) {
- if (!memo[row.id]) {
- // Build Channel
- const channel = row.VideoChannel
- const channelModel = new VideoChannelModel(pick(channel, [ 'id', 'name', 'description', 'actorId' ]))
- channelModel.Actor = buildActor(channel.Actor)
-
- const account = row.VideoChannel.Account
- const accountModel = new AccountModel(pick(account, [ 'id', 'name' ]))
- accountModel.Actor = buildActor(account.Actor)
-
- channelModel.Account = accountModel
-
- const videoModel = new VideoModel(pick(row, videoKeys))
- videoModel.VideoChannel = channelModel
-
- videoModel.UserVideoHistories = []
- videoModel.Thumbnails = []
- videoModel.VideoFiles = []
-
- memo[row.id] = videoModel
- // Don't take object value to have a sorted array
- videos.push(videoModel)
- }
-
- const videoModel = memo[row.id]
-
- if (row.userVideoHistory?.id && !historyDone.has(row.userVideoHistory.id)) {
- const historyModel = new UserVideoHistoryModel(pick(row.userVideoHistory, [ 'id', 'currentTime' ]))
- videoModel.UserVideoHistories.push(historyModel)
-
- historyDone.add(row.userVideoHistory.id)
- }
-
- if (row.Thumbnails?.id && !thumbnailsDone.has(row.Thumbnails.id)) {
- const thumbnailModel = new ThumbnailModel(pick(row.Thumbnails, [ 'id', 'type', 'filename' ]))
- videoModel.Thumbnails.push(thumbnailModel)
-
- thumbnailsDone.add(row.Thumbnails.id)
- }
-
- if (row.VideoFiles?.id && !videoFilesDone.has(row.VideoFiles.id)) {
- const videoFileModel = new VideoFileModel(pick(row.VideoFiles, videoFileKeys))
- videoModel.VideoFiles.push(videoFileModel)
-
- videoFilesDone.add(row.VideoFiles.id)
- }
- }
-
- return videos
- }
-
- static getCategoryLabel (id: number) {
- return VIDEO_CATEGORIES[id] || 'Misc'
- }
-
- static getLicenceLabel (id: number) {
- return VIDEO_LICENCES[id] || 'Unknown'