import { Sequelize, Transaction } from 'sequelize'
+import { pick } from '@shared/core-utils'
import { AbstractVideoQueryBuilder } from './shared/abstract-video-query-builder'
import { VideoFileQueryBuilder } from './shared/video-file-query-builder'
import { VideoModelBuilder } from './shared/video-model-builder'
export type GetType =
'api' |
- 'full-light' |
+ 'full' |
'account-blacklist-files' |
'all-files' |
'thumbnails' |
private readonly videoModelBuilder: VideoModelBuilder
- private static readonly videoFilesInclude = new Set<GetType>([ 'api', 'full-light', 'account-blacklist-files', 'all-files' ])
+ private static readonly videoFilesInclude = new Set<GetType>([ 'api', 'full', 'account-blacklist-files', 'all-files' ])
constructor (protected readonly sequelize: Sequelize) {
this.videoQueryBuilder = new VideosModelGetQuerySubBuilder(sequelize)
}
async queryVideo (options: BuildVideoGetQueryOptions) {
+ const fileQueryOptions = {
+ ...pick(options, [ 'id', 'url', 'transaction', 'logging' ]),
+
+ includeRedundancy: this.shouldIncludeRedundancies(options)
+ }
+
const [ videoRows, webtorrentFilesRows, streamingPlaylistFilesRows ] = await Promise.all([
this.videoQueryBuilder.queryVideos(options),
VideoModelGetQueryBuilder.videoFilesInclude.has(options.type)
- ? this.webtorrentFilesQueryBuilder.queryWebTorrentVideos(options)
+ ? this.webtorrentFilesQueryBuilder.queryWebTorrentVideos(fileQueryOptions)
: Promise.resolve(undefined),
VideoModelGetQueryBuilder.videoFilesInclude.has(options.type)
- ? this.streamingPlaylistFilesQueryBuilder.queryStreamingPlaylistVideos(options)
+ ? this.streamingPlaylistFilesQueryBuilder.queryStreamingPlaylistVideos(fileQueryOptions)
: Promise.resolve(undefined)
])
return videos[0]
}
+
+ private shouldIncludeRedundancies (options: BuildVideoGetQueryOptions) {
+ return options.type === 'api'
+ }
}
export class VideosModelGetQuerySubBuilder extends AbstractVideoQueryBuilder {
protected streamingPlaylistFilesQuery: string
private static readonly trackersInclude = new Set<GetType>([ 'api' ])
- private static readonly liveInclude = new Set<GetType>([ 'api', 'full-light' ])
- private static readonly scheduleUpdateInclude = new Set<GetType>([ 'api', 'full-light' ])
- private static readonly tagsInclude = new Set<GetType>([ 'api', 'full-light' ])
- private static readonly userHistoryInclude = new Set<GetType>([ 'api', 'full-light' ])
- private static readonly accountInclude = new Set<GetType>([ 'api', 'full-light', 'account-blacklist-files' ])
+ private static readonly liveInclude = new Set<GetType>([ 'api', 'full' ])
+ private static readonly scheduleUpdateInclude = new Set<GetType>([ 'api', 'full' ])
+ private static readonly tagsInclude = new Set<GetType>([ 'api', 'full' ])
+ private static readonly userHistoryInclude = new Set<GetType>([ 'api', 'full' ])
+ private static readonly accountInclude = new Set<GetType>([ 'api', 'full', 'account-blacklist-files' ])
private static readonly ownerUserInclude = new Set<GetType>([ 'blacklist-rights' ])
private static readonly blacklistedInclude = new Set<GetType>([
'api',
- 'full-light',
+ 'full',
'account-blacklist-files',
'thumbnails-blacklist',
'blacklist-rights'
private static readonly thumbnailsInclude = new Set<GetType>([
'api',
- 'full-light',
+ 'full',
'account-blacklist-files',
'all-files',
'thumbnails',