1
0
Fork 0

Fix live files include

This commit is contained in:
Chocobozzz 2021-06-11 16:02:26 +02:00
parent b8afe6f0cd
commit 668f864f5a
No known key found for this signature in database
GPG Key ID: 583A612D890159BE
5 changed files with 18 additions and 15 deletions

View File

@ -102,9 +102,8 @@ export class AbstractVideosModelQueryBuilder extends AbstractVideosQueryBuilder
} }
} }
protected includeWebtorrentFiles (required: boolean) { protected includeWebtorrentFiles () {
const joinType = required ? 'INNER' : 'LEFT' this.addJoin('LEFT JOIN "videoFile" AS "VideoFiles" ON "VideoFiles"."videoId" = "video"."id"')
this.addJoin(joinType + ' JOIN "videoFile" AS "VideoFiles" ON "VideoFiles"."videoId" = "video"."id"')
this.attributes = { this.attributes = {
...this.attributes, ...this.attributes,
@ -113,15 +112,13 @@ export class AbstractVideosModelQueryBuilder extends AbstractVideosQueryBuilder
} }
} }
protected includeStreamingPlaylistFiles (required: boolean) { protected includeStreamingPlaylistFiles () {
const joinType = required ? 'INNER' : 'LEFT'
this.addJoin( this.addJoin(
joinType + ' JOIN "videoStreamingPlaylist" AS "VideoStreamingPlaylists" ON "VideoStreamingPlaylists"."videoId" = "video"."id"' 'LEFT JOIN "videoStreamingPlaylist" AS "VideoStreamingPlaylists" ON "VideoStreamingPlaylists"."videoId" = "video"."id"'
) )
this.addJoin( this.addJoin(
joinType + ' JOIN "videoFile" AS "VideoStreamingPlaylists->VideoFiles" ' + 'LEFT JOIN "videoFile" AS "VideoStreamingPlaylists->VideoFiles" ' +
'ON "VideoStreamingPlaylists->VideoFiles"."videoStreamingPlaylistId" = "VideoStreamingPlaylists"."id"' 'ON "VideoStreamingPlaylists->VideoFiles"."videoStreamingPlaylistId" = "VideoStreamingPlaylists"."id"'
) )

View File

@ -32,7 +32,7 @@ export class VideoFileQueryBuilder extends AbstractVideosModelQueryBuilder {
'"video"."id"': '' '"video"."id"': ''
} }
this.includeWebtorrentFiles(true) this.includeWebtorrentFiles()
if (this.shouldIncludeRedundancies(options)) { if (this.shouldIncludeRedundancies(options)) {
this.includeWebTorrentRedundancies() this.includeWebTorrentRedundancies()
@ -48,7 +48,7 @@ export class VideoFileQueryBuilder extends AbstractVideosModelQueryBuilder {
'"video"."id"': '' '"video"."id"': ''
} }
this.includeStreamingPlaylistFiles(true) this.includeStreamingPlaylistFiles()
if (this.shouldIncludeRedundancies(options)) { if (this.shouldIncludeRedundancies(options)) {
this.includeStreamingPlaylistRedundancies() this.includeStreamingPlaylistRedundancies()

View File

@ -108,9 +108,12 @@ export class VideoModelBuilder {
if (!rowsWebTorrentFiles) return if (!rowsWebTorrentFiles) return
for (const row of rowsWebTorrentFiles) { for (const row of rowsWebTorrentFiles) {
const id = row['VideoFiles.id']
if (!id) continue
const videoModel = this.videosMemo[row.id] const videoModel = this.videosMemo[row.id]
this.addWebTorrentFile(row, videoModel) this.addWebTorrentFile(row, videoModel)
this.addRedundancy(row, 'VideoFiles.RedundancyVideos', this.videoFileMemo[row['VideoFiles.id']]) this.addRedundancy(row, 'VideoFiles.RedundancyVideos', this.videoFileMemo[id])
} }
} }
@ -118,6 +121,9 @@ export class VideoModelBuilder {
if (!rowsStreamingPlaylist) return if (!rowsStreamingPlaylist) return
for (const row of rowsStreamingPlaylist || []) { for (const row of rowsStreamingPlaylist || []) {
const id = row['VideoStreamingPlaylists.id']
if (!id) continue
const videoModel = this.videosMemo[row.id] const videoModel = this.videosMemo[row.id]
this.addStreamingPlaylist(row, videoModel) this.addStreamingPlaylist(row, videoModel)
@ -125,7 +131,7 @@ export class VideoModelBuilder {
this.addRedundancy( this.addRedundancy(
row, row,
'VideoStreamingPlaylists.RedundancyVideos', 'VideoStreamingPlaylists.RedundancyVideos',
this.videoStreamingPlaylistMemo[row['VideoStreamingPlaylists.id']] this.videoStreamingPlaylistMemo[id]
) )
} }
} }

View File

@ -52,8 +52,8 @@ export class VideosModelListQueryBuilder extends AbstractVideosModelQueryBuilder
this.includeThumbnails() this.includeThumbnails()
if (options.withFiles) { if (options.withFiles) {
this.includeWebtorrentFiles(false) this.includeWebtorrentFiles()
this.includeStreamingPlaylistFiles(false) this.includeStreamingPlaylistFiles()
} }
if (options.user) { if (options.user) {

View File

@ -27,7 +27,7 @@ import {
const expect = chai.expect const expect = chai.expect
describe('Permenant live', function () { describe('Permanent live', function () {
let servers: ServerInfo[] = [] let servers: ServerInfo[] = []
let videoUUID: string let videoUUID: string