]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - client/src/app/shared/shared-video-playlist/video-playlist.model.ts
Use show uuid for playlist miniatures
[github/Chocobozzz/PeerTube.git] / client / src / app / shared / shared-video-playlist / video-playlist.model.ts
1 import { getAbsoluteAPIUrl, getAbsoluteEmbedUrl } from '@app/helpers'
2 import { Actor } from '@app/shared/shared-main'
3 import { peertubeTranslate } from '@shared/core-utils/i18n'
4 import {
5 AccountSummary,
6 VideoChannelSummary,
7 VideoConstant,
8 VideoPlaylist as ServerVideoPlaylist,
9 VideoPlaylistPrivacy,
10 VideoPlaylistType
11 } from '@shared/models'
12
13 export class VideoPlaylist implements ServerVideoPlaylist {
14 id: number
15 uuid: string
16 shortUUID: string
17
18 isLocal: boolean
19
20 url: string
21
22 displayName: string
23 description: string
24 privacy: VideoConstant<VideoPlaylistPrivacy>
25
26 videosLength: number
27
28 type: VideoConstant<VideoPlaylistType>
29
30 createdAt: Date | string
31 updatedAt: Date | string
32
33 ownerAccount: AccountSummary
34 videoChannel?: VideoChannelSummary
35
36 thumbnailPath: string
37 thumbnailUrl: string
38
39 embedPath: string
40 embedUrl: string
41
42 ownerBy: string
43
44 videoChannelBy?: string
45
46 static buildWatchUrl (playlist: Pick<VideoPlaylist, 'uuid' | 'shortUUID'>) {
47 return '/w/p/' + (playlist.shortUUID || playlist.uuid)
48 }
49
50 constructor (hash: ServerVideoPlaylist, translations: {}) {
51 const absoluteAPIUrl = getAbsoluteAPIUrl()
52
53 this.id = hash.id
54 this.uuid = hash.uuid
55 this.shortUUID = hash.shortUUID
56
57 this.url = hash.url
58 this.isLocal = hash.isLocal
59
60 this.displayName = hash.displayName
61
62 this.description = hash.description
63 this.privacy = hash.privacy
64
65 this.thumbnailPath = hash.thumbnailPath
66
67 this.thumbnailUrl = this.thumbnailPath
68 ? hash.thumbnailUrl || (absoluteAPIUrl + hash.thumbnailPath)
69 : absoluteAPIUrl + '/client/assets/images/default-playlist.jpg'
70
71 this.embedPath = hash.embedPath
72 this.embedUrl = hash.embedUrl || (getAbsoluteEmbedUrl() + hash.embedPath)
73
74 this.videosLength = hash.videosLength
75
76 this.type = hash.type
77
78 this.createdAt = new Date(hash.createdAt)
79 this.updatedAt = new Date(hash.updatedAt)
80
81 this.ownerAccount = hash.ownerAccount
82 this.ownerBy = Actor.CREATE_BY_STRING(hash.ownerAccount.name, hash.ownerAccount.host)
83
84 if (hash.videoChannel) {
85 this.videoChannel = hash.videoChannel
86 this.videoChannelBy = Actor.CREATE_BY_STRING(hash.videoChannel.name, hash.videoChannel.host)
87 }
88
89 this.privacy.label = peertubeTranslate(this.privacy.label, translations)
90
91 if (this.type.id === VideoPlaylistType.WATCH_LATER) {
92 this.displayName = peertubeTranslate(this.displayName, translations)
93 }
94 }
95 }