]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/commitdiff
createThumbnail -> updateThumbnail
authorChocobozzz <me@florianbigard.com>
Fri, 4 Jun 2021 07:19:01 +0000 (09:19 +0200)
committerChocobozzz <me@florianbigard.com>
Fri, 4 Jun 2021 13:45:44 +0000 (15:45 +0200)
server/controllers/api/video-playlist.ts
server/controllers/api/videos/import.ts
server/controllers/api/videos/live.ts
server/lib/activitypub/playlists/create-update.ts
server/lib/activitypub/videos/shared/abstract-builder.ts
server/lib/thumbnail.ts
server/lib/video.ts

index b8613699bde900b65f3895027471807ea5bbc711..7c816b93acce849e636b173c3d4261153183f47f 100644 (file)
@@ -18,7 +18,7 @@ import { sequelizeTypescript } from '../../initializers/database'
 import { sendCreateVideoPlaylist, sendDeleteVideoPlaylist, sendUpdateVideoPlaylist } from '../../lib/activitypub/send'
 import { getLocalVideoPlaylistActivityPubUrl, getLocalVideoPlaylistElementActivityPubUrl } from '../../lib/activitypub/url'
 import { JobQueue } from '../../lib/job-queue'
-import { createPlaylistMiniatureFromExisting } from '../../lib/thumbnail'
+import { updatePlaylistMiniatureFromExisting } from '../../lib/thumbnail'
 import {
   asyncMiddleware,
   asyncRetryTransactionMiddleware,
@@ -173,7 +173,7 @@ async function addVideoPlaylist (req: express.Request, res: express.Response) {
 
   const thumbnailField = req.files['thumbnailfile']
   const thumbnailModel = thumbnailField
-    ? await createPlaylistMiniatureFromExisting({
+    ? await updatePlaylistMiniatureFromExisting({
       inputPath: thumbnailField[0].path,
       playlist: videoPlaylist,
       automaticallyGenerated: false
@@ -215,7 +215,7 @@ async function updateVideoPlaylist (req: express.Request, res: express.Response)
 
   const thumbnailField = req.files['thumbnailfile']
   const thumbnailModel = thumbnailField
-    ? await createPlaylistMiniatureFromExisting({
+    ? await updatePlaylistMiniatureFromExisting({
       inputPath: thumbnailField[0].path,
       playlist: videoPlaylistInstance,
       automaticallyGenerated: false
@@ -482,7 +482,7 @@ async function generateThumbnailForPlaylist (videoPlaylist: MVideoPlaylistThumbn
   }
 
   const inputPath = join(CONFIG.STORAGE.THUMBNAILS_DIR, videoMiniature.filename)
-  const thumbnailModel = await createPlaylistMiniatureFromExisting({
+  const thumbnailModel = await updatePlaylistMiniatureFromExisting({
     inputPath,
     playlist: videoPlaylist,
     automaticallyGenerated: true,
index 42ca59975aefe6b22448e9ac0d7cc7c45604dbca..de9a5308a1e50a426002fe224f3e5bae8e77c3ca 100644 (file)
@@ -31,7 +31,7 @@ import { MIMETYPES } from '../../../initializers/constants'
 import { sequelizeTypescript } from '../../../initializers/database'
 import { getLocalVideoActivityPubUrl } from '../../../lib/activitypub/url'
 import { JobQueue } from '../../../lib/job-queue/job-queue'
-import { createVideoMiniatureFromExisting, createVideoMiniatureFromUrl } from '../../../lib/thumbnail'
+import { updateVideoMiniatureFromExisting, updateVideoMiniatureFromUrl } from '../../../lib/thumbnail'
 import { autoBlacklistVideoIfNeeded } from '../../../lib/video-blacklist'
 import { asyncMiddleware, asyncRetryTransactionMiddleware, authenticate, videoImportAddValidator } from '../../../middlewares'
 import { VideoModel } from '../../../models/video/video'
@@ -230,7 +230,7 @@ async function processThumbnail (req: express.Request, video: MVideoThumbnail) {
   if (thumbnailField) {
     const thumbnailPhysicalFile = thumbnailField[0]
 
-    return createVideoMiniatureFromExisting({
+    return updateVideoMiniatureFromExisting({
       inputPath: thumbnailPhysicalFile.path,
       video,
       type: ThumbnailType.MINIATURE,
@@ -246,7 +246,7 @@ async function processPreview (req: express.Request, video: MVideoThumbnail): Pr
   if (previewField) {
     const previewPhysicalFile = previewField[0]
 
-    return createVideoMiniatureFromExisting({
+    return updateVideoMiniatureFromExisting({
       inputPath: previewPhysicalFile.path,
       video,
       type: ThumbnailType.PREVIEW,
@@ -259,7 +259,7 @@ async function processPreview (req: express.Request, video: MVideoThumbnail): Pr
 
 async function processThumbnailFromUrl (url: string, video: MVideoThumbnail) {
   try {
-    return createVideoMiniatureFromUrl({ downloadUrl: url, video, type: ThumbnailType.MINIATURE })
+    return updateVideoMiniatureFromUrl({ downloadUrl: url, video, type: ThumbnailType.MINIATURE })
   } catch (err) {
     logger.warn('Cannot generate video thumbnail %s for %s.', url, video.url, { err })
     return undefined
@@ -268,7 +268,7 @@ async function processThumbnailFromUrl (url: string, video: MVideoThumbnail) {
 
 async function processPreviewFromUrl (url: string, video: MVideoThumbnail) {
   try {
-    return createVideoMiniatureFromUrl({ downloadUrl: url, video, type: ThumbnailType.PREVIEW })
+    return updateVideoMiniatureFromUrl({ downloadUrl: url, video, type: ThumbnailType.PREVIEW })
   } catch (err) {
     logger.warn('Cannot generate video preview %s for %s.', url, video.url, { err })
     return undefined
index 6b733c577b539206fe9afd2a8938c8e6f58e16f4..61fa979c47919a261350b116af4f152e8478b06b 100644 (file)
@@ -13,7 +13,7 @@ import { MVideoDetails, MVideoFullLight } from '@server/types/models'
 import { LiveVideoCreate, LiveVideoUpdate, VideoState } from '../../../../shared'
 import { logger } from '../../../helpers/logger'
 import { sequelizeTypescript } from '../../../initializers/database'
-import { createVideoMiniatureFromExisting } from '../../../lib/thumbnail'
+import { updateVideoMiniatureFromExisting } from '../../../lib/thumbnail'
 import { asyncMiddleware, asyncRetryTransactionMiddleware, authenticate } from '../../../middlewares'
 import { VideoModel } from '../../../models/video/video'
 import { HttpStatusCode } from '../../../../shared/core-utils/miscs/http-error-codes'
@@ -100,7 +100,7 @@ async function addLiveVideo (req: express.Request, res: express.Response) {
     video,
     files: req.files,
     fallback: type => {
-      return createVideoMiniatureFromExisting({
+      return updateVideoMiniatureFromExisting({
         inputPath: ASSETS_PATH.DEFAULT_LIVE_BACKGROUND,
         video,
         type,
index fcfcc41a28fcd0ecd8546659d64899b8f38487c0..dd4316d54c34dac1e3baba6f2cf8abf668c56c91 100644 (file)
@@ -2,7 +2,7 @@ import { isArray } from '@server/helpers/custom-validators/misc'
 import { logger, loggerTagsFactory } from '@server/helpers/logger'
 import { CRAWL_REQUEST_CONCURRENCY } from '@server/initializers/constants'
 import { sequelizeTypescript } from '@server/initializers/database'
-import { createPlaylistMiniatureFromUrl } from '@server/lib/thumbnail'
+import { updatePlaylistMiniatureFromUrl } from '@server/lib/thumbnail'
 import { VideoPlaylistModel } from '@server/models/video/video-playlist'
 import { VideoPlaylistElementModel } from '@server/models/video/video-playlist-element'
 import { FilteredModelAttributes } from '@server/types'
@@ -98,7 +98,7 @@ async function fetchElementUrls (playlistObject: PlaylistObject) {
 
 async function updatePlaylistThumbnail (playlistObject: PlaylistObject, playlist: MVideoPlaylistFull) {
   if (playlistObject.icon) {
-    const thumbnailModel = await createPlaylistMiniatureFromUrl({ downloadUrl: playlistObject.icon.url, playlist })
+    const thumbnailModel = await updatePlaylistMiniatureFromUrl({ downloadUrl: playlistObject.icon.url, playlist })
     await playlist.setAndSaveThumbnail(thumbnailModel, undefined)
 
     return
index 4bd38b40c1834da7f0dcc584cc48167de4684fa5..0b58ddb33f4df12b49b6540294af6d179455803d 100644 (file)
@@ -2,7 +2,7 @@ import { Transaction } from 'sequelize/types'
 import { checkUrlsSameHost } from '@server/helpers/activitypub'
 import { deleteNonExistingModels } from '@server/helpers/database-utils'
 import { logger, LoggerTagsFn } from '@server/helpers/logger'
-import { createPlaceholderThumbnail, createVideoMiniatureFromUrl } from '@server/lib/thumbnail'
+import { updatePlaceholderThumbnail, updateVideoMiniatureFromUrl } from '@server/lib/thumbnail'
 import { setVideoTags } from '@server/lib/video'
 import { VideoCaptionModel } from '@server/models/video/video-caption'
 import { VideoFileModel } from '@server/models/video/video-file'
@@ -38,7 +38,7 @@ export abstract class APVideoAbstractBuilder {
   }
 
   protected tryToGenerateThumbnail (video: MVideoThumbnail): Promise<MThumbnail> {
-    return createVideoMiniatureFromUrl({
+    return updateVideoMiniatureFromUrl({
       downloadUrl: getThumbnailFromIcons(this.videoObject).url,
       video,
       type: ThumbnailType.MINIATURE
@@ -54,7 +54,7 @@ export abstract class APVideoAbstractBuilder {
     const previewIcon = getPreviewFromIcons(this.videoObject)
     if (!previewIcon) return
 
-    const previewModel = createPlaceholderThumbnail({
+    const previewModel = updatePlaceholderThumbnail({
       fileUrl: previewIcon.url,
       video,
       type: ThumbnailType.PREVIEW,
index cfee69cfc50df4ad6ef9733357c26f619a87662d..c085239880ded8dfbce700b10ce5b2b706ef0c98 100644 (file)
@@ -14,7 +14,7 @@ import { getVideoFilePath } from './video-paths'
 
 type ImageSize = { height?: number, width?: number }
 
-function createPlaylistMiniatureFromExisting (options: {
+function updatePlaylistMiniatureFromExisting (options: {
   inputPath: string
   playlist: MVideoPlaylistThumbnail
   automaticallyGenerated: boolean
@@ -26,7 +26,7 @@ function createPlaylistMiniatureFromExisting (options: {
   const type = ThumbnailType.MINIATURE
 
   const thumbnailCreator = () => processImage(inputPath, outputPath, { width, height }, keepOriginal)
-  return createThumbnailFromFunction({
+  return updateThumbnailFromFunction({
     thumbnailCreator,
     filename,
     height,
@@ -37,7 +37,7 @@ function createPlaylistMiniatureFromExisting (options: {
   })
 }
 
-function createPlaylistMiniatureFromUrl (options: {
+function updatePlaylistMiniatureFromUrl (options: {
   downloadUrl: string
   playlist: MVideoPlaylistThumbnail
   size?: ImageSize
@@ -52,10 +52,10 @@ function createPlaylistMiniatureFromUrl (options: {
     : downloadUrl
 
   const thumbnailCreator = () => downloadImage(downloadUrl, basePath, filename, { width, height })
-  return createThumbnailFromFunction({ thumbnailCreator, filename, height, width, type, existingThumbnail, fileUrl })
+  return updateThumbnailFromFunction({ thumbnailCreator, filename, height, width, type, existingThumbnail, fileUrl })
 }
 
-function createVideoMiniatureFromUrl (options: {
+function updateVideoMiniatureFromUrl (options: {
   downloadUrl: string
   video: MVideoThumbnail
   type: ThumbnailType
@@ -82,10 +82,10 @@ function createVideoMiniatureFromUrl (options: {
     return Promise.resolve()
   }
 
-  return createThumbnailFromFunction({ thumbnailCreator, filename, height, width, type, existingThumbnail, fileUrl })
+  return updateThumbnailFromFunction({ thumbnailCreator, filename, height, width, type, existingThumbnail, fileUrl })
 }
 
-function createVideoMiniatureFromExisting (options: {
+function updateVideoMiniatureFromExisting (options: {
   inputPath: string
   video: MVideoThumbnail
   type: ThumbnailType
@@ -98,7 +98,7 @@ function createVideoMiniatureFromExisting (options: {
   const { filename, outputPath, height, width, existingThumbnail } = buildMetadataFromVideo(video, type, size)
   const thumbnailCreator = () => processImage(inputPath, outputPath, { width, height }, keepOriginal)
 
-  return createThumbnailFromFunction({
+  return updateThumbnailFromFunction({
     thumbnailCreator,
     filename,
     height,
@@ -123,7 +123,7 @@ function generateVideoMiniature (options: {
     ? () => processImage(ASSETS_PATH.DEFAULT_AUDIO_BACKGROUND, outputPath, { width, height }, true)
     : () => generateImageFromVideoFile(input, basePath, filename, { height, width })
 
-  return createThumbnailFromFunction({
+  return updateThumbnailFromFunction({
     thumbnailCreator,
     filename,
     height,
@@ -134,7 +134,7 @@ function generateVideoMiniature (options: {
   })
 }
 
-function createPlaceholderThumbnail (options: {
+function updatePlaceholderThumbnail (options: {
   fileUrl: string
   video: MVideoThumbnail
   type: ThumbnailType
@@ -165,11 +165,11 @@ function createPlaceholderThumbnail (options: {
 
 export {
   generateVideoMiniature,
-  createVideoMiniatureFromUrl,
-  createVideoMiniatureFromExisting,
-  createPlaceholderThumbnail,
-  createPlaylistMiniatureFromUrl,
-  createPlaylistMiniatureFromExisting
+  updateVideoMiniatureFromUrl,
+  updateVideoMiniatureFromExisting,
+  updatePlaceholderThumbnail,
+  updatePlaylistMiniatureFromUrl,
+  updatePlaylistMiniatureFromExisting
 }
 
 function hasThumbnailUrlChanged (existingThumbnail: MThumbnail, downloadUrl: string, video: MVideoUUID) {
@@ -231,7 +231,7 @@ function buildMetadataFromVideo (video: MVideoThumbnail, type: ThumbnailType, si
   return undefined
 }
 
-async function createThumbnailFromFunction (parameters: {
+async function updateThumbnailFromFunction (parameters: {
   thumbnailCreator: () => Promise<any>
   filename: string
   height: number
index d26cf85cd1ed0bc686059342b965c380a3b2504c..daf998704b55cc2eae78fec787f15c019a993ec9 100644 (file)
@@ -10,7 +10,7 @@ import { ThumbnailType, VideoCreate, VideoPrivacy, VideoTranscodingPayload } fro
 import { federateVideoIfNeeded } from './activitypub/videos'
 import { JobQueue } from './job-queue/job-queue'
 import { Notifier } from './notifier'
-import { createVideoMiniatureFromExisting } from './thumbnail'
+import { updateVideoMiniatureFromExisting } from './thumbnail'
 
 function buildLocalVideoFromReq (videoInfo: VideoCreate, channelId: number): FilteredModelAttributes<VideoModel> {
   return {
@@ -54,7 +54,7 @@ async function buildVideoThumbnailsFromReq (options: {
     const fields = files?.[p.fieldName]
 
     if (fields) {
-      return createVideoMiniatureFromExisting({
+      return updateVideoMiniatureFromExisting({
         inputPath: fields[0].path,
         video,
         type: p.type,