]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - client/src/app/shared/shared-main/video/video-details.model.ts
Update angular
[github/Chocobozzz/PeerTube.git] / client / src / app / shared / shared-main / video / video-details.model.ts
CommitLineData
67ed6552
C
1import { Account } from '@app/shared/shared-main/account/account.model'
2import { VideoChannel } from '@app/shared/shared-main/video-channel/video-channel.model'
3import {
4 VideoConstant,
5 VideoDetails as VideoDetailsServerModel,
6 VideoFile,
7 VideoState,
8 VideoStreamingPlaylist,
9 VideoStreamingPlaylistType
10} from '@shared/models'
11import { Video } from './video.model'
404b54e1
C
12
13export class VideoDetails extends Video implements VideoDetailsServerModel {
09700934 14 descriptionPath: string
2422c46b 15 support: string
09700934 16 channel: VideoChannel
404b54e1 17 tags: string[]
b1fa3eba 18 account: Account
09700934 19 commentsEnabled: boolean
7f2cfe3a 20 downloadEnabled: boolean
09700934 21
2186386c
C
22 waitTranscoding: boolean
23 state: VideoConstant<VideoState>
24
6a9e1d42
C
25 likesPercent: number
26 dislikesPercent: number
404b54e1 27
09209296
C
28 trackerUrls: string[]
29
3c10840f 30 files: VideoFile[]
09209296
C
31 streamingPlaylists: VideoStreamingPlaylist[]
32
7ce44a74
C
33 constructor (hash: VideoDetailsServerModel, translations = {}) {
34 super(hash, translations)
404b54e1 35
2de96f4d 36 this.descriptionPath = hash.descriptionPath
22a16e36 37 this.channel = new VideoChannel(hash.channel)
ad9e39fb 38 this.account = new Account(hash.account)
d48ff09d 39 this.tags = hash.tags
07fa4c97 40 this.support = hash.support
47564bbe 41 this.commentsEnabled = hash.commentsEnabled
7f2cfe3a 42 this.downloadEnabled = hash.downloadEnabled
6a9e1d42 43
09209296 44 this.trackerUrls = hash.trackerUrls
09209296 45
20b40b19 46 this.buildLikeAndDislikePercents()
404b54e1
C
47 }
48
20b40b19
C
49 buildLikeAndDislikePercents () {
50 this.likesPercent = (this.likes / (this.likes + this.dislikes)) * 100
51 this.dislikesPercent = (this.dislikes / (this.likes + this.dislikes)) * 100
52 }
09209296
C
53
54 getHlsPlaylist () {
55 return this.streamingPlaylists.find(p => p.type === VideoStreamingPlaylistType.HLS)
56 }
65659166
C
57
58 hasHlsPlaylist () {
59 return !!this.getHlsPlaylist()
60 }
5a71acd2
C
61
62 getFiles () {
c6c0fa6c 63 if (this.files.length !== 0) return this.files
efcd6f2e 64
c6c0fa6c
C
65 const hls = this.getHlsPlaylist()
66 if (hls) return hls.files
67
68 return []
5a71acd2 69 }
404b54e1 70}