aboutsummaryrefslogtreecommitdiffhomepage
path: root/client/angular/videos/video.ts
diff options
context:
space:
mode:
authorChocobozzz <florian.bigard@gmail.com>2016-05-21 18:03:34 +0200
committerChocobozzz <florian.bigard@gmail.com>2016-05-21 18:08:23 +0200
commit501bc6c2b186f6a724a5b619d15aa44791f13995 (patch)
tree4a6e1d244c5f94305a25b6ec6f50f1a71ce9295d /client/angular/videos/video.ts
parent295ba044afc394ef51dac22263063670362787ec (diff)
downloadPeerTube-501bc6c2b186f6a724a5b619d15aa44791f13995.tar.gz
PeerTube-501bc6c2b186f6a724a5b619d15aa44791f13995.tar.zst
PeerTube-501bc6c2b186f6a724a5b619d15aa44791f13995.zip
Thumbnail, author and duration support in client
Diffstat (limited to 'client/angular/videos/video.ts')
-rw-r--r--client/angular/videos/video.ts60
1 files changed, 60 insertions, 0 deletions
diff --git a/client/angular/videos/video.ts b/client/angular/videos/video.ts
new file mode 100644
index 000000000..32ff64eb3
--- /dev/null
+++ b/client/angular/videos/video.ts
@@ -0,0 +1,60 @@
1export class Video {
2 id: string;
3 name: string;
4 description: string;
5 magnetUri: string;
6 podUrl: string;
7 isLocal: boolean;
8 thumbnailPath: string;
9 author: string;
10 createdDate: Date;
11 by: string;
12 duration: string;
13
14 constructor(hash: {
15 id: string,
16 name: string,
17 description: string,
18 magnetUri: string,
19 podUrl: string,
20 isLocal: boolean,
21 thumbnailPath: string,
22 author: string,
23 createdDate: string,
24 duration: number;
25 }) {
26 this.id = hash.id;
27 this.name = hash.name;
28 this.description = hash.description;
29 this.magnetUri = hash.magnetUri;
30 this.podUrl = hash.podUrl;
31 this.isLocal = hash.isLocal;
32 this.thumbnailPath = hash.thumbnailPath;
33 this.author = hash.author;
34 this.createdDate = new Date(hash.createdDate);
35 this.duration = Video.createDurationString(hash.duration);
36 this.by = Video.createByString(hash.author, hash.podUrl);
37 }
38
39 isRemovableBy(user): boolean {
40 return this.isLocal === true && user && this.author === user.username;
41 }
42
43 private static createDurationString(duration: number): string {
44 const minutes = Math.floor(duration / 60);
45 const seconds = duration % 60;
46 const minutes_padding = minutes >= 10 ? '' : '0';
47 const seconds_padding = seconds >= 10 ? '' : '0'
48
49 return minutes_padding + minutes.toString() + ':' + seconds_padding + seconds.toString();
50 }
51
52 private static createByString(author: string, podUrl: string): string {
53 let [ host, port ] = podUrl.replace(/^https?:\/\//, '').split(':');
54
55 if (port === '80' || port === '443') port = '';
56 else port = ':' + port;
57
58 return author + '@' + host + port;
59 }
60}