2019-05-31 15:14:40 +02:00
|
|
|
import { VideoConstant, VideoDetails as VideoDetailsServerModel, VideoFile, VideoState } from '../../../../../shared'
|
2018-01-03 10:12:36 +01:00
|
|
|
import { Video } from '../../shared/video/video.model'
|
2018-05-25 09:57:16 +02:00
|
|
|
import { Account } from '@app/shared/account/account.model'
|
2018-08-21 16:18:59 +02:00
|
|
|
import { VideoChannel } from '@app/shared/video-channel/video-channel.model'
|
2019-01-29 08:37:25 +01:00
|
|
|
import { VideoStreamingPlaylist } from '../../../../../shared/models/videos/video-streaming-playlist.model'
|
|
|
|
import { VideoStreamingPlaylistType } from '../../../../../shared/models/videos/video-streaming-playlist.type'
|
2017-10-25 16:43:19 +02:00
|
|
|
|
|
|
|
export class VideoDetails extends Video implements VideoDetailsServerModel {
|
2018-03-19 11:04:40 +01:00
|
|
|
descriptionPath: string
|
2018-02-15 14:46:26 +01:00
|
|
|
support: string
|
2018-03-19 11:04:40 +01:00
|
|
|
channel: VideoChannel
|
2017-10-25 16:43:19 +02:00
|
|
|
tags: string[]
|
|
|
|
files: VideoFile[]
|
2017-12-06 17:15:59 +01:00
|
|
|
account: Account
|
2018-03-19 11:04:40 +01:00
|
|
|
commentsEnabled: boolean
|
2018-10-08 14:45:22 +02:00
|
|
|
downloadEnabled: boolean
|
2018-03-19 11:04:40 +01:00
|
|
|
|
2018-06-12 20:04:58 +02:00
|
|
|
waitTranscoding: boolean
|
|
|
|
state: VideoConstant<VideoState>
|
|
|
|
|
2017-12-06 18:04:40 +01:00
|
|
|
likesPercent: number
|
|
|
|
dislikesPercent: number
|
2017-10-25 16:43:19 +02:00
|
|
|
|
2019-01-29 08:37:25 +01:00
|
|
|
trackerUrls: string[]
|
|
|
|
|
|
|
|
streamingPlaylists: VideoStreamingPlaylist[]
|
|
|
|
|
2018-06-06 16:46:42 +02:00
|
|
|
constructor (hash: VideoDetailsServerModel, translations = {}) {
|
|
|
|
super(hash, translations)
|
2017-10-25 16:43:19 +02:00
|
|
|
|
2017-10-30 20:26:06 +01:00
|
|
|
this.descriptionPath = hash.descriptionPath
|
2017-10-25 16:43:19 +02:00
|
|
|
this.files = hash.files
|
2018-08-21 16:18:59 +02:00
|
|
|
this.channel = new VideoChannel(hash.channel)
|
2018-05-25 09:57:16 +02:00
|
|
|
this.account = new Account(hash.account)
|
2017-12-14 10:07:57 +01:00
|
|
|
this.tags = hash.tags
|
2018-02-20 16:13:05 +01:00
|
|
|
this.support = hash.support
|
2018-01-03 10:12:36 +01:00
|
|
|
this.commentsEnabled = hash.commentsEnabled
|
2018-10-08 14:45:22 +02:00
|
|
|
this.downloadEnabled = hash.downloadEnabled
|
2017-12-06 18:04:40 +01:00
|
|
|
|
2019-01-29 08:37:25 +01:00
|
|
|
this.trackerUrls = hash.trackerUrls
|
|
|
|
this.streamingPlaylists = hash.streamingPlaylists
|
|
|
|
|
2018-02-28 09:49:40 +01:00
|
|
|
this.buildLikeAndDislikePercents()
|
2017-10-25 16:43:19 +02:00
|
|
|
}
|
|
|
|
|
2018-02-28 09:49:40 +01:00
|
|
|
buildLikeAndDislikePercents () {
|
|
|
|
this.likesPercent = (this.likes / (this.likes + this.dislikes)) * 100
|
|
|
|
this.dislikesPercent = (this.dislikes / (this.likes + this.dislikes)) * 100
|
|
|
|
}
|
2019-01-29 08:37:25 +01:00
|
|
|
|
|
|
|
getHlsPlaylist () {
|
|
|
|
return this.streamingPlaylists.find(p => p.type === VideoStreamingPlaylistType.HLS)
|
|
|
|
}
|
2019-05-14 11:35:54 +02:00
|
|
|
|
|
|
|
hasHlsPlaylist () {
|
|
|
|
return !!this.getHlsPlaylist()
|
|
|
|
}
|
2019-11-21 17:01:24 +01:00
|
|
|
|
|
|
|
getFiles () {
|
|
|
|
if (this.files.length === 0) return this.getHlsPlaylist().files
|
2019-11-22 17:27:46 +01:00
|
|
|
|
|
|
|
return this.files
|
2019-11-21 17:01:24 +01:00
|
|
|
}
|
2017-10-25 16:43:19 +02:00
|
|
|
}
|