-function createVideoThumbnailFromUrl (url: string, video: VideoModel, type: ThumbnailType, size?: ImageSize) {
- const { filename, basePath, height, width, existingThumbnail } = buildMetadataFromVideo(video, type, size)
- const thumbnailCreator = () => downloadImage(url, basePath, filename, { width, height })
+function updateVideoMiniatureFromUrl (options: {
+ downloadUrl: string
+ video: MVideoThumbnail
+ type: ThumbnailType
+ size?: ImageSize
+}) {
+ const { downloadUrl, video, type, size } = options
+ const { filename: updatedFilename, basePath, height, width, existingThumbnail } = buildMetadataFromVideo(video, type, size)
+
+ // Only save the file URL if it is a remote video
+ const fileUrl = video.isOwned()
+ ? null
+ : downloadUrl
+
+ const thumbnailUrlChanged = hasThumbnailUrlChanged(existingThumbnail, downloadUrl, video)
+
+ // Do not change the thumbnail filename if the file did not change
+ const filename = thumbnailUrlChanged
+ ? updatedFilename
+ : existingThumbnail.filename