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,
const thumbnailField = req.files['thumbnailfile']
const thumbnailModel = thumbnailField
- ? await createPlaylistMiniatureFromExisting({
+ ? await updatePlaylistMiniatureFromExisting({
inputPath: thumbnailField[0].path,
playlist: videoPlaylist,
automaticallyGenerated: false
const thumbnailField = req.files['thumbnailfile']
const thumbnailModel = thumbnailField
- ? await createPlaylistMiniatureFromExisting({
+ ? await updatePlaylistMiniatureFromExisting({
inputPath: thumbnailField[0].path,
playlist: videoPlaylistInstance,
automaticallyGenerated: false
}
const inputPath = join(CONFIG.STORAGE.THUMBNAILS_DIR, videoMiniature.filename)
- const thumbnailModel = await createPlaylistMiniatureFromExisting({
+ const thumbnailModel = await updatePlaylistMiniatureFromExisting({
inputPath,
playlist: videoPlaylist,
automaticallyGenerated: true,
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'
if (thumbnailField) {
const thumbnailPhysicalFile = thumbnailField[0]
- return createVideoMiniatureFromExisting({
+ return updateVideoMiniatureFromExisting({
inputPath: thumbnailPhysicalFile.path,
video,
type: ThumbnailType.MINIATURE,
if (previewField) {
const previewPhysicalFile = previewField[0]
- return createVideoMiniatureFromExisting({
+ return updateVideoMiniatureFromExisting({
inputPath: previewPhysicalFile.path,
video,
type: ThumbnailType.PREVIEW,
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
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
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'
video,
files: req.files,
fallback: type => {
- return createVideoMiniatureFromExisting({
+ return updateVideoMiniatureFromExisting({
inputPath: ASSETS_PATH.DEFAULT_LIVE_BACKGROUND,
video,
type,
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'
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
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'
}
protected tryToGenerateThumbnail (video: MVideoThumbnail): Promise<MThumbnail> {
- return createVideoMiniatureFromUrl({
+ return updateVideoMiniatureFromUrl({
downloadUrl: getThumbnailFromIcons(this.videoObject).url,
video,
type: ThumbnailType.MINIATURE
const previewIcon = getPreviewFromIcons(this.videoObject)
if (!previewIcon) return
- const previewModel = createPlaceholderThumbnail({
+ const previewModel = updatePlaceholderThumbnail({
fileUrl: previewIcon.url,
video,
type: ThumbnailType.PREVIEW,
type ImageSize = { height?: number, width?: number }
-function createPlaylistMiniatureFromExisting (options: {
+function updatePlaylistMiniatureFromExisting (options: {
inputPath: string
playlist: MVideoPlaylistThumbnail
automaticallyGenerated: boolean
const type = ThumbnailType.MINIATURE
const thumbnailCreator = () => processImage(inputPath, outputPath, { width, height }, keepOriginal)
- return createThumbnailFromFunction({
+ return updateThumbnailFromFunction({
thumbnailCreator,
filename,
height,
})
}
-function createPlaylistMiniatureFromUrl (options: {
+function updatePlaylistMiniatureFromUrl (options: {
downloadUrl: string
playlist: MVideoPlaylistThumbnail
size?: ImageSize
: 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
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
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,
? () => processImage(ASSETS_PATH.DEFAULT_AUDIO_BACKGROUND, outputPath, { width, height }, true)
: () => generateImageFromVideoFile(input, basePath, filename, { height, width })
- return createThumbnailFromFunction({
+ return updateThumbnailFromFunction({
thumbnailCreator,
filename,
height,
})
}
-function createPlaceholderThumbnail (options: {
+function updatePlaceholderThumbnail (options: {
fileUrl: string
video: MVideoThumbnail
type: ThumbnailType
export {
generateVideoMiniature,
- createVideoMiniatureFromUrl,
- createVideoMiniatureFromExisting,
- createPlaceholderThumbnail,
- createPlaylistMiniatureFromUrl,
- createPlaylistMiniatureFromExisting
+ updateVideoMiniatureFromUrl,
+ updateVideoMiniatureFromExisting,
+ updatePlaceholderThumbnail,
+ updatePlaylistMiniatureFromUrl,
+ updatePlaylistMiniatureFromExisting
}
function hasThumbnailUrlChanged (existingThumbnail: MThumbnail, downloadUrl: string, video: MVideoUUID) {
return undefined
}
-async function createThumbnailFromFunction (parameters: {
+async function updateThumbnailFromFunction (parameters: {
thumbnailCreator: () => Promise<any>
filename: string
height: number
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 {
const fields = files?.[p.fieldName]
if (fields) {
- return createVideoMiniatureFromExisting({
+ return updateVideoMiniatureFromExisting({
inputPath: fields[0].path,
video,
type: p.type,