4 VideoPlaylist as ServerVideoPlaylist,
7 } from '../../../../../shared/models/videos'
8 import { AccountSummary, peertubeTranslate } from '@shared/models'
9 import { Actor } from '@app/shared/actor/actor.model'
10 import { getAbsoluteAPIUrl } from '@app/shared/misc/utils'
12 export class VideoPlaylist implements ServerVideoPlaylist {
19 privacy: VideoConstant<VideoPlaylistPrivacy>
25 type: VideoConstant<VideoPlaylistType>
27 createdAt: Date | string
28 updatedAt: Date | string
30 ownerAccount: AccountSummary
31 videoChannel?: VideoChannelSummary
36 ownerAvatarUrl: string
38 videoChannelBy?: string
39 videoChannelAvatarUrl?: string
41 private thumbnailVersion: number
42 private originThumbnailUrl: string
44 constructor (hash: ServerVideoPlaylist, translations: {}) {
45 const absoluteAPIUrl = getAbsoluteAPIUrl()
49 this.isLocal = hash.isLocal
51 this.displayName = hash.displayName
53 this.description = hash.description
54 this.privacy = hash.privacy
56 this.thumbnailPath = hash.thumbnailPath
58 if (this.thumbnailPath) {
59 this.thumbnailUrl = absoluteAPIUrl + hash.thumbnailPath
60 this.originThumbnailUrl = this.thumbnailUrl
62 this.thumbnailUrl = window.location.origin + '/client/assets/images/default-playlist.jpg'
65 this.videosLength = hash.videosLength
69 this.createdAt = new Date(hash.createdAt)
70 this.updatedAt = new Date(hash.updatedAt)
72 this.ownerAccount = hash.ownerAccount
73 this.ownerBy = Actor.CREATE_BY_STRING(hash.ownerAccount.name, hash.ownerAccount.host)
74 this.ownerAvatarUrl = Actor.GET_ACTOR_AVATAR_URL(this.ownerAccount)
76 if (hash.videoChannel) {
77 this.videoChannel = hash.videoChannel
78 this.videoChannelBy = Actor.CREATE_BY_STRING(hash.videoChannel.name, hash.videoChannel.host)
79 this.videoChannelAvatarUrl = Actor.GET_ACTOR_AVATAR_URL(this.videoChannel)
82 this.privacy.label = peertubeTranslate(this.privacy.label, translations)
84 if (this.type.id === VideoPlaylistType.WATCH_LATER) {
85 this.displayName = peertubeTranslate(this.displayName, translations)
90 if (!this.originThumbnailUrl) return
92 if (!this.thumbnailVersion) this.thumbnailVersion = 0
93 this.thumbnailVersion++
95 this.thumbnailUrl = this.originThumbnailUrl + '?v' + this.thumbnailVersion