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.ts59
1 files changed, 30 insertions, 29 deletions
diff --git a/client/app/videos/shared/video.model.ts b/client/app/videos/shared/video.model.ts
index 2b018ad86..614403d79 100644
--- a/client/app/videos/shared/video.model.ts
+++ b/client/app/videos/shared/video.model.ts
@@ -1,24 +1,15 @@
1export class Video { 1export class Video {
2 id: string; 2 author: string;
3 name: string; 3 by: string;
4 createdDate: Date;
4 description: string; 5 description: string;
6 duration: string;
7 id: string;
8 isLocal: boolean;
5 magnetUri: string; 9 magnetUri: string;
10 name: string;
6 podUrl: string; 11 podUrl: string;
7 isLocal: boolean;
8 thumbnailPath: string; 12 thumbnailPath: string;
9 author: string;
10 createdDate: Date;
11 by: string;
12 duration: string;
13
14 private static createDurationString(duration: number) {
15 const minutes = Math.floor(duration / 60);
16 const seconds = duration % 60;
17 const minutes_padding = minutes >= 10 ? '' : '0';
18 const seconds_padding = seconds >= 10 ? '' : '0';
19
20 return minutes_padding + minutes.toString() + ':' + seconds_padding + seconds.toString();
21 }
22 13
23 private static createByString(author: string, podUrl: string) { 14 private static createByString(author: string, podUrl: string) {
24 let [ host, port ] = podUrl.replace(/^https?:\/\//, '').split(':'); 15 let [ host, port ] = podUrl.replace(/^https?:\/\//, '').split(':');
@@ -32,28 +23,38 @@ export class Video {
32 return author + '@' + host + port; 23 return author + '@' + host + port;
33 } 24 }
34 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: { 35 constructor(hash: {
36 id: string,
37 name: string,
38 description: string,
39 magnetUri: string,
40 podUrl: string,
41 isLocal: boolean,
42 thumbnailPath: string,
43 author: string, 36 author: string,
44 createdDate: string, 37 createdDate: string,
38 description: string,
45 duration: number; 39 duration: number;
40 id: string,
41 isLocal: boolean,
42 magnetUri: string,
43 name: string,
44 podUrl: string,
45 thumbnailPath: string
46 }) { 46 }) {
47 this.id = hash.id; 47 this.author = hash.author;
48 this.name = hash.name; 48 this.createdDate = new Date(hash.createdDate);
49 this.description = hash.description; 49 this.description = hash.description;
50 this.duration = Video.createDurationString(hash.duration);
51 this.id = hash.id;
52 this.isLocal = hash.isLocal;
50 this.magnetUri = hash.magnetUri; 53 this.magnetUri = hash.magnetUri;
54 this.name = hash.name;
51 this.podUrl = hash.podUrl; 55 this.podUrl = hash.podUrl;
52 this.isLocal = hash.isLocal;
53 this.thumbnailPath = hash.thumbnailPath; 56 this.thumbnailPath = hash.thumbnailPath;
54 this.author = hash.author; 57
55 this.createdDate = new Date(hash.createdDate);
56 this.duration = Video.createDurationString(hash.duration);
57 this.by = Video.createByString(hash.author, hash.podUrl); 58 this.by = Video.createByString(hash.author, hash.podUrl);
58 } 59 }
59 60