UserRight,
Video as VideoServerModel,
VideoConstant,
+ VideoFile,
VideoPrivacy,
VideoScheduleUpdate,
- VideoState
+ VideoState,
+ VideoStreamingPlaylist,
+ VideoStreamingPlaylistType
} from '@shared/models'
export class Video implements VideoServerModel {
url: string
views: number
+ // If live
+ viewers?: number
+
likes: number
dislikes: number
nsfw: boolean
pluginData?: any
+ streamingPlaylists?: VideoStreamingPlaylist[]
+ files?: VideoFile[]
+
static buildWatchUrl (video: Partial<Pick<Video, 'uuid' | 'shortUUID'>>) {
return buildVideoWatchPath({ shortUUID: video.shortUUID || video.uuid })
}
this.url = hash.url
this.views = hash.views
+ this.viewers = hash.viewers
this.likes = hash.likes
this.dislikes = hash.dislikes
this.blockedOwner = hash.blockedOwner
this.blockedServer = hash.blockedServer
+ this.streamingPlaylists = hash.streamingPlaylists
+ this.files = hash.files
+
this.userHistory = hash.userHistory
this.originInstanceHost = this.account.host
return user && this.isLocal === true && (this.account.name === user.username || user.hasRight(UserRight.UPDATE_ANY_VIDEO))
}
+ canRemoveFiles (user: AuthUser) {
+ return this.isLocal &&
+ user.hasRight(UserRight.MANAGE_VIDEO_FILES) &&
+ this.state.id !== VideoState.TO_TRANSCODE &&
+ this.hasHLS() &&
+ this.hasWebTorrent()
+ }
+
+ canRunTranscoding (user: AuthUser) {
+ return this.isLocal &&
+ user.hasRight(UserRight.RUN_VIDEO_TRANSCODING) &&
+ this.state.id !== VideoState.TO_TRANSCODE
+ }
+
+ hasHLS () {
+ return this.streamingPlaylists?.some(p => p.type === VideoStreamingPlaylistType.HLS)
+ }
+
+ hasWebTorrent () {
+ return this.files && this.files.length !== 0
+ }
+
isLiveInfoAvailableBy (user: AuthUser) {
return this.isLive &&
user && this.isLocal === true && (this.account.name === user.username || user.hasRight(UserRight.GET_ANY_LIVE))