1 import { VideoConstant, VideoDetails as VideoDetailsServerModel, VideoFile, VideoState } from '../../../../../shared'
2 import { Video } from '../../shared/video/video.model'
3 import { Account } from '@app/shared/account/account.model'
4 import { VideoChannel } from '@app/shared/video-channel/video-channel.model'
5 import { VideoStreamingPlaylist } from '../../../../../shared/models/videos/video-streaming-playlist.model'
6 import { VideoStreamingPlaylistType } from '../../../../../shared/models/videos/video-streaming-playlist.type'
8 export class VideoDetails extends Video implements VideoDetailsServerModel {
9 descriptionPath: string
15 commentsEnabled: boolean
16 downloadEnabled: boolean
18 waitTranscoding: boolean
19 state: VideoConstant<VideoState>
22 dislikesPercent: number
26 streamingPlaylists: VideoStreamingPlaylist[]
28 constructor (hash: VideoDetailsServerModel, translations = {}) {
29 super(hash, translations)
31 this.descriptionPath = hash.descriptionPath
32 this.files = hash.files
33 this.channel = new VideoChannel(hash.channel)
34 this.account = new Account(hash.account)
36 this.support = hash.support
37 this.commentsEnabled = hash.commentsEnabled
38 this.downloadEnabled = hash.downloadEnabled
40 this.trackerUrls = hash.trackerUrls
41 this.streamingPlaylists = hash.streamingPlaylists
43 this.buildLikeAndDislikePercents()
46 buildLikeAndDislikePercents () {
47 this.likesPercent = (this.likes / (this.likes + this.dislikes)) * 100
48 this.dislikesPercent = (this.dislikes / (this.likes + this.dislikes)) * 100
52 return this.streamingPlaylists.find(p => p.type === VideoStreamingPlaylistType.HLS)
56 return !!this.getHlsPlaylist()
60 if (this.files.length === 0) return this.getHlsPlaylist().files