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