aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/app/videos/shared/video.model.ts
diff options
context:
space:
mode:
Diffstat (limited to 'client/app/videos/shared/video.model.ts')
-rw-r--r--client/app/videos/shared/video.model.ts64
1 files changed, 0 insertions, 64 deletions
diff --git a/client/app/videos/shared/video.model.ts b/client/app/videos/shared/video.model.ts
deleted file mode 100644
index 614403d79..000000000
--- a/client/app/videos/shared/video.model.ts
+++ /dev/null
@@ -1,64 +0,0 @@
1export class Video {
2 author: string;
3 by: string;
4 createdDate: Date;
5 description: string;
6 duration: string;
7 id: string;
8 isLocal: boolean;
9 magnetUri: string;
10 name: string;
11 podUrl: string;
12 thumbnailPath: string;
13
14 private static createByString(author: string, podUrl: string) {
15 let [ host, port ] = podUrl.replace(/^https?:\/\//, '').split(':');
16
17 if (port === '80' || port === '443') {
18 port = '';
19 } else {
20 port = ':' + port;
21 }
22
23 return author + '@' + host + port;
24 }
25
26 private static createDurationString(duration: number) {
27 const minutes = Math.floor(duration / 60);
28 const seconds = duration % 60;
29 const minutes_padding = minutes >= 10 ? '' : '0';
30 const seconds_padding = seconds >= 10 ? '' : '0';
31
32 return minutes_padding + minutes.toString() + ':' + seconds_padding + seconds.toString();
33 }
34
35 constructor(hash: {
36 author: string,
37 createdDate: string,
38 description: string,
39 duration: number;
40 id: string,
41 isLocal: boolean,
42 magnetUri: string,
43 name: string,
44 podUrl: string,
45 thumbnailPath: string
46 }) {
47 this.author = hash.author;
48 this.createdDate = new Date(hash.createdDate);
49 this.description = hash.description;
50 this.duration = Video.createDurationString(hash.duration);
51 this.id = hash.id;
52 this.isLocal = hash.isLocal;
53 this.magnetUri = hash.magnetUri;
54 this.name = hash.name;
55 this.podUrl = hash.podUrl;
56 this.thumbnailPath = hash.thumbnailPath;
57
58 this.by = Video.createByString(hash.author, hash.podUrl);
59 }
60
61 isRemovableBy(user) {
62 return this.isLocal === true && user && this.author === user.username;
63 }
64}