diff options
author | Chocobozzz <me@florianbigard.com> | 2023-07-19 16:02:49 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2023-07-21 17:38:13 +0200 |
commit | 12dc3a942a13c7f1489822dae052da197ef15905 (patch) | |
tree | 7b87b6be692af0b62ebac17e720c80244fd8a7ec /server/lib/thumbnail.ts | |
parent | c6867725fb8e3dfbc2018a37ed5a963103587cb6 (diff) | |
download | PeerTube-12dc3a942a13c7f1489822dae052da197ef15905.tar.gz PeerTube-12dc3a942a13c7f1489822dae052da197ef15905.tar.zst PeerTube-12dc3a942a13c7f1489822dae052da197ef15905.zip |
Implement replace file in server side
Diffstat (limited to 'server/lib/thumbnail.ts')
-rw-r--r-- | server/lib/thumbnail.ts | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/server/lib/thumbnail.ts b/server/lib/thumbnail.ts index d95442795..0b98da14f 100644 --- a/server/lib/thumbnail.ts +++ b/server/lib/thumbnail.ts | |||
@@ -4,7 +4,7 @@ import { generateImageFilename, generateImageFromVideoFile } from '../helpers/im | |||
4 | import { CONFIG } from '../initializers/config' | 4 | import { CONFIG } from '../initializers/config' |
5 | import { ASSETS_PATH, PREVIEWS_SIZE, THUMBNAILS_SIZE } from '../initializers/constants' | 5 | import { ASSETS_PATH, PREVIEWS_SIZE, THUMBNAILS_SIZE } from '../initializers/constants' |
6 | import { ThumbnailModel } from '../models/video/thumbnail' | 6 | import { ThumbnailModel } from '../models/video/thumbnail' |
7 | import { MVideoFile, MVideoThumbnail, MVideoUUID } from '../types/models' | 7 | import { MVideoFile, MVideoThumbnail, MVideoUUID, MVideoWithAllFiles } from '../types/models' |
8 | import { MThumbnail } from '../types/models/video/thumbnail' | 8 | import { MThumbnail } from '../types/models/video/thumbnail' |
9 | import { MVideoPlaylistThumbnail } from '../types/models/video/video-playlist' | 9 | import { MVideoPlaylistThumbnail } from '../types/models/video/video-playlist' |
10 | import { VideoPathManager } from './video-path-manager' | 10 | import { VideoPathManager } from './video-path-manager' |
@@ -187,8 +187,31 @@ function updateRemoteVideoThumbnail (options: { | |||
187 | 187 | ||
188 | // --------------------------------------------------------------------------- | 188 | // --------------------------------------------------------------------------- |
189 | 189 | ||
190 | async function regenerateMiniaturesIfNeeded (video: MVideoWithAllFiles) { | ||
191 | if (video.getMiniature().automaticallyGenerated === true) { | ||
192 | const miniature = await generateLocalVideoMiniature({ | ||
193 | video, | ||
194 | videoFile: video.getMaxQualityFile(), | ||
195 | type: ThumbnailType.MINIATURE | ||
196 | }) | ||
197 | await video.addAndSaveThumbnail(miniature) | ||
198 | } | ||
199 | |||
200 | if (video.getPreview().automaticallyGenerated === true) { | ||
201 | const preview = await generateLocalVideoMiniature({ | ||
202 | video, | ||
203 | videoFile: video.getMaxQualityFile(), | ||
204 | type: ThumbnailType.PREVIEW | ||
205 | }) | ||
206 | await video.addAndSaveThumbnail(preview) | ||
207 | } | ||
208 | } | ||
209 | |||
210 | // --------------------------------------------------------------------------- | ||
211 | |||
190 | export { | 212 | export { |
191 | generateLocalVideoMiniature, | 213 | generateLocalVideoMiniature, |
214 | regenerateMiniaturesIfNeeded, | ||
192 | updateLocalVideoMiniatureFromUrl, | 215 | updateLocalVideoMiniatureFromUrl, |
193 | updateLocalVideoMiniatureFromExisting, | 216 | updateLocalVideoMiniatureFromExisting, |
194 | updateRemoteVideoThumbnail, | 217 | updateRemoteVideoThumbnail, |