diff options
Diffstat (limited to 'server/models')
-rw-r--r-- | server/models/video/formatter/video-format-utils.ts | 3 | ||||
-rw-r--r-- | server/models/video/video-file.ts | 8 | ||||
-rw-r--r-- | server/models/video/video-job-info.ts | 2 | ||||
-rw-r--r-- | server/models/video/video-streaming-playlist.ts | 4 | ||||
-rw-r--r-- | server/models/video/video.ts | 9 |
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' | |||
2 | import { generateMagnetUri } from '@server/helpers/webtorrent' | 2 | import { generateMagnetUri } from '@server/helpers/webtorrent' |
3 | import { getLocalVideoFileMetadataUrl } from '@server/lib/video-urls' | 3 | import { getLocalVideoFileMetadataUrl } from '@server/lib/video-urls' |
4 | import { VideoViews } from '@server/lib/video-views' | 4 | import { VideoViews } from '@server/lib/video-views' |
5 | import { VideosCommonQueryAfterSanitize } from '@shared/models' | 5 | import { VideoFile, VideosCommonQueryAfterSanitize } from '@shared/models' |
6 | import { VideoFile } from '@shared/models/videos/video-file.model' | ||
7 | import { ActivityTagObject, ActivityUrlObject, VideoObject } from '../../../../shared/models/activitypub/objects' | 6 | import { ActivityTagObject, ActivityUrlObject, VideoObject } from '../../../../shared/models/activitypub/objects' |
8 | import { Video, VideoDetails, VideoInclude } from '../../../../shared/models/videos' | 7 | import { Video, VideoDetails, VideoInclude } from '../../../../shared/models/videos' |
9 | import { VideoStreamingPlaylist } from '../../../../shared/models/videos/video-streaming-playlist.model' | 8 | import { 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' | |||
25 | import { extractVideo } from '@server/helpers/video' | 25 | import { extractVideo } from '@server/helpers/video' |
26 | import { getHLSPublicFileUrl, getWebTorrentPublicFileUrl } from '@server/lib/object-storage' | 26 | import { getHLSPublicFileUrl, getWebTorrentPublicFileUrl } from '@server/lib/object-storage' |
27 | import { getFSTorrentFilePath } from '@server/lib/paths' | 27 | import { getFSTorrentFilePath } from '@server/lib/paths' |
28 | import { MStreamingPlaylistVideo, MVideo, MVideoWithHost } from '@server/types/models' | 28 | import { isStreamingPlaylist, MStreamingPlaylistVideo, MVideo, MVideoWithHost } from '@server/types/models' |
29 | import { AttributesOnly } from '@shared/core-utils' | 29 | import { AttributesOnly } from '@shared/core-utils' |
30 | import { VideoStorage } from '@shared/models' | 30 | import { VideoStorage } from '@shared/models' |
31 | import { | 31 | import { |
@@ -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' | |||
33 | import { VideoPathManager } from '@server/lib/video-path-manager' | 33 | import { VideoPathManager } from '@server/lib/video-path-manager' |
34 | import { getServerActor } from '@server/models/application/application' | 34 | import { getServerActor } from '@server/models/application/application' |
35 | import { ModelCache } from '@server/models/model-cache' | 35 | import { ModelCache } from '@server/models/model-cache' |
36 | import { AttributesOnly, buildVideoEmbedPath, buildVideoWatchPath, pick } from '@shared/core-utils' | 36 | import { AttributesOnly, buildVideoEmbedPath, buildVideoWatchPath, isThisWeek, pick } from '@shared/core-utils' |
37 | import { VideoInclude } from '@shared/models' | 37 | import { VideoFile, VideoInclude } from '@shared/models' |
38 | import { VideoFile } from '@shared/models/videos/video-file.model' | ||
39 | import { ResultList, UserRight, VideoPrivacy, VideoState } from '../../../shared' | 38 | import { ResultList, UserRight, VideoPrivacy, VideoState } from '../../../shared' |
40 | import { VideoObject } from '../../../shared/models/activitypub/objects' | 39 | import { VideoObject } from '../../../shared/models/activitypub/objects' |
41 | import { Video, VideoDetails, VideoRateType, VideoStorage } from '../../../shared/models/videos' | 40 | import { 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 | } |