1 import { User } from '../../shared';
11 languageLabel: string;
21 thumbnailPath: string;
27 private static createByString(author: string, podHost: string) {
28 return author + '@' + podHost;
31 private static createDurationString(duration: number) {
32 const minutes = Math.floor(duration / 60);
33 const seconds = duration % 60;
34 const minutes_padding = minutes >= 10 ? '' : '0';
35 const seconds_padding = seconds >= 10 ? '' : '0';
37 return minutes_padding + minutes.toString() + ':' + seconds_padding + seconds.toString();
43 categoryLabel: string,
47 languageLabel: string;
57 thumbnailPath: string,
63 this.author = hash.author;
64 this.createdAt = new Date(hash.createdAt);
65 this.categoryLabel = hash.categoryLabel;
66 this.category = hash.category;
67 this.licenceLabel = hash.licenceLabel;
68 this.licence = hash.licence;
69 this.languageLabel = hash.languageLabel;
70 this.language = hash.language;
71 this.description = hash.description;
72 this.duration = Video.createDurationString(hash.duration);
74 this.isLocal = hash.isLocal;
75 this.magnetUri = hash.magnetUri;
76 this.name = hash.name;
77 this.podHost = hash.podHost;
78 this.tags = hash.tags;
79 this.thumbnailPath = hash.thumbnailPath;
80 this.views = hash.views;
81 this.likes = hash.likes;
82 this.dislikes = hash.dislikes;
83 this.nsfw = hash.nsfw;
85 this.by = Video.createByString(hash.author, hash.podHost);
89 return user && this.isLocal === true && (this.author === user.username || user.isAdmin() === true);
92 isBlackistableBy(user) {
93 return user && user.isAdmin() === true && this.isLocal === false;
97 return user && this.isLocal === true && user.username === this.author;
100 isVideoNSFWForUser(user: User) {
101 // If the video is NSFW and the user is not logged in, or the user does not want to display NSFW videos...
102 return (this.nsfw && (!user || user.displayNSFW === false));
105 patch(values: Object) {
106 Object.keys(values).forEach((key) => {
107 this[key] = values[key];
114 createdAt: this.createdAt,
115 category: this.category,
116 licence: this.licence,
117 language: this.language,
118 description: this.description,
119 duration: this.duration,
121 isLocal: this.isLocal,
122 magnetUri: this.magnetUri,
124 podHost: this.podHost,
126 thumbnailPath: this.thumbnailPath,
129 dislikes: this.dislikes,