1 import { User } from '../../shared';
18 thumbnailPath: string;
24 private static createByString(author: string, podHost: string) {
25 return author + '@' + podHost;
28 private static createDurationString(duration: number) {
29 const minutes = Math.floor(duration / 60);
30 const seconds = duration % 60;
31 const minutes_padding = minutes >= 10 ? '' : '0';
32 const seconds_padding = seconds >= 10 ? '' : '0';
34 return minutes_padding + minutes.toString() + ':' + seconds_padding + seconds.toString();
40 categoryLabel: string,
42 languageLabel: string;
51 thumbnailPath: string,
57 this.author = hash.author;
58 this.createdAt = new Date(hash.createdAt);
59 this.categoryLabel = hash.categoryLabel;
60 this.licenceLabel = hash.licenceLabel;
61 this.languageLabel = hash.languageLabel;
62 this.description = hash.description;
63 this.duration = Video.createDurationString(hash.duration);
65 this.isLocal = hash.isLocal;
66 this.magnetUri = hash.magnetUri;
67 this.name = hash.name;
68 this.podHost = hash.podHost;
69 this.tags = hash.tags;
70 this.thumbnailPath = hash.thumbnailPath;
71 this.views = hash.views;
72 this.likes = hash.likes;
73 this.dislikes = hash.dislikes;
74 this.nsfw = hash.nsfw;
76 this.by = Video.createByString(hash.author, hash.podHost);
79 isRemovableBy(user: User) {
80 return this.isLocal === true && user && this.author === user.username;
83 isVideoNSFWForUser(user: User) {
84 // If the video is NSFW and the user is not logged in, or the user does not want to display NSFW videos...
85 return (this.nsfw && (!user || user.displayNSFW === false));