]>
Commit | Line | Data |
---|---|---|
501bc6c2 | 1 | export class Video { |
4fd8aa32 C |
2 | author: string; |
3 | by: string; | |
4 | createdDate: Date; | |
501bc6c2 | 5 | description: string; |
4fd8aa32 C |
6 | duration: string; |
7 | id: string; | |
8 | isLocal: boolean; | |
501bc6c2 | 9 | magnetUri: string; |
4fd8aa32 | 10 | name: string; |
49abbbbe | 11 | podHost: string; |
00a44645 | 12 | tags: string[]; |
501bc6c2 | 13 | thumbnailPath: string; |
aff038cd | 14 | |
49abbbbe C |
15 | private static createByString(author: string, podHost: string) { |
16 | return author + '@' + podHost; | |
aff038cd C |
17 | } |
18 | ||
4fd8aa32 C |
19 | private static createDurationString(duration: number) { |
20 | const minutes = Math.floor(duration / 60); | |
21 | const seconds = duration % 60; | |
22 | const minutes_padding = minutes >= 10 ? '' : '0'; | |
23 | const seconds_padding = seconds >= 10 ? '' : '0'; | |
24 | ||
25 | return minutes_padding + minutes.toString() + ':' + seconds_padding + seconds.toString(); | |
26 | } | |
27 | ||
501bc6c2 | 28 | constructor(hash: { |
501bc6c2 C |
29 | author: string, |
30 | createdDate: string, | |
4fd8aa32 | 31 | description: string, |
501bc6c2 | 32 | duration: number; |
4fd8aa32 C |
33 | id: string, |
34 | isLocal: boolean, | |
35 | magnetUri: string, | |
36 | name: string, | |
49abbbbe | 37 | podHost: string, |
00a44645 | 38 | tags: string[], |
4fd8aa32 | 39 | thumbnailPath: string |
501bc6c2 | 40 | }) { |
4fd8aa32 C |
41 | this.author = hash.author; |
42 | this.createdDate = new Date(hash.createdDate); | |
501bc6c2 | 43 | this.description = hash.description; |
4fd8aa32 C |
44 | this.duration = Video.createDurationString(hash.duration); |
45 | this.id = hash.id; | |
46 | this.isLocal = hash.isLocal; | |
501bc6c2 | 47 | this.magnetUri = hash.magnetUri; |
4fd8aa32 | 48 | this.name = hash.name; |
49abbbbe | 49 | this.podHost = hash.podHost; |
00a44645 | 50 | this.tags = hash.tags; |
501bc6c2 | 51 | this.thumbnailPath = hash.thumbnailPath; |
4fd8aa32 | 52 | |
49abbbbe | 53 | this.by = Video.createByString(hash.author, hash.podHost); |
501bc6c2 C |
54 | } |
55 | ||
ccf6ed16 | 56 | isRemovableBy(user) { |
501bc6c2 C |
57 | return this.isLocal === true && user && this.author === user.username; |
58 | } | |
501bc6c2 | 59 | } |