aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models
diff options
context:
space:
mode:
Diffstat (limited to 'server/models')
-rw-r--r--server/models/video/formatter/video-format-utils.ts3
-rw-r--r--server/models/video/video-file.ts8
-rw-r--r--server/models/video/video-job-info.ts2
-rw-r--r--server/models/video/video-streaming-playlist.ts4
-rw-r--r--server/models/video/video.ts9
5 files changed, 17 insertions, 9 deletions
diff --git a/server/models/video/formatter/video-format-utils.ts b/server/models/video/formatter/video-format-utils.ts
index 461e296df..fd4da68ed 100644
--- a/server/models/video/formatter/video-format-utils.ts
+++ b/server/models/video/formatter/video-format-utils.ts
@@ -2,8 +2,7 @@ import { uuidToShort } from '@server/helpers/uuid'
2import { generateMagnetUri } from '@server/helpers/webtorrent' 2import { generateMagnetUri } from '@server/helpers/webtorrent'
3import { getLocalVideoFileMetadataUrl } from '@server/lib/video-urls' 3import { getLocalVideoFileMetadataUrl } from '@server/lib/video-urls'
4import { VideoViews } from '@server/lib/video-views' 4import { VideoViews } from '@server/lib/video-views'
5import { VideosCommonQueryAfterSanitize } from '@shared/models' 5import { VideoFile, VideosCommonQueryAfterSanitize } from '@shared/models'
6import { VideoFile } from '@shared/models/videos/video-file.model'
7import { ActivityTagObject, ActivityUrlObject, VideoObject } from '../../../../shared/models/activitypub/objects' 6import { ActivityTagObject, ActivityUrlObject, VideoObject } from '../../../../shared/models/activitypub/objects'
8import { Video, VideoDetails, VideoInclude } from '../../../../shared/models/videos' 7import { Video, VideoDetails, VideoInclude } from '../../../../shared/models/videos'
9import { VideoStreamingPlaylist } from '../../../../shared/models/videos/video-streaming-playlist.model' 8import { VideoStreamingPlaylist } from '../../../../shared/models/videos/video-streaming-playlist.model'
diff --git a/server/models/video/video-file.ts b/server/models/video/video-file.ts
index 106f9602b..87311c0ed 100644
--- a/server/models/video/video-file.ts
+++ b/server/models/video/video-file.ts
@@ -25,7 +25,7 @@ import { logger } from '@server/helpers/logger'
25import { extractVideo } from '@server/helpers/video' 25import { extractVideo } from '@server/helpers/video'
26import { getHLSPublicFileUrl, getWebTorrentPublicFileUrl } from '@server/lib/object-storage' 26import { getHLSPublicFileUrl, getWebTorrentPublicFileUrl } from '@server/lib/object-storage'
27import { getFSTorrentFilePath } from '@server/lib/paths' 27import { getFSTorrentFilePath } from '@server/lib/paths'
28import { MStreamingPlaylistVideo, MVideo, MVideoWithHost } from '@server/types/models' 28import { isStreamingPlaylist, MStreamingPlaylistVideo, MVideo, MVideoWithHost } from '@server/types/models'
29import { AttributesOnly } from '@shared/core-utils' 29import { AttributesOnly } from '@shared/core-utils'
30import { VideoStorage } from '@shared/models' 30import { VideoStorage } from '@shared/models'
31import { 31import {
@@ -536,4 +536,10 @@ export class VideoFileModel extends Model<Partial<AttributesOnly<VideoFileModel>
536 (this.videoStreamingPlaylistId !== null && this.videoStreamingPlaylistId === other.videoStreamingPlaylistId) 536 (this.videoStreamingPlaylistId !== null && this.videoStreamingPlaylistId === other.videoStreamingPlaylistId)
537 ) 537 )
538 } 538 }
539
540 withVideoOrPlaylist (videoOrPlaylist: MVideo | MStreamingPlaylistVideo) {
541 if (isStreamingPlaylist(videoOrPlaylist)) return Object.assign(this, { VideoStreamingPlaylist: videoOrPlaylist })
542
543 return Object.assign(this, { Video: videoOrPlaylist })
544 }
539} 545}
diff --git a/server/models/video/video-job-info.ts b/server/models/video/video-job-info.ts
index 7c1fe6734..cb1f3f2f0 100644
--- a/server/models/video/video-job-info.ts
+++ b/server/models/video/video-job-info.ts
@@ -49,7 +49,7 @@ export class VideoJobInfoModel extends Model<Partial<AttributesOnly<VideoJobInfo
49 }) 49 })
50 Video: VideoModel 50 Video: VideoModel
51 51
52 static load (videoId: number, transaction: Transaction) { 52 static load (videoId: number, transaction?: Transaction) {
53 const where = { 53 const where = {
54 videoId 54 videoId
55 } 55 }
diff --git a/server/models/video/video-streaming-playlist.ts b/server/models/video/video-streaming-playlist.ts
index 18d96c750..4643c5452 100644
--- a/server/models/video/video-streaming-playlist.ts
+++ b/server/models/video/video-streaming-playlist.ts
@@ -239,6 +239,10 @@ export class VideoStreamingPlaylistModel extends Model<Partial<AttributesOnly<Vi
239 this.videoId === other.videoId 239 this.videoId === other.videoId
240 } 240 }
241 241
242 withVideo (video: MVideo) {
243 return Object.assign(this, { Video: video })
244 }
245
242 private getMasterPlaylistStaticPath (videoUUID: string) { 246 private getMasterPlaylistStaticPath (videoUUID: string) {
243 return join(STATIC_PATHS.STREAMING_PLAYLISTS.HLS, videoUUID, this.playlistFilename) 247 return join(STATIC_PATHS.STREAMING_PLAYLISTS.HLS, videoUUID, this.playlistFilename)
244 } 248 }
diff --git a/server/models/video/video.ts b/server/models/video/video.ts
index 6eeb6b312..c49df1d5e 100644
--- a/server/models/video/video.ts
+++ b/server/models/video/video.ts
@@ -33,9 +33,8 @@ import { getHLSDirectory, getHLSRedundancyDirectory } from '@server/lib/paths'
33import { VideoPathManager } from '@server/lib/video-path-manager' 33import { VideoPathManager } from '@server/lib/video-path-manager'
34import { getServerActor } from '@server/models/application/application' 34import { getServerActor } from '@server/models/application/application'
35import { ModelCache } from '@server/models/model-cache' 35import { ModelCache } from '@server/models/model-cache'
36import { AttributesOnly, buildVideoEmbedPath, buildVideoWatchPath, pick } from '@shared/core-utils' 36import { AttributesOnly, buildVideoEmbedPath, buildVideoWatchPath, isThisWeek, pick } from '@shared/core-utils'
37import { VideoInclude } from '@shared/models' 37import { VideoFile, VideoInclude } from '@shared/models'
38import { VideoFile } from '@shared/models/videos/video-file.model'
39import { ResultList, UserRight, VideoPrivacy, VideoState } from '../../../shared' 38import { ResultList, UserRight, VideoPrivacy, VideoState } from '../../../shared'
40import { VideoObject } from '../../../shared/models/activitypub/objects' 39import { VideoObject } from '../../../shared/models/activitypub/objects'
41import { Video, VideoDetails, VideoRateType, VideoStorage } from '../../../shared/models/videos' 40import { Video, VideoDetails, VideoRateType, VideoStorage } from '../../../shared/models/videos'
@@ -1673,7 +1672,7 @@ export class VideoModel extends Model<Partial<AttributesOnly<VideoModel>>> {
1673 const file = this.getMaxQualityFile() 1672 const file = this.getMaxQualityFile()
1674 const videoOrPlaylist = file.getVideoOrStreamingPlaylist() 1673 const videoOrPlaylist = file.getVideoOrStreamingPlaylist()
1675 1674
1676 return VideoPathManager.Instance.makeAvailableVideoFile(videoOrPlaylist, file, originalFilePath => { 1675 return VideoPathManager.Instance.makeAvailableVideoFile(file.withVideoOrPlaylist(videoOrPlaylist), originalFilePath => {
1677 return getVideoFileResolution(originalFilePath) 1676 return getVideoFileResolution(originalFilePath)
1678 }) 1677 })
1679 } 1678 }
@@ -1742,7 +1741,7 @@ export class VideoModel extends Model<Partial<AttributesOnly<VideoModel>>> {
1742 ) 1741 )
1743 1742
1744 if (streamingPlaylist.storage === VideoStorage.OBJECT_STORAGE) { 1743 if (streamingPlaylist.storage === VideoStorage.OBJECT_STORAGE) {
1745 await removeHLSObjectStorage(streamingPlaylist, this) 1744 await removeHLSObjectStorage(streamingPlaylist.withVideo(this))
1746 } 1745 }
1747 } 1746 }
1748 } 1747 }