From 9e2b2e76ba5f7f570dcf59fc03bfec98ea5ffab8 Mon Sep 17 00:00:00 2001 From: Chocobozzz Date: Fri, 6 Nov 2020 14:33:31 +0100 Subject: [PATCH] Don't add live videos in redundancy --- server/helpers/ffmpeg-utils.ts | 2 ++ server/lib/job-queue/handlers/video-live-ending.ts | 2 +- server/lib/video-transcoding.ts | 2 -- server/models/redundancy/video-redundancy.ts | 7 +++++-- server/models/video/video-file.ts | 2 +- 5 files changed, 9 insertions(+), 6 deletions(-) diff --git a/server/helpers/ffmpeg-utils.ts b/server/helpers/ffmpeg-utils.ts index b6f4097aa..69564a1a3 100644 --- a/server/helpers/ffmpeg-utils.ts +++ b/server/helpers/ffmpeg-utils.ts @@ -271,6 +271,8 @@ type TranscodeOptions = | QuickTranscodeOptions function transcode (options: TranscodeOptions) { + logger.debug('Will run transcode.', { options }) + return new Promise(async (res, rej) => { try { let command = getFFmpeg(options.inputPath) diff --git a/server/lib/job-queue/handlers/video-live-ending.ts b/server/lib/job-queue/handlers/video-live-ending.ts index 3d9341738..55c7a4ccb 100644 --- a/server/lib/job-queue/handlers/video-live-ending.ts +++ b/server/lib/job-queue/handlers/video-live-ending.ts @@ -123,7 +123,7 @@ async function saveLive (video: MVideo, live: MVideoLive) { } async function cleanupLive (video: MVideo, streamingPlaylist: MStreamingPlaylist) { - const hlsDirectory = getHLSDirectory(video, false) + const hlsDirectory = getHLSDirectory(video) await remove(hlsDirectory) diff --git a/server/lib/video-transcoding.ts b/server/lib/video-transcoding.ts index e267b1397..9882a14db 100644 --- a/server/lib/video-transcoding.ts +++ b/server/lib/video-transcoding.ts @@ -174,8 +174,6 @@ async function generateHlsPlaylist (options: { } } - logger.debug('Will run transcode.', { transcodeOptions }) - await transcode(transcodeOptions) const playlistUrl = WEBSERVER.URL + VideoStreamingPlaylistModel.getHlsMasterPlaylistStaticPath(video.uuid) diff --git a/server/models/redundancy/video-redundancy.ts b/server/models/redundancy/video-redundancy.ts index 1c8b2cf78..1b967996c 100644 --- a/server/models/redundancy/video-redundancy.ts +++ b/server/models/redundancy/video-redundancy.ts @@ -268,7 +268,8 @@ export class VideoRedundancyModel extends Model { limit: randomizedFactor, order: getVideoSort('-views'), where: { - privacy: VideoPrivacy.PUBLIC + privacy: VideoPrivacy.PUBLIC, + isLive: false }, include: [ await VideoRedundancyModel.buildVideoFileForDuplication(), @@ -288,7 +289,8 @@ export class VideoRedundancyModel extends Model { limit: randomizedFactor, order: getVideoSort('-trending'), where: { - privacy: VideoPrivacy.PUBLIC + privacy: VideoPrivacy.PUBLIC, + isLive: false }, include: [ await VideoRedundancyModel.buildVideoFileForDuplication(), @@ -309,6 +311,7 @@ export class VideoRedundancyModel extends Model { order: getVideoSort('-publishedAt'), where: { privacy: VideoPrivacy.PUBLIC, + isLive: false, views: { [Op.gte]: minViews } diff --git a/server/models/video/video-file.ts b/server/models/video/video-file.ts index 0e834aee0..a130317f6 100644 --- a/server/models/video/video-file.ts +++ b/server/models/video/video-file.ts @@ -334,7 +334,7 @@ export class VideoFileModel extends Model { } isHLS () { - return this.videoStreamingPlaylistId !== null + return !!this.videoStreamingPlaylistId } hasSameUniqueKeysThan (other: MVideoFile) {