aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/models/video/video.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2023-07-11 09:21:13 +0200
committerChocobozzz <me@florianbigard.com>2023-07-11 09:21:13 +0200
commit784e2ad5c34bcfef36a3f69e9e9acd7cbb3d6428 (patch)
tree29c46cfd6344065eb805680ed080cb05592ee1d4 /server/models/video/video.ts
parentc3030e944ad03c7fd7b5d668a2d88ff03e4cdf19 (diff)
downloadPeerTube-784e2ad5c34bcfef36a3f69e9e9acd7cbb3d6428.tar.gz
PeerTube-784e2ad5c34bcfef36a3f69e9e9acd7cbb3d6428.tar.zst
PeerTube-784e2ad5c34bcfef36a3f69e9e9acd7cbb3d6428.zip
Prefer web videos in favour of webtorrent
Diffstat (limited to 'server/models/video/video.ts')
-rw-r--r--server/models/video/video.ts27
1 files changed, 17 insertions, 10 deletions
diff --git a/server/models/video/video.ts b/server/models/video/video.ts
index 3a0d95b62..4c6297243 100644
--- a/server/models/video/video.ts
+++ b/server/models/video/video.ts
@@ -29,7 +29,7 @@ import {
29import { getPrivaciesForFederation, isPrivacyForFederation, isStateForFederation } from '@server/helpers/video' 29import { getPrivaciesForFederation, isPrivacyForFederation, isStateForFederation } from '@server/helpers/video'
30import { InternalEventEmitter } from '@server/lib/internal-event-emitter' 30import { InternalEventEmitter } from '@server/lib/internal-event-emitter'
31import { LiveManager } from '@server/lib/live/live-manager' 31import { LiveManager } from '@server/lib/live/live-manager'
32import { removeHLSFileObjectStorageByFilename, removeHLSObjectStorage, removeWebTorrentObjectStorage } from '@server/lib/object-storage' 32import { removeHLSFileObjectStorageByFilename, removeHLSObjectStorage, removeWebVideoObjectStorage } from '@server/lib/object-storage'
33import { tracer } from '@server/lib/opentelemetry/tracing' 33import { tracer } from '@server/lib/opentelemetry/tracing'
34import { getHLSDirectory, getHLSRedundancyDirectory, getHlsResolutionPlaylistFilename } from '@server/lib/paths' 34import { getHLSDirectory, getHLSRedundancyDirectory, getHlsResolutionPlaylistFilename } from '@server/lib/paths'
35import { Hooks } from '@server/lib/plugins/hooks' 35import { Hooks } from '@server/lib/plugins/hooks'
@@ -151,7 +151,7 @@ export enum ScopeNames {
151 FOR_API = 'FOR_API', 151 FOR_API = 'FOR_API',
152 WITH_ACCOUNT_DETAILS = 'WITH_ACCOUNT_DETAILS', 152 WITH_ACCOUNT_DETAILS = 'WITH_ACCOUNT_DETAILS',
153 WITH_TAGS = 'WITH_TAGS', 153 WITH_TAGS = 'WITH_TAGS',
154 WITH_WEBTORRENT_FILES = 'WITH_WEBTORRENT_FILES', 154 WITH_WEB_VIDEO_FILES = 'WITH_WEB_VIDEO_FILES',
155 WITH_SCHEDULED_UPDATE = 'WITH_SCHEDULED_UPDATE', 155 WITH_SCHEDULED_UPDATE = 'WITH_SCHEDULED_UPDATE',
156 WITH_BLACKLISTED = 'WITH_BLACKLISTED', 156 WITH_BLACKLISTED = 'WITH_BLACKLISTED',
157 WITH_STREAMING_PLAYLISTS = 'WITH_STREAMING_PLAYLISTS', 157 WITH_STREAMING_PLAYLISTS = 'WITH_STREAMING_PLAYLISTS',
@@ -290,7 +290,7 @@ export type ForAPIOptions = {
290 } 290 }
291 ] 291 ]
292 }, 292 },
293 [ScopeNames.WITH_WEBTORRENT_FILES]: (withRedundancies = false) => { 293 [ScopeNames.WITH_WEB_VIDEO_FILES]: (withRedundancies = false) => {
294 let subInclude: any[] = [] 294 let subInclude: any[] = []
295 295
296 if (withRedundancies === true) { 296 if (withRedundancies === true) {
@@ -813,7 +813,7 @@ export class VideoModel extends Model<Partial<AttributesOnly<VideoModel>>> {
813 813
814 // Remove physical files and torrents 814 // Remove physical files and torrents
815 instance.VideoFiles.forEach(file => { 815 instance.VideoFiles.forEach(file => {
816 tasks.push(instance.removeWebTorrentFile(file)) 816 tasks.push(instance.removeWebVideoFile(file))
817 }) 817 })
818 818
819 // Remove playlists file 819 // Remove playlists file
@@ -1107,7 +1107,10 @@ export class VideoModel extends Model<Partial<AttributesOnly<VideoModel>>> {
1107 include?: VideoInclude 1107 include?: VideoInclude
1108 1108
1109 hasFiles?: boolean // default false 1109 hasFiles?: boolean // default false
1110 hasWebtorrentFiles?: boolean 1110
1111 hasWebtorrentFiles?: boolean // TODO: remove in v7
1112 hasWebVideoFiles?: boolean
1113
1111 hasHLSFiles?: boolean 1114 hasHLSFiles?: boolean
1112 1115
1113 categoryOneOf?: number[] 1116 categoryOneOf?: number[]
@@ -1172,6 +1175,7 @@ export class VideoModel extends Model<Partial<AttributesOnly<VideoModel>>> {
1172 'historyOfUser', 1175 'historyOfUser',
1173 'hasHLSFiles', 1176 'hasHLSFiles',
1174 'hasWebtorrentFiles', 1177 'hasWebtorrentFiles',
1178 'hasWebVideoFiles',
1175 'search', 1179 'search',
1176 'excludeAlreadyWatched' 1180 'excludeAlreadyWatched'
1177 ]), 1181 ]),
@@ -1205,7 +1209,9 @@ export class VideoModel extends Model<Partial<AttributesOnly<VideoModel>>> {
1205 1209
1206 user?: MUserAccountId 1210 user?: MUserAccountId
1207 1211
1208 hasWebtorrentFiles?: boolean 1212 hasWebtorrentFiles?: boolean // TODO: remove in v7
1213 hasWebVideoFiles?: boolean
1214
1209 hasHLSFiles?: boolean 1215 hasHLSFiles?: boolean
1210 1216
1211 search?: string 1217 search?: string
@@ -1252,6 +1258,7 @@ export class VideoModel extends Model<Partial<AttributesOnly<VideoModel>>> {
1252 'durationMax', 1258 'durationMax',
1253 'hasHLSFiles', 1259 'hasHLSFiles',
1254 'hasWebtorrentFiles', 1260 'hasWebtorrentFiles',
1261 'hasWebVideoFiles',
1255 'uuids', 1262 'uuids',
1256 'search', 1263 'search',
1257 'displayOnlyForFollower', 1264 'displayOnlyForFollower',
@@ -1676,7 +1683,7 @@ export class VideoModel extends Model<Partial<AttributesOnly<VideoModel>>> {
1676 return this.getQualityFileBy(minBy) 1683 return this.getQualityFileBy(minBy)
1677 } 1684 }
1678 1685
1679 getWebTorrentFile<T extends MVideoWithFile> (this: T, resolution: number): MVideoFileVideo { 1686 getWebVideoFile<T extends MVideoWithFile> (this: T, resolution: number): MVideoFileVideo {
1680 if (Array.isArray(this.VideoFiles) === false) return undefined 1687 if (Array.isArray(this.VideoFiles) === false) return undefined
1681 1688
1682 const file = this.VideoFiles.find(f => f.resolution === resolution) 1689 const file = this.VideoFiles.find(f => f.resolution === resolution)
@@ -1685,7 +1692,7 @@ export class VideoModel extends Model<Partial<AttributesOnly<VideoModel>>> {
1685 return Object.assign(file, { Video: this }) 1692 return Object.assign(file, { Video: this })
1686 } 1693 }
1687 1694
1688 hasWebTorrentFiles () { 1695 hasWebVideoFiles () {
1689 return Array.isArray(this.VideoFiles) === true && this.VideoFiles.length !== 0 1696 return Array.isArray(this.VideoFiles) === true && this.VideoFiles.length !== 0
1690 } 1697 }
1691 1698
@@ -1884,7 +1891,7 @@ export class VideoModel extends Model<Partial<AttributesOnly<VideoModel>>> {
1884 .concat(toAdd) 1891 .concat(toAdd)
1885 } 1892 }
1886 1893
1887 removeWebTorrentFile (videoFile: MVideoFile, isRedundancy = false) { 1894 removeWebVideoFile (videoFile: MVideoFile, isRedundancy = false) {
1888 const filePath = isRedundancy 1895 const filePath = isRedundancy
1889 ? VideoPathManager.Instance.getFSRedundancyVideoFilePath(this, videoFile) 1896 ? VideoPathManager.Instance.getFSRedundancyVideoFilePath(this, videoFile)
1890 : VideoPathManager.Instance.getFSVideoFileOutputPath(this, videoFile) 1897 : VideoPathManager.Instance.getFSVideoFileOutputPath(this, videoFile)
@@ -1893,7 +1900,7 @@ export class VideoModel extends Model<Partial<AttributesOnly<VideoModel>>> {
1893 if (!isRedundancy) promises.push(videoFile.removeTorrent()) 1900 if (!isRedundancy) promises.push(videoFile.removeTorrent())
1894 1901
1895 if (videoFile.storage === VideoStorage.OBJECT_STORAGE) { 1902 if (videoFile.storage === VideoStorage.OBJECT_STORAGE) {
1896 promises.push(removeWebTorrentObjectStorage(videoFile)) 1903 promises.push(removeWebVideoObjectStorage(videoFile))
1897 } 1904 }
1898 1905
1899 return Promise.all(promises) 1906 return Promise.all(promises)