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