1
0
Fork 0
mirror of https://github.com/Chocobozzz/PeerTube.git synced 2025-10-05 19:42:24 +02:00

Generate a name for thumbnails

Allows aggressive caching
This commit is contained in:
Chocobozzz 2021-02-12 16:23:19 +01:00 committed by Chocobozzz
parent 0472d474fd
commit a8b1b40485
11 changed files with 116 additions and 55 deletions

View file

@ -27,18 +27,28 @@ function createPlaylistMiniatureFromExisting (
return createThumbnailFromFunction({ thumbnailCreator, filename, height, width, type, automaticallyGenerated, existingThumbnail })
}
function createPlaylistMiniatureFromUrl (fileUrl: string, playlist: MVideoPlaylistThumbnail, size?: ImageSize) {
function createPlaylistMiniatureFromUrl (downloadUrl: string, playlist: MVideoPlaylistThumbnail, size?: ImageSize) {
const { filename, basePath, height, width, existingThumbnail } = buildMetadataFromPlaylist(playlist, size)
const type = ThumbnailType.MINIATURE
const thumbnailCreator = () => downloadImage(fileUrl, basePath, filename, { width, height })
// Only save the file URL if it is a remote playlist
const fileUrl = playlist.isOwned()
? null
: downloadUrl
const thumbnailCreator = () => downloadImage(downloadUrl, basePath, filename, { width, height })
return createThumbnailFromFunction({ thumbnailCreator, filename, height, width, type, existingThumbnail, fileUrl })
}
function createVideoMiniatureFromUrl (fileUrl: string, video: MVideoThumbnail, type: ThumbnailType, size?: ImageSize) {
function createVideoMiniatureFromUrl (downloadUrl: string, video: MVideoThumbnail, type: ThumbnailType, size?: ImageSize) {
const { filename, basePath, height, width, existingThumbnail } = buildMetadataFromVideo(video, type, size)
const thumbnailCreator = () => downloadImage(fileUrl, basePath, filename, { width, height })
// Only save the file URL if it is a remote video
const fileUrl = video.isOwned()
? null
: downloadUrl
const thumbnailCreator = () => downloadImage(downloadUrl, basePath, filename, { width, height })
return createThumbnailFromFunction({ thumbnailCreator, filename, height, width, type, existingThumbnail, fileUrl })
}