X-Git-Url: https://git.immae.eu/?a=blobdiff_plain;f=server%2Fcontrollers%2Fapi%2Fvideo-playlist.ts;h=375d711fdcde9f1e04998a7a2cba547ead17437e;hb=b763f88dd0f455ce0ccae9cb81182c985a47c101;hp=b51490bf914f599c301c1796dfc89f3e25938158;hpb=818c449b3c34e9f324ac744120c8774e724ab25e;p=github%2FChocobozzz%2FPeerTube.git diff --git a/server/controllers/api/video-playlist.ts b/server/controllers/api/video-playlist.ts index b51490bf9..375d711fd 100644 --- a/server/controllers/api/video-playlist.ts +++ b/server/controllers/api/video-playlist.ts @@ -1,5 +1,5 @@ import * as express from 'express' -import { getFormattedObjects, getServerActor } from '../../helpers/utils' +import { getFormattedObjects } from '../../helpers/utils' import { asyncMiddleware, asyncRetryTransactionMiddleware, @@ -41,6 +41,7 @@ import { CONFIG } from '../../initializers/config' import { sequelizeTypescript } from '../../initializers/database' import { createPlaylistMiniatureFromExisting } from '../../lib/thumbnail' import { MVideoPlaylistFull, MVideoPlaylistThumbnail, MVideoThumbnail } from '@server/typings/models' +import { getServerActor } from '@server/models/application/application' const reqThumbnailFile = createReqFiles([ 'thumbnailfile' ], MIMETYPES.IMAGE.MIMETYPE_EXT, { thumbnailfile: CONFIG.STORAGE.TMP_DIR }) @@ -463,7 +464,13 @@ async function regeneratePlaylistThumbnail (videoPlaylist: MVideoPlaylistThumbna async function generateThumbnailForPlaylist (videoPlaylist: MVideoPlaylistThumbnail, video: MVideoThumbnail) { logger.info('Generating default thumbnail to playlist %s.', videoPlaylist.url) - const inputPath = join(CONFIG.STORAGE.THUMBNAILS_DIR, video.getMiniature().filename) + const videoMiniature = video.getMiniature() + if (!videoMiniature) { + logger.info('Cannot generate thumbnail for playlist %s because video %s does not have any.', videoPlaylist.url, video.url) + return + } + + const inputPath = join(CONFIG.STORAGE.THUMBNAILS_DIR, videoMiniature.filename) const thumbnailModel = await createPlaylistMiniatureFromExisting(inputPath, videoPlaylist, true, true) thumbnailModel.videoPlaylistId = videoPlaylist.id