From 7a4994873c0b3394d04e16e877fc7418bc8b146a Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Wed, 27 Jan 2021 16:42:13 +0100 Subject: Fix rss feed with HLS videos --- server/models/video/video-query-builder.ts | 3 +++ server/models/video/video.ts | 36 +++++++++++++++++------------- 2 files changed, 24 insertions(+), 15 deletions(-) (limited to 'server') diff --git a/server/models/video/video-query-builder.ts b/server/models/video/video-query-builder.ts index 25d5042b7..9e5b6febb 100644 --- a/server/models/video/video-query-builder.ts +++ b/server/models/video/video-query-builder.ts @@ -472,6 +472,8 @@ function wrapForAPIResults (baseQuery: string, replacements: any, options: Build '"VideoFiles"."videoId"': '"VideoFiles.videoId"', '"VideoStreamingPlaylists"."id"': '"VideoStreamingPlaylists.id"', + '"VideoStreamingPlaylists"."playlistUrl"': '"VideoStreamingPlaylists.playlistUrl"', + '"VideoStreamingPlaylists"."type"': '"VideoStreamingPlaylists.type"', '"VideoStreamingPlaylists->VideoFiles"."id"': '"VideoStreamingPlaylists.VideoFiles.id"', '"VideoStreamingPlaylists->VideoFiles"."createdAt"': '"VideoStreamingPlaylists.VideoFiles.createdAt"', '"VideoStreamingPlaylists->VideoFiles"."updatedAt"': '"VideoStreamingPlaylists.VideoFiles.updatedAt"', @@ -480,6 +482,7 @@ function wrapForAPIResults (baseQuery: string, replacements: any, options: Build '"VideoStreamingPlaylists->VideoFiles"."extname"': '"VideoStreamingPlaylists.VideoFiles.extname"', '"VideoStreamingPlaylists->VideoFiles"."infoHash"': '"VideoStreamingPlaylists.VideoFiles.infoHash"', '"VideoStreamingPlaylists->VideoFiles"."fps"': '"VideoStreamingPlaylists.VideoFiles.fps"', + '"VideoStreamingPlaylists->VideoFiles"."videoStreamingPlaylistId"': '"VideoStreamingPlaylists.VideoFiles.videoStreamingPlaylistId"', '"VideoStreamingPlaylists->VideoFiles"."videoId"': '"VideoStreamingPlaylists.VideoFiles.videoId"' }) } diff --git a/server/models/video/video.ts b/server/models/video/video.ts index 343abde44..9b0aa809e 100644 --- a/server/models/video/video.ts +++ b/server/models/video/video.ts @@ -152,8 +152,6 @@ export type ForAPIOptions = { videoPlaylistId?: number - withFiles?: boolean - withAccountBlockerIds?: number[] } @@ -220,13 +218,6 @@ export type AvailableForListIDsOptions = { } } - if (options.withFiles === true) { - include.push({ - model: VideoFileModel, - required: true - }) - } - if (options.videoPlaylistId) { include.push({ model: VideoPlaylistElementModel.unscoped(), @@ -1622,8 +1613,19 @@ export class VideoModel extends Model { const avatarKeys = [ 'id', 'filename', 'fileUrl', 'onDisk', 'createdAt', 'updatedAt' ] const actorKeys = [ 'id', 'preferredUsername', 'url', 'serverId', 'avatarId' ] const serverKeys = [ 'id', 'host' ] - const videoFileKeys = [ 'id', 'createdAt', 'updatedAt', 'resolution', 'size', 'extname', 'infoHash', 'fps', 'videoId' ] - const videoStreamingPlaylistKeys = [ 'id' ] + const videoFileKeys = [ + 'id', + 'createdAt', + 'updatedAt', + 'resolution', + 'size', + 'extname', + 'infoHash', + 'fps', + 'videoId', + 'videoStreamingPlaylistId' + ] + const videoStreamingPlaylistKeys = [ 'id', 'type', 'playlistUrl' ] const videoKeys = [ 'id', 'uuid', @@ -1882,17 +1884,21 @@ export class VideoModel extends Model { getFormattedVideoFilesJSON (): VideoFile[] { const { baseUrlHttp, baseUrlWs } = this.getBaseUrls() - let files: MVideoFileRedundanciesOpt[] = [] + let files: VideoFile[] = [] if (Array.isArray(this.VideoFiles)) { - files = files.concat(this.VideoFiles) + const result = videoFilesModelToFormattedJSON(this, baseUrlHttp, baseUrlWs, this.VideoFiles) + files = files.concat(result) } for (const p of (this.VideoStreamingPlaylists || [])) { - files = files.concat(p.VideoFiles || []) + p.Video = this + + const result = videoFilesModelToFormattedJSON(p, baseUrlHttp, baseUrlWs, p.VideoFiles) + files = files.concat(result) } - return videoFilesModelToFormattedJSON(this, baseUrlHttp, baseUrlWs, files) + return files } toActivityPubObject (this: MVideoAP): VideoObject { -- cgit v1.2.3