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