1 import { Account } from '@app/shared/shared-main/account/account.model'
2 import { VideoChannel } from '@app/shared/shared-main/video-channel/video-channel.model'
5 VideoDetails as VideoDetailsServerModel,
8 VideoStreamingPlaylist,
9 VideoStreamingPlaylistType
10 } from '@shared/models'
11 import { Video } from './video.model'
13 export class VideoDetails extends Video implements VideoDetailsServerModel {
14 descriptionPath: string
20 commentsEnabled: boolean
21 downloadEnabled: boolean
23 waitTranscoding: boolean
24 state: VideoConstant<VideoState>
27 dislikesPercent: number
31 streamingPlaylists: VideoStreamingPlaylist[]
33 constructor (hash: VideoDetailsServerModel, translations = {}) {
34 super(hash, translations)
36 this.descriptionPath = hash.descriptionPath
37 this.files = hash.files
38 this.channel = new VideoChannel(hash.channel)
39 this.account = new Account(hash.account)
41 this.support = hash.support
42 this.commentsEnabled = hash.commentsEnabled
43 this.downloadEnabled = hash.downloadEnabled
45 this.trackerUrls = hash.trackerUrls
46 this.streamingPlaylists = hash.streamingPlaylists
48 this.buildLikeAndDislikePercents()
51 buildLikeAndDislikePercents () {
52 this.likesPercent = (this.likes / (this.likes + this.dislikes)) * 100
53 this.dislikesPercent = (this.dislikes / (this.likes + this.dislikes)) * 100
57 return this.streamingPlaylists.find(p => p.type === VideoStreamingPlaylistType.HLS)
61 return !!this.getHlsPlaylist()
65 if (this.files.length !== 0) return this.files
67 const hls = this.getHlsPlaylist()
68 if (hls) return hls.files