X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Flib%2Fthumbnail.ts;h=8dbd417711bb8cfdd1a297f94db31b54c9c7893b;hb=ebefc902f59be6c5542c19ff706e310d9dddf75f;hp=84791955e0cc00c908b9882dae22377b93dd9188;hpb=282e61e6c11f79e919c543871783fe1a00298d18;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/lib/thumbnail.ts b/server/lib/thumbnail.ts index 84791955e..8dbd41771 100644 --- a/server/lib/thumbnail.ts +++ b/server/lib/thumbnail.ts @@ -9,6 +9,7 @@ import { downloadImage } from '../helpers/requests' import { MVideoPlaylistThumbnail } from '../typings/models/video/video-playlist' import { MVideoFile, MVideoThumbnail } from '../typings/models' import { MThumbnail } from '../typings/models/video/thumbnail' +import { getVideoFilePath } from './video-paths' type ImageSize = { height: number, width: number } @@ -55,7 +56,7 @@ function createVideoMiniatureFromExisting ( } function generateVideoMiniature (video: MVideoThumbnail, videoFile: MVideoFile, type: ThumbnailType) { - const input = video.getVideoFilePath(videoFile) + const input = getVideoFilePath(video, videoFile) const { filename, basePath, height, width, existingThumbnail, outputPath } = buildMetadataFromVideo(video, type) const thumbnailCreator = videoFile.isAudio() @@ -68,7 +69,7 @@ function generateVideoMiniature (video: MVideoThumbnail, videoFile: MVideoFile, function createPlaceholderThumbnail (fileUrl: string, video: MVideoThumbnail, type: ThumbnailType, size: ImageSize) { const { filename, height, width, existingThumbnail } = buildMetadataFromVideo(video, type, size) - const thumbnail = existingThumbnail ? existingThumbnail : new ThumbnailModel() + const thumbnail = existingThumbnail || new ThumbnailModel() thumbnail.filename = filename thumbnail.height = height @@ -141,18 +142,18 @@ function buildMetadataFromVideo (video: MVideoThumbnail, type: ThumbnailType, si } async function createThumbnailFromFunction (parameters: { - thumbnailCreator: () => Promise, - filename: string, - height: number, - width: number, - type: ThumbnailType, - automaticallyGenerated?: boolean, - fileUrl?: string, + thumbnailCreator: () => Promise + filename: string + height: number + width: number + type: ThumbnailType + automaticallyGenerated?: boolean + fileUrl?: string existingThumbnail?: MThumbnail }) { const { thumbnailCreator, filename, width, height, type, existingThumbnail, automaticallyGenerated = null, fileUrl = null } = parameters - const thumbnail = existingThumbnail ? existingThumbnail : new ThumbnailModel() + const thumbnail = existingThumbnail || new ThumbnailModel() thumbnail.filename = filename thumbnail.height = height