]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blobdiff - client/src/app/shared/shared-main/video/video.model.ts
Don't manage remote video files
[github/Chocobozzz/PeerTube.git] / client / src / app / shared / shared-main / video / video.model.ts
index b11316471fe0772d3e05edcbfebfdea712c294ca..fe56436889fedd1f91907bcf14107e5e95cb1ffd 100644 (file)
@@ -14,7 +14,8 @@ import {
   VideoPrivacy,
   VideoScheduleUpdate,
   VideoState,
-  VideoStreamingPlaylist
+  VideoStreamingPlaylist,
+  VideoStreamingPlaylistType
 } from '@shared/models'
 
 export class Video implements VideoServerModel {
@@ -57,6 +58,9 @@ export class Video implements VideoServerModel {
   url: string
 
   views: number
+  // If live
+  viewers?: number
+
   likes: number
   dislikes: number
   nsfw: boolean
@@ -150,6 +154,7 @@ export class Video implements VideoServerModel {
     this.url = hash.url
 
     this.views = hash.views
+    this.viewers = hash.viewers
     this.likes = hash.likes
     this.dislikes = hash.dislikes
 
@@ -215,6 +220,28 @@ export class Video implements VideoServerModel {
     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))