1 import { getAbsoluteAPIUrl, getAbsoluteEmbedUrl } from '@app/helpers'
2 import { Actor } from '@app/shared/shared-main'
3 import { peertubeTranslate } from '@shared/core-utils/i18n'
8 VideoPlaylist as ServerVideoPlaylist,
11 } from '@shared/models'
13 export class VideoPlaylist implements ServerVideoPlaylist {
22 privacy: VideoConstant<VideoPlaylistPrivacy>
26 type: VideoConstant<VideoPlaylistType>
28 createdAt: Date | string
29 updatedAt: Date | string
31 ownerAccount: AccountSummary
32 videoChannel?: VideoChannelSummary
42 videoChannelBy?: string
44 constructor (hash: ServerVideoPlaylist, translations: {}) {
45 const absoluteAPIUrl = getAbsoluteAPIUrl()
50 this.isLocal = hash.isLocal
52 this.displayName = hash.displayName
54 this.description = hash.description
55 this.privacy = hash.privacy
57 this.thumbnailPath = hash.thumbnailPath
59 this.thumbnailUrl = this.thumbnailPath
60 ? hash.thumbnailUrl || (absoluteAPIUrl + hash.thumbnailPath)
61 : absoluteAPIUrl + '/client/assets/images/default-playlist.jpg'
63 this.embedPath = hash.embedPath
64 this.embedUrl = hash.embedUrl || (getAbsoluteEmbedUrl() + hash.embedPath)
66 this.videosLength = hash.videosLength
70 this.createdAt = new Date(hash.createdAt)
71 this.updatedAt = new Date(hash.updatedAt)
73 this.ownerAccount = hash.ownerAccount
74 this.ownerBy = Actor.CREATE_BY_STRING(hash.ownerAccount.name, hash.ownerAccount.host)
76 if (hash.videoChannel) {
77 this.videoChannel = hash.videoChannel
78 this.videoChannelBy = Actor.CREATE_BY_STRING(hash.videoChannel.name, hash.videoChannel.host)
81 this.privacy.label = peertubeTranslate(this.privacy.label, translations)
83 if (this.type.id === VideoPlaylistType.WATCH_LATER) {
84 this.displayName = peertubeTranslate(this.displayName, translations)