aboutsummaryrefslogtreecommitdiffhomepage
path: root/server
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2021-06-04 09:19:01 +0200
committerChocobozzz <me@florianbigard.com>2021-06-04 15:45:44 +0200
commit91f8f8db97ffb83701c30f9cdb1e804670434eb0 (patch)
tree4b6659c8572d95b78454c6c4806ddc77a9c420e1 /server
parent1333ab1f2d4ec495084c5368df25610683582ae3 (diff)
downloadPeerTube-91f8f8db97ffb83701c30f9cdb1e804670434eb0.tar.gz
PeerTube-91f8f8db97ffb83701c30f9cdb1e804670434eb0.tar.zst
PeerTube-91f8f8db97ffb83701c30f9cdb1e804670434eb0.zip
createThumbnail -> updateThumbnail
Diffstat (limited to 'server')
-rw-r--r--server/controllers/api/video-playlist.ts8
-rw-r--r--server/controllers/api/videos/import.ts10
-rw-r--r--server/controllers/api/videos/live.ts4
-rw-r--r--server/lib/activitypub/playlists/create-update.ts4
-rw-r--r--server/lib/activitypub/videos/shared/abstract-builder.ts6
-rw-r--r--server/lib/thumbnail.ts32
-rw-r--r--server/lib/video.ts4
7 files changed, 34 insertions, 34 deletions
diff --git a/server/controllers/api/video-playlist.ts b/server/controllers/api/video-playlist.ts
index b8613699b..7c816b93a 100644
--- a/server/controllers/api/video-playlist.ts
+++ b/server/controllers/api/video-playlist.ts
@@ -18,7 +18,7 @@ import { sequelizeTypescript } from '../../initializers/database'
18import { sendCreateVideoPlaylist, sendDeleteVideoPlaylist, sendUpdateVideoPlaylist } from '../../lib/activitypub/send' 18import { sendCreateVideoPlaylist, sendDeleteVideoPlaylist, sendUpdateVideoPlaylist } from '../../lib/activitypub/send'
19import { getLocalVideoPlaylistActivityPubUrl, getLocalVideoPlaylistElementActivityPubUrl } from '../../lib/activitypub/url' 19import { getLocalVideoPlaylistActivityPubUrl, getLocalVideoPlaylistElementActivityPubUrl } from '../../lib/activitypub/url'
20import { JobQueue } from '../../lib/job-queue' 20import { JobQueue } from '../../lib/job-queue'
21import { createPlaylistMiniatureFromExisting } from '../../lib/thumbnail' 21import { updatePlaylistMiniatureFromExisting } from '../../lib/thumbnail'
22import { 22import {
23 asyncMiddleware, 23 asyncMiddleware,
24 asyncRetryTransactionMiddleware, 24 asyncRetryTransactionMiddleware,
@@ -173,7 +173,7 @@ async function addVideoPlaylist (req: express.Request, res: express.Response) {
173 173
174 const thumbnailField = req.files['thumbnailfile'] 174 const thumbnailField = req.files['thumbnailfile']
175 const thumbnailModel = thumbnailField 175 const thumbnailModel = thumbnailField
176 ? await createPlaylistMiniatureFromExisting({ 176 ? await updatePlaylistMiniatureFromExisting({
177 inputPath: thumbnailField[0].path, 177 inputPath: thumbnailField[0].path,
178 playlist: videoPlaylist, 178 playlist: videoPlaylist,
179 automaticallyGenerated: false 179 automaticallyGenerated: false
@@ -215,7 +215,7 @@ async function updateVideoPlaylist (req: express.Request, res: express.Response)
215 215
216 const thumbnailField = req.files['thumbnailfile'] 216 const thumbnailField = req.files['thumbnailfile']
217 const thumbnailModel = thumbnailField 217 const thumbnailModel = thumbnailField
218 ? await createPlaylistMiniatureFromExisting({ 218 ? await updatePlaylistMiniatureFromExisting({
219 inputPath: thumbnailField[0].path, 219 inputPath: thumbnailField[0].path,
220 playlist: videoPlaylistInstance, 220 playlist: videoPlaylistInstance,
221 automaticallyGenerated: false 221 automaticallyGenerated: false
@@ -482,7 +482,7 @@ async function generateThumbnailForPlaylist (videoPlaylist: MVideoPlaylistThumbn
482 } 482 }
483 483
484 const inputPath = join(CONFIG.STORAGE.THUMBNAILS_DIR, videoMiniature.filename) 484 const inputPath = join(CONFIG.STORAGE.THUMBNAILS_DIR, videoMiniature.filename)
485 const thumbnailModel = await createPlaylistMiniatureFromExisting({ 485 const thumbnailModel = await updatePlaylistMiniatureFromExisting({
486 inputPath, 486 inputPath,
487 playlist: videoPlaylist, 487 playlist: videoPlaylist,
488 automaticallyGenerated: true, 488 automaticallyGenerated: true,
diff --git a/server/controllers/api/videos/import.ts b/server/controllers/api/videos/import.ts
index 42ca59975..de9a5308a 100644
--- a/server/controllers/api/videos/import.ts
+++ b/server/controllers/api/videos/import.ts
@@ -31,7 +31,7 @@ import { MIMETYPES } from '../../../initializers/constants'
31import { sequelizeTypescript } from '../../../initializers/database' 31import { sequelizeTypescript } from '../../../initializers/database'
32import { getLocalVideoActivityPubUrl } from '../../../lib/activitypub/url' 32import { getLocalVideoActivityPubUrl } from '../../../lib/activitypub/url'
33import { JobQueue } from '../../../lib/job-queue/job-queue' 33import { JobQueue } from '../../../lib/job-queue/job-queue'
34import { createVideoMiniatureFromExisting, createVideoMiniatureFromUrl } from '../../../lib/thumbnail' 34import { updateVideoMiniatureFromExisting, updateVideoMiniatureFromUrl } from '../../../lib/thumbnail'
35import { autoBlacklistVideoIfNeeded } from '../../../lib/video-blacklist' 35import { autoBlacklistVideoIfNeeded } from '../../../lib/video-blacklist'
36import { asyncMiddleware, asyncRetryTransactionMiddleware, authenticate, videoImportAddValidator } from '../../../middlewares' 36import { asyncMiddleware, asyncRetryTransactionMiddleware, authenticate, videoImportAddValidator } from '../../../middlewares'
37import { VideoModel } from '../../../models/video/video' 37import { VideoModel } from '../../../models/video/video'
@@ -230,7 +230,7 @@ async function processThumbnail (req: express.Request, video: MVideoThumbnail) {
230 if (thumbnailField) { 230 if (thumbnailField) {
231 const thumbnailPhysicalFile = thumbnailField[0] 231 const thumbnailPhysicalFile = thumbnailField[0]
232 232
233 return createVideoMiniatureFromExisting({ 233 return updateVideoMiniatureFromExisting({
234 inputPath: thumbnailPhysicalFile.path, 234 inputPath: thumbnailPhysicalFile.path,
235 video, 235 video,
236 type: ThumbnailType.MINIATURE, 236 type: ThumbnailType.MINIATURE,
@@ -246,7 +246,7 @@ async function processPreview (req: express.Request, video: MVideoThumbnail): Pr
246 if (previewField) { 246 if (previewField) {
247 const previewPhysicalFile = previewField[0] 247 const previewPhysicalFile = previewField[0]
248 248
249 return createVideoMiniatureFromExisting({ 249 return updateVideoMiniatureFromExisting({
250 inputPath: previewPhysicalFile.path, 250 inputPath: previewPhysicalFile.path,
251 video, 251 video,
252 type: ThumbnailType.PREVIEW, 252 type: ThumbnailType.PREVIEW,
@@ -259,7 +259,7 @@ async function processPreview (req: express.Request, video: MVideoThumbnail): Pr
259 259
260async function processThumbnailFromUrl (url: string, video: MVideoThumbnail) { 260async function processThumbnailFromUrl (url: string, video: MVideoThumbnail) {
261 try { 261 try {
262 return createVideoMiniatureFromUrl({ downloadUrl: url, video, type: ThumbnailType.MINIATURE }) 262 return updateVideoMiniatureFromUrl({ downloadUrl: url, video, type: ThumbnailType.MINIATURE })
263 } catch (err) { 263 } catch (err) {
264 logger.warn('Cannot generate video thumbnail %s for %s.', url, video.url, { err }) 264 logger.warn('Cannot generate video thumbnail %s for %s.', url, video.url, { err })
265 return undefined 265 return undefined
@@ -268,7 +268,7 @@ async function processThumbnailFromUrl (url: string, video: MVideoThumbnail) {
268 268
269async function processPreviewFromUrl (url: string, video: MVideoThumbnail) { 269async function processPreviewFromUrl (url: string, video: MVideoThumbnail) {
270 try { 270 try {
271 return createVideoMiniatureFromUrl({ downloadUrl: url, video, type: ThumbnailType.PREVIEW }) 271 return updateVideoMiniatureFromUrl({ downloadUrl: url, video, type: ThumbnailType.PREVIEW })
272 } catch (err) { 272 } catch (err) {
273 logger.warn('Cannot generate video preview %s for %s.', url, video.url, { err }) 273 logger.warn('Cannot generate video preview %s for %s.', url, video.url, { err })
274 return undefined 274 return undefined
diff --git a/server/controllers/api/videos/live.ts b/server/controllers/api/videos/live.ts
index 6b733c577..61fa979c4 100644
--- a/server/controllers/api/videos/live.ts
+++ b/server/controllers/api/videos/live.ts
@@ -13,7 +13,7 @@ import { MVideoDetails, MVideoFullLight } from '@server/types/models'
13import { LiveVideoCreate, LiveVideoUpdate, VideoState } from '../../../../shared' 13import { LiveVideoCreate, LiveVideoUpdate, VideoState } from '../../../../shared'
14import { logger } from '../../../helpers/logger' 14import { logger } from '../../../helpers/logger'
15import { sequelizeTypescript } from '../../../initializers/database' 15import { sequelizeTypescript } from '../../../initializers/database'
16import { createVideoMiniatureFromExisting } from '../../../lib/thumbnail' 16import { updateVideoMiniatureFromExisting } from '../../../lib/thumbnail'
17import { asyncMiddleware, asyncRetryTransactionMiddleware, authenticate } from '../../../middlewares' 17import { asyncMiddleware, asyncRetryTransactionMiddleware, authenticate } from '../../../middlewares'
18import { VideoModel } from '../../../models/video/video' 18import { VideoModel } from '../../../models/video/video'
19import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes' 19import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
@@ -100,7 +100,7 @@ async function addLiveVideo (req: express.Request, res: express.Response) {
100 video, 100 video,
101 files: req.files, 101 files: req.files,
102 fallback: type => { 102 fallback: type => {
103 return createVideoMiniatureFromExisting({ 103 return updateVideoMiniatureFromExisting({
104 inputPath: ASSETS_PATH.DEFAULT_LIVE_BACKGROUND, 104 inputPath: ASSETS_PATH.DEFAULT_LIVE_BACKGROUND,
105 video, 105 video,
106 type, 106 type,
diff --git a/server/lib/activitypub/playlists/create-update.ts b/server/lib/activitypub/playlists/create-update.ts
index fcfcc41a2..dd4316d54 100644
--- a/server/lib/activitypub/playlists/create-update.ts
+++ b/server/lib/activitypub/playlists/create-update.ts
@@ -2,7 +2,7 @@ import { isArray } from '@server/helpers/custom-validators/misc'
2import { logger, loggerTagsFactory } from '@server/helpers/logger' 2import { logger, loggerTagsFactory } from '@server/helpers/logger'
3import { CRAWL_REQUEST_CONCURRENCY } from '@server/initializers/constants' 3import { CRAWL_REQUEST_CONCURRENCY } from '@server/initializers/constants'
4import { sequelizeTypescript } from '@server/initializers/database' 4import { sequelizeTypescript } from '@server/initializers/database'
5import { createPlaylistMiniatureFromUrl } from '@server/lib/thumbnail' 5import { updatePlaylistMiniatureFromUrl } from '@server/lib/thumbnail'
6import { VideoPlaylistModel } from '@server/models/video/video-playlist' 6import { VideoPlaylistModel } from '@server/models/video/video-playlist'
7import { VideoPlaylistElementModel } from '@server/models/video/video-playlist-element' 7import { VideoPlaylistElementModel } from '@server/models/video/video-playlist-element'
8import { FilteredModelAttributes } from '@server/types' 8import { FilteredModelAttributes } from '@server/types'
@@ -98,7 +98,7 @@ async function fetchElementUrls (playlistObject: PlaylistObject) {
98 98
99async function updatePlaylistThumbnail (playlistObject: PlaylistObject, playlist: MVideoPlaylistFull) { 99async function updatePlaylistThumbnail (playlistObject: PlaylistObject, playlist: MVideoPlaylistFull) {
100 if (playlistObject.icon) { 100 if (playlistObject.icon) {
101 const thumbnailModel = await createPlaylistMiniatureFromUrl({ downloadUrl: playlistObject.icon.url, playlist }) 101 const thumbnailModel = await updatePlaylistMiniatureFromUrl({ downloadUrl: playlistObject.icon.url, playlist })
102 await playlist.setAndSaveThumbnail(thumbnailModel, undefined) 102 await playlist.setAndSaveThumbnail(thumbnailModel, undefined)
103 103
104 return 104 return
diff --git a/server/lib/activitypub/videos/shared/abstract-builder.ts b/server/lib/activitypub/videos/shared/abstract-builder.ts
index 4bd38b40c..0b58ddb33 100644
--- a/server/lib/activitypub/videos/shared/abstract-builder.ts
+++ b/server/lib/activitypub/videos/shared/abstract-builder.ts
@@ -2,7 +2,7 @@ import { Transaction } from 'sequelize/types'
2import { checkUrlsSameHost } from '@server/helpers/activitypub' 2import { checkUrlsSameHost } from '@server/helpers/activitypub'
3import { deleteNonExistingModels } from '@server/helpers/database-utils' 3import { deleteNonExistingModels } from '@server/helpers/database-utils'
4import { logger, LoggerTagsFn } from '@server/helpers/logger' 4import { logger, LoggerTagsFn } from '@server/helpers/logger'
5import { createPlaceholderThumbnail, createVideoMiniatureFromUrl } from '@server/lib/thumbnail' 5import { updatePlaceholderThumbnail, updateVideoMiniatureFromUrl } from '@server/lib/thumbnail'
6import { setVideoTags } from '@server/lib/video' 6import { setVideoTags } from '@server/lib/video'
7import { VideoCaptionModel } from '@server/models/video/video-caption' 7import { VideoCaptionModel } from '@server/models/video/video-caption'
8import { VideoFileModel } from '@server/models/video/video-file' 8import { VideoFileModel } from '@server/models/video/video-file'
@@ -38,7 +38,7 @@ export abstract class APVideoAbstractBuilder {
38 } 38 }
39 39
40 protected tryToGenerateThumbnail (video: MVideoThumbnail): Promise<MThumbnail> { 40 protected tryToGenerateThumbnail (video: MVideoThumbnail): Promise<MThumbnail> {
41 return createVideoMiniatureFromUrl({ 41 return updateVideoMiniatureFromUrl({
42 downloadUrl: getThumbnailFromIcons(this.videoObject).url, 42 downloadUrl: getThumbnailFromIcons(this.videoObject).url,
43 video, 43 video,
44 type: ThumbnailType.MINIATURE 44 type: ThumbnailType.MINIATURE
@@ -54,7 +54,7 @@ export abstract class APVideoAbstractBuilder {
54 const previewIcon = getPreviewFromIcons(this.videoObject) 54 const previewIcon = getPreviewFromIcons(this.videoObject)
55 if (!previewIcon) return 55 if (!previewIcon) return
56 56
57 const previewModel = createPlaceholderThumbnail({ 57 const previewModel = updatePlaceholderThumbnail({
58 fileUrl: previewIcon.url, 58 fileUrl: previewIcon.url,
59 video, 59 video,
60 type: ThumbnailType.PREVIEW, 60 type: ThumbnailType.PREVIEW,
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
15type ImageSize = { height?: number, width?: number } 15type ImageSize = { height?: number, width?: number }
16 16
17function createPlaylistMiniatureFromExisting (options: { 17function 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
40function createPlaylistMiniatureFromUrl (options: { 40function 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
58function createVideoMiniatureFromUrl (options: { 58function 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
88function createVideoMiniatureFromExisting (options: { 88function 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
137function createPlaceholderThumbnail (options: { 137function 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
166export { 166export {
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
175function hasThumbnailUrlChanged (existingThumbnail: MThumbnail, downloadUrl: string, video: MVideoUUID) { 175function 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
234async function createThumbnailFromFunction (parameters: { 234async function updateThumbnailFromFunction (parameters: {
235 thumbnailCreator: () => Promise<any> 235 thumbnailCreator: () => Promise<any>
236 filename: string 236 filename: string
237 height: number 237 height: number
diff --git a/server/lib/video.ts b/server/lib/video.ts
index d26cf85cd..daf998704 100644
--- a/server/lib/video.ts
+++ b/server/lib/video.ts
@@ -10,7 +10,7 @@ import { ThumbnailType, VideoCreate, VideoPrivacy, VideoTranscodingPayload } fro
10import { federateVideoIfNeeded } from './activitypub/videos' 10import { federateVideoIfNeeded } from './activitypub/videos'
11import { JobQueue } from './job-queue/job-queue' 11import { JobQueue } from './job-queue/job-queue'
12import { Notifier } from './notifier' 12import { Notifier } from './notifier'
13import { createVideoMiniatureFromExisting } from './thumbnail' 13import { updateVideoMiniatureFromExisting } from './thumbnail'
14 14
15function buildLocalVideoFromReq (videoInfo: VideoCreate, channelId: number): FilteredModelAttributes<VideoModel> { 15function buildLocalVideoFromReq (videoInfo: VideoCreate, channelId: number): FilteredModelAttributes<VideoModel> {
16 return { 16 return {
@@ -54,7 +54,7 @@ async function buildVideoThumbnailsFromReq (options: {
54 const fields = files?.[p.fieldName] 54 const fields = files?.[p.fieldName]
55 55
56 if (fields) { 56 if (fields) {
57 return createVideoMiniatureFromExisting({ 57 return updateVideoMiniatureFromExisting({
58 inputPath: fields[0].path, 58 inputPath: fields[0].path,
59 video, 59 video,
60 type: p.type, 60 type: p.type,