diff options
author | Chocobozzz <me@florianbigard.com> | 2020-01-30 11:53:38 +0100 |
---|---|---|
committer | Chocobozzz <me@florianbigard.com> | 2020-01-30 11:53:38 +0100 |
commit | ca6d36227a9273f616a462d3aad6a721ab5dd627 (patch) | |
tree | a1610578e719ddb2c58199f06dd4eae436d25c0a /server/lib/files-cache/videos-preview-cache.ts | |
parent | 215304eaa06020f27152108567c6a9de16b220d3 (diff) | |
download | PeerTube-ca6d36227a9273f616a462d3aad6a721ab5dd627.tar.gz PeerTube-ca6d36227a9273f616a462d3aad6a721ab5dd627.tar.zst PeerTube-ca6d36227a9273f616a462d3aad6a721ab5dd627.zip |
Add url field in caption and use it for thumbnails
Diffstat (limited to 'server/lib/files-cache/videos-preview-cache.ts')
-rw-r--r-- | server/lib/files-cache/videos-preview-cache.ts | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/server/lib/files-cache/videos-preview-cache.ts b/server/lib/files-cache/videos-preview-cache.ts index 3da6bb138..7bfeb5783 100644 --- a/server/lib/files-cache/videos-preview-cache.ts +++ b/server/lib/files-cache/videos-preview-cache.ts | |||
@@ -2,8 +2,8 @@ import { join } from 'path' | |||
2 | import { FILES_CACHE, STATIC_PATHS } from '../../initializers/constants' | 2 | import { FILES_CACHE, STATIC_PATHS } from '../../initializers/constants' |
3 | import { VideoModel } from '../../models/video/video' | 3 | import { VideoModel } from '../../models/video/video' |
4 | import { AbstractVideoStaticFileCache } from './abstract-video-static-file-cache' | 4 | import { AbstractVideoStaticFileCache } from './abstract-video-static-file-cache' |
5 | import { CONFIG } from '../../initializers/config' | 5 | import { doRequestAndSaveToFile } from '@server/helpers/requests' |
6 | import { fetchRemoteVideoStaticFile } from '../activitypub' | 6 | import { buildRemoteVideoBaseUrl } from '@server/helpers/activitypub' |
7 | 7 | ||
8 | class VideosPreviewCache extends AbstractVideoStaticFileCache <string> { | 8 | class VideosPreviewCache extends AbstractVideoStaticFileCache <string> { |
9 | 9 | ||
@@ -32,11 +32,11 @@ class VideosPreviewCache extends AbstractVideoStaticFileCache <string> { | |||
32 | 32 | ||
33 | if (video.isOwned()) throw new Error('Cannot load remote preview of owned video.') | 33 | if (video.isOwned()) throw new Error('Cannot load remote preview of owned video.') |
34 | 34 | ||
35 | // FIXME: use URL | 35 | const preview = video.getPreview() |
36 | const remoteStaticPath = join(STATIC_PATHS.PREVIEWS, video.getPreview().filename) | 36 | const destPath = join(FILES_CACHE.PREVIEWS.DIRECTORY, preview.filename) |
37 | const destPath = join(FILES_CACHE.PREVIEWS.DIRECTORY, video.getPreview().filename) | ||
38 | 37 | ||
39 | await fetchRemoteVideoStaticFile(video, remoteStaticPath, destPath) | 38 | const remoteUrl = preview.getFileUrl(video) |
39 | await doRequestAndSaveToFile({ uri: remoteUrl }, destPath) | ||
40 | 40 | ||
41 | return { isOwned: false, path: destPath } | 41 | return { isOwned: false, path: destPath } |
42 | } | 42 | } |