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
19 commentsEnabled: boolean
20 downloadEnabled: boolean
22 waitTranscoding: boolean
23 state: VideoConstant<VideoState>
26 dislikesPercent: number
31 streamingPlaylists: VideoStreamingPlaylist[]
33 constructor (hash: VideoDetailsServerModel, translations = {}) {
34 super(hash, translations)
36 this.descriptionPath = hash.descriptionPath
37 this.channel = new VideoChannel(hash.channel)
38 this.account = new Account(hash.account)
40 this.support = hash.support
41 this.commentsEnabled = hash.commentsEnabled
42 this.downloadEnabled = hash.downloadEnabled
44 this.trackerUrls = hash.trackerUrls
46 this.buildLikeAndDislikePercents()
49 buildLikeAndDislikePercents () {
50 this.likesPercent = (this.likes / (this.likes + this.dislikes)) * 100
51 this.dislikesPercent = (this.dislikes / (this.likes + this.dislikes)) * 100
55 return this.streamingPlaylists.find(p => p.type === VideoStreamingPlaylistType.HLS)
59 return !!this.getHlsPlaylist()
63 if (this.files.length !== 0) return this.files
65 const hls = this.getHlsPlaylist()
66 if (hls) return hls.files