]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - 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
CommitLineData
951b582f 1import { getAbsoluteAPIUrl, getAbsoluteEmbedUrl } from '@app/helpers'
37a44fc9 2import { Actor } from '@app/shared/shared-main'
bd45d503 3import { peertubeTranslate } from '@shared/core-utils/i18n'
830b4faf 4import {
67ed6552 5 AccountSummary,
830b4faf
C
6 VideoChannelSummary,
7 VideoConstant,
8 VideoPlaylist as ServerVideoPlaylist,
9 VideoPlaylistPrivacy,
10 VideoPlaylistType
67ed6552 11} from '@shared/models'
830b4faf
C
12
13export class VideoPlaylist implements ServerVideoPlaylist {
14 id: number
15 uuid: string
d4a8e7a6
C
16 shortUUID: string
17
830b4faf
C
18 isLocal: boolean
19
37a44fc9
C
20 url: string
21
830b4faf
C
22 displayName: string
23 description: string
24 privacy: VideoConstant<VideoPlaylistPrivacy>
25
830b4faf
C
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
37a44fc9 36 thumbnailPath: string
830b4faf
C
37 thumbnailUrl: string
38
951b582f
C
39 embedPath: string
40 embedUrl: string
41
830b4faf 42 ownerBy: string
830b4faf
C
43
44 videoChannelBy?: string
830b4faf 45
d4a8e7a6 46 static buildWatchUrl (playlist: Pick<VideoPlaylist, 'uuid' | 'shortUUID'>) {
cf7f5830 47 return '/w/p/' + (playlist.shortUUID || playlist.uuid)
d4a8e7a6
C
48 }
49
830b4faf
C
50 constructor (hash: ServerVideoPlaylist, translations: {}) {
51 const absoluteAPIUrl = getAbsoluteAPIUrl()
52
53 this.id = hash.id
54 this.uuid = hash.uuid
d4a8e7a6
C
55 this.shortUUID = hash.shortUUID
56
37a44fc9 57 this.url = hash.url
830b4faf
C
58 this.isLocal = hash.isLocal
59
60 this.displayName = hash.displayName
f0a39880 61
830b4faf
C
62 this.description = hash.description
63 this.privacy = hash.privacy
64
65 this.thumbnailPath = hash.thumbnailPath
5fb6996b 66
37a44fc9
C
67 this.thumbnailUrl = this.thumbnailPath
68 ? hash.thumbnailUrl || (absoluteAPIUrl + hash.thumbnailPath)
69 : absoluteAPIUrl + '/client/assets/images/default-playlist.jpg'
830b4faf 70
951b582f 71 this.embedPath = hash.embedPath
37a44fc9 72 this.embedUrl = hash.embedUrl || (getAbsoluteEmbedUrl() + hash.embedPath)
951b582f 73
830b4faf
C
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)
830b4faf
C
83
84 if (hash.videoChannel) {
85 this.videoChannel = hash.videoChannel
86 this.videoChannelBy = Actor.CREATE_BY_STRING(hash.videoChannel.name, hash.videoChannel.host)
830b4faf
C
87 }
88
89 this.privacy.label = peertubeTranslate(this.privacy.label, translations)
f0a39880
C
90
91 if (this.type.id === VideoPlaylistType.WATCH_LATER) {
92 this.displayName = peertubeTranslate(this.displayName, translations)
93 }
830b4faf
C
94 }
95}