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';
20 return minutes_padding + minutes.toString() + ':' + seconds_padding + seconds.toString();
23 private static createByString(author: string, podUrl: string) {
24 let [ host, port ] = podUrl.replace(/^https?:\/\//, '').split(':');
26 if (port === '80' || port === '443') {
32 return author + '@' + host + port;
42 thumbnailPath: string,
48 this.name = hash.name;
49 this.description = hash.description;
50 this.magnetUri = hash.magnetUri;
51 this.podUrl = hash.podUrl;
52 this.isLocal = hash.isLocal;
53 this.thumbnailPath = hash.thumbnailPath;
54 this.author = hash.author;
55 this.createdDate = new Date(hash.createdDate);
56 this.duration = Video.createDurationString(hash.duration);
57 this.by = Video.createByString(hash.author, hash.podUrl);
61 return this.isLocal === true && user && this.author === user.username;