Skip to content

ActivityPub-federated video streaming platform using P2P directly in your web browser

createThumbnail -> updateThumbnail

Chocobozzz91f8f8db97ff
diff --git a/server/controllers/api/video-playlist.ts b/server/controllers/api/video-playlist.ts
index b8613699bd..7c816b93ac 100644
--- a/server/controllers/api/video-playlist.ts
+++ b/server/controllers/api/video-playlist.ts
@@ -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,
diff --git a/server/controllers/api/videos/import.ts b/server/controllers/api/videos/import.ts
index 42ca59975a..de9a5308a1 100644
--- a/server/controllers/api/videos/import.ts
+++ b/server/controllers/api/videos/import.ts
@@ -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
diff --git a/server/controllers/api/videos/live.ts b/server/controllers/api/videos/live.ts
index 6b733c577b..61fa979c47 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'
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,
diff --git a/server/lib/activitypub/playlists/create-update.ts b/server/lib/activitypub/playlists/create-update.ts
index fcfcc41a28..dd4316d54c 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'
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
diff --git a/server/lib/activitypub/videos/shared/abstract-builder.ts b/server/lib/activitypub/videos/shared/abstract-builder.ts
index 4bd38b40c1..0b58ddb33f 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'
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,
diff --git a/server/lib/thumbnail.ts b/server/lib/thumbnail.ts
index cfee69cfc5..c085239880 100644
--- a/server/lib/thumbnail.ts
+++ b/server/lib/thumbnail.ts
@@ -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
diff --git a/server/lib/video.ts b/server/lib/video.ts
index d26cf85cd1..daf998704b 100644
--- a/server/lib/video.ts
+++ b/server/lib/video.ts
@@ -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,