aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models/video
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2023-06-07 08:53:14 +0200
committerChocobozzz <me@florianbigard.com>2023-06-29 10:19:33 +0200
commitbafaba0bcda0c9fb553b9eebef3764994bb4ff60 (patch)
treebff9a580cda865cd81c91cd5e1b7b527df45dac1 /server/models/video
parentf162d32da098aa55f6de2367142faa166edb7c08 (diff)
downloadPeerTube-bafaba0bcda0c9fb553b9eebef3764994bb4ff60.tar.gz
PeerTube-bafaba0bcda0c9fb553b9eebef3764994bb4ff60.tar.zst
PeerTube-bafaba0bcda0c9fb553b9eebef3764994bb4ff60.zip
Support lazy download of remote video miniatures
Diffstat (limited to 'server/models/video')
-rw-r--r--server/models/video/thumbnail.ts8
-rw-r--r--server/models/video/video-playlist.ts6
2 files changed, 9 insertions, 5 deletions
diff --git a/server/models/video/thumbnail.ts b/server/models/video/thumbnail.ts
index 2a1f6a7b4..1722acdb4 100644
--- a/server/models/video/thumbnail.ts
+++ b/server/models/video/thumbnail.ts
@@ -21,7 +21,7 @@ import { AttributesOnly } from '@shared/typescript-utils'
21import { ThumbnailType } from '../../../shared/models/videos/thumbnail.type' 21import { ThumbnailType } from '../../../shared/models/videos/thumbnail.type'
22import { logger } from '../../helpers/logger' 22import { logger } from '../../helpers/logger'
23import { CONFIG } from '../../initializers/config' 23import { CONFIG } from '../../initializers/config'
24import { CONSTRAINTS_FIELDS, LAZY_STATIC_PATHS, STATIC_PATHS, WEBSERVER } from '../../initializers/constants' 24import { CONSTRAINTS_FIELDS, LAZY_STATIC_PATHS, WEBSERVER } from '../../initializers/constants'
25import { VideoModel } from './video' 25import { VideoModel } from './video'
26import { VideoPlaylistModel } from './video-playlist' 26import { VideoPlaylistModel } from './video-playlist'
27 27
@@ -110,7 +110,7 @@ export class ThumbnailModel extends Model<Partial<AttributesOnly<ThumbnailModel>
110 [ThumbnailType.MINIATURE]: { 110 [ThumbnailType.MINIATURE]: {
111 label: 'miniature', 111 label: 'miniature',
112 directory: CONFIG.STORAGE.THUMBNAILS_DIR, 112 directory: CONFIG.STORAGE.THUMBNAILS_DIR,
113 staticPath: STATIC_PATHS.THUMBNAILS 113 staticPath: LAZY_STATIC_PATHS.THUMBNAILS
114 }, 114 },
115 [ThumbnailType.PREVIEW]: { 115 [ThumbnailType.PREVIEW]: {
116 label: 'preview', 116 label: 'preview',
@@ -201,4 +201,8 @@ export class ThumbnailModel extends Model<Partial<AttributesOnly<ThumbnailModel>
201 201
202 this.previousThumbnailFilename = undefined 202 this.previousThumbnailFilename = undefined
203 } 203 }
204
205 isOwned () {
206 return !this.fileUrl
207 }
204} 208}
diff --git a/server/models/video/video-playlist.ts b/server/models/video/video-playlist.ts
index faf4bea78..15999d409 100644
--- a/server/models/video/video-playlist.ts
+++ b/server/models/video/video-playlist.ts
@@ -32,7 +32,7 @@ import {
32import { 32import {
33 ACTIVITY_PUB, 33 ACTIVITY_PUB,
34 CONSTRAINTS_FIELDS, 34 CONSTRAINTS_FIELDS,
35 STATIC_PATHS, 35 LAZY_STATIC_PATHS,
36 THUMBNAILS_SIZE, 36 THUMBNAILS_SIZE,
37 VIDEO_PLAYLIST_PRIVACIES, 37 VIDEO_PLAYLIST_PRIVACIES,
38 VIDEO_PLAYLIST_TYPES, 38 VIDEO_PLAYLIST_TYPES,
@@ -592,13 +592,13 @@ export class VideoPlaylistModel extends Model<Partial<AttributesOnly<VideoPlayli
592 getThumbnailUrl () { 592 getThumbnailUrl () {
593 if (!this.hasThumbnail()) return null 593 if (!this.hasThumbnail()) return null
594 594
595 return WEBSERVER.URL + STATIC_PATHS.THUMBNAILS + this.Thumbnail.filename 595 return WEBSERVER.URL + LAZY_STATIC_PATHS.THUMBNAILS + this.Thumbnail.filename
596 } 596 }
597 597
598 getThumbnailStaticPath () { 598 getThumbnailStaticPath () {
599 if (!this.hasThumbnail()) return null 599 if (!this.hasThumbnail()) return null
600 600
601 return join(STATIC_PATHS.THUMBNAILS, this.Thumbnail.filename) 601 return join(LAZY_STATIC_PATHS.THUMBNAILS, this.Thumbnail.filename)
602 } 602 }
603 603
604 getWatchStaticPath () { 604 getWatchStaticPath () {