diff options
author | Chocobozzz <me@florianbigard.com> | 2021-06-04 09:19:01 +0200 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2021-06-04 15:45:44 +0200 |
commit | 91f8f8db97ffb83701c30f9cdb1e804670434eb0 (patch) | |
tree | 4b6659c8572d95b78454c6c4806ddc77a9c420e1 /server/lib/thumbnail.ts | |
parent | 1333ab1f2d4ec495084c5368df25610683582ae3 (diff) | |
download | PeerTube-91f8f8db97ffb83701c30f9cdb1e804670434eb0.tar.gz PeerTube-91f8f8db97ffb83701c30f9cdb1e804670434eb0.tar.zst PeerTube-91f8f8db97ffb83701c30f9cdb1e804670434eb0.zip |
createThumbnail -> updateThumbnail
Diffstat (limited to 'server/lib/thumbnail.ts')
-rw-r--r-- | server/lib/thumbnail.ts | 32 |
1 files changed, 16 insertions, 16 deletions
diff --git a/server/lib/thumbnail.ts b/server/lib/thumbnail.ts index cfee69cfc..c08523988 100644 --- a/server/lib/thumbnail.ts +++ b/server/lib/thumbnail.ts | |||
@@ -14,7 +14,7 @@ import { getVideoFilePath } from './video-paths' | |||
14 | 14 | ||
15 | type ImageSize = { height?: number, width?: number } | 15 | type ImageSize = { height?: number, width?: number } |
16 | 16 | ||
17 | function createPlaylistMiniatureFromExisting (options: { | 17 | function updatePlaylistMiniatureFromExisting (options: { |
18 | inputPath: string | 18 | inputPath: string |
19 | playlist: MVideoPlaylistThumbnail | 19 | playlist: MVideoPlaylistThumbnail |
20 | automaticallyGenerated: boolean | 20 | automaticallyGenerated: boolean |
@@ -26,7 +26,7 @@ function createPlaylistMiniatureFromExisting (options: { | |||
26 | const type = ThumbnailType.MINIATURE | 26 | const type = ThumbnailType.MINIATURE |
27 | 27 | ||
28 | const thumbnailCreator = () => processImage(inputPath, outputPath, { width, height }, keepOriginal) | 28 | const thumbnailCreator = () => processImage(inputPath, outputPath, { width, height }, keepOriginal) |
29 | return createThumbnailFromFunction({ | 29 | return updateThumbnailFromFunction({ |
30 | thumbnailCreator, | 30 | thumbnailCreator, |
31 | filename, | 31 | filename, |
32 | height, | 32 | height, |
@@ -37,7 +37,7 @@ function createPlaylistMiniatureFromExisting (options: { | |||
37 | }) | 37 | }) |
38 | } | 38 | } |
39 | 39 | ||
40 | function createPlaylistMiniatureFromUrl (options: { | 40 | function updatePlaylistMiniatureFromUrl (options: { |
41 | downloadUrl: string | 41 | downloadUrl: string |
42 | playlist: MVideoPlaylistThumbnail | 42 | playlist: MVideoPlaylistThumbnail |
43 | size?: ImageSize | 43 | size?: ImageSize |
@@ -52,10 +52,10 @@ function createPlaylistMiniatureFromUrl (options: { | |||
52 | : downloadUrl | 52 | : downloadUrl |
53 | 53 | ||
54 | const thumbnailCreator = () => downloadImage(downloadUrl, basePath, filename, { width, height }) | 54 | const thumbnailCreator = () => downloadImage(downloadUrl, basePath, filename, { width, height }) |
55 | return createThumbnailFromFunction({ thumbnailCreator, filename, height, width, type, existingThumbnail, fileUrl }) | 55 | return updateThumbnailFromFunction({ thumbnailCreator, filename, height, width, type, existingThumbnail, fileUrl }) |
56 | } | 56 | } |
57 | 57 | ||
58 | function createVideoMiniatureFromUrl (options: { | 58 | function updateVideoMiniatureFromUrl (options: { |
59 | downloadUrl: string | 59 | downloadUrl: string |
60 | video: MVideoThumbnail | 60 | video: MVideoThumbnail |
61 | type: ThumbnailType | 61 | type: ThumbnailType |
@@ -82,10 +82,10 @@ function createVideoMiniatureFromUrl (options: { | |||
82 | return Promise.resolve() | 82 | return Promise.resolve() |
83 | } | 83 | } |
84 | 84 | ||
85 | return createThumbnailFromFunction({ thumbnailCreator, filename, height, width, type, existingThumbnail, fileUrl }) | 85 | return updateThumbnailFromFunction({ thumbnailCreator, filename, height, width, type, existingThumbnail, fileUrl }) |
86 | } | 86 | } |
87 | 87 | ||
88 | function createVideoMiniatureFromExisting (options: { | 88 | function updateVideoMiniatureFromExisting (options: { |
89 | inputPath: string | 89 | inputPath: string |
90 | video: MVideoThumbnail | 90 | video: MVideoThumbnail |
91 | type: ThumbnailType | 91 | type: ThumbnailType |
@@ -98,7 +98,7 @@ function createVideoMiniatureFromExisting (options: { | |||
98 | const { filename, outputPath, height, width, existingThumbnail } = buildMetadataFromVideo(video, type, size) | 98 | const { filename, outputPath, height, width, existingThumbnail } = buildMetadataFromVideo(video, type, size) |
99 | const thumbnailCreator = () => processImage(inputPath, outputPath, { width, height }, keepOriginal) | 99 | const thumbnailCreator = () => processImage(inputPath, outputPath, { width, height }, keepOriginal) |
100 | 100 | ||
101 | return createThumbnailFromFunction({ | 101 | return updateThumbnailFromFunction({ |
102 | thumbnailCreator, | 102 | thumbnailCreator, |
103 | filename, | 103 | filename, |
104 | height, | 104 | height, |
@@ -123,7 +123,7 @@ function generateVideoMiniature (options: { | |||
123 | ? () => processImage(ASSETS_PATH.DEFAULT_AUDIO_BACKGROUND, outputPath, { width, height }, true) | 123 | ? () => processImage(ASSETS_PATH.DEFAULT_AUDIO_BACKGROUND, outputPath, { width, height }, true) |
124 | : () => generateImageFromVideoFile(input, basePath, filename, { height, width }) | 124 | : () => generateImageFromVideoFile(input, basePath, filename, { height, width }) |
125 | 125 | ||
126 | return createThumbnailFromFunction({ | 126 | return updateThumbnailFromFunction({ |
127 | thumbnailCreator, | 127 | thumbnailCreator, |
128 | filename, | 128 | filename, |
129 | height, | 129 | height, |
@@ -134,7 +134,7 @@ function generateVideoMiniature (options: { | |||
134 | }) | 134 | }) |
135 | } | 135 | } |
136 | 136 | ||
137 | function createPlaceholderThumbnail (options: { | 137 | function updatePlaceholderThumbnail (options: { |
138 | fileUrl: string | 138 | fileUrl: string |
139 | video: MVideoThumbnail | 139 | video: MVideoThumbnail |
140 | type: ThumbnailType | 140 | type: ThumbnailType |
@@ -165,11 +165,11 @@ function createPlaceholderThumbnail (options: { | |||
165 | 165 | ||
166 | export { | 166 | export { |
167 | generateVideoMiniature, | 167 | generateVideoMiniature, |
168 | createVideoMiniatureFromUrl, | 168 | updateVideoMiniatureFromUrl, |
169 | createVideoMiniatureFromExisting, | 169 | updateVideoMiniatureFromExisting, |
170 | createPlaceholderThumbnail, | 170 | updatePlaceholderThumbnail, |
171 | createPlaylistMiniatureFromUrl, | 171 | updatePlaylistMiniatureFromUrl, |
172 | createPlaylistMiniatureFromExisting | 172 | updatePlaylistMiniatureFromExisting |
173 | } | 173 | } |
174 | 174 | ||
175 | function hasThumbnailUrlChanged (existingThumbnail: MThumbnail, downloadUrl: string, video: MVideoUUID) { | 175 | function hasThumbnailUrlChanged (existingThumbnail: MThumbnail, downloadUrl: string, video: MVideoUUID) { |
@@ -231,7 +231,7 @@ function buildMetadataFromVideo (video: MVideoThumbnail, type: ThumbnailType, si | |||
231 | return undefined | 231 | return undefined |
232 | } | 232 | } |
233 | 233 | ||
234 | async function createThumbnailFromFunction (parameters: { | 234 | async function updateThumbnailFromFunction (parameters: { |
235 | thumbnailCreator: () => Promise<any> | 235 | thumbnailCreator: () => Promise<any> |
236 | filename: string | 236 | filename: string |
237 | height: number | 237 | height: number |