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 constructor (hash: ServerVideoPlaylist, translations: {}) {
42 const absoluteAPIUrl = getAbsoluteAPIUrl()
46 this.isLocal = hash.isLocal
48 this.displayName = hash.displayName
50 this.description = hash.description
51 this.privacy = hash.privacy
53 this.thumbnailPath = hash.thumbnailPath
55 if (this.thumbnailPath) {
56 this.thumbnailUrl = absoluteAPIUrl + hash.thumbnailPath
58 this.thumbnailUrl = window.location.origin + '/client/assets/images/default-playlist.jpg'
61 this.videosLength = hash.videosLength
65 this.createdAt = new Date(hash.createdAt)
66 this.updatedAt = new Date(hash.updatedAt)
68 this.ownerAccount = hash.ownerAccount
69 this.ownerBy = Actor.CREATE_BY_STRING(hash.ownerAccount.name, hash.ownerAccount.host)
70 this.ownerAvatarUrl = Actor.GET_ACTOR_AVATAR_URL(this.ownerAccount)
72 if (hash.videoChannel) {
73 this.videoChannel = hash.videoChannel
74 this.videoChannelBy = Actor.CREATE_BY_STRING(hash.videoChannel.name, hash.videoChannel.host)
75 this.videoChannelAvatarUrl = Actor.GET_ACTOR_AVATAR_URL(this.videoChannel)
78 this.privacy.label = peertubeTranslate(this.privacy.label, translations)
80 if (this.type.id === VideoPlaylistType.WATCH_LATER) {
81 this.displayName = peertubeTranslate(this.displayName, translations)