createThumbnail -> updateThumbnail
This commit is contained in:
parent
1333ab1f2d
commit
91f8f8db97
|
@ -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,
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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,
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in New Issue