1 import { User } from '../../shared';
17 thumbnailPath: string;
23 private static createByString(author: string, podHost: string) {
24 return author + '@' + podHost;
27 private static createDurationString(duration: number) {
28 const minutes = Math.floor(duration / 60);
29 const seconds = duration % 60;
30 const minutes_padding = minutes >= 10 ? '' : '0';
31 const seconds_padding = seconds >= 10 ? '' : '0';
33 return minutes_padding + minutes.toString() + ':' + seconds_padding + seconds.toString();
39 categoryLabel: string,
49 thumbnailPath: string,
55 this.author = hash.author;
56 this.createdAt = new Date(hash.createdAt);
57 this.categoryLabel = hash.categoryLabel;
58 this.licenceLabel = hash.licenceLabel;
59 this.description = hash.description;
60 this.duration = Video.createDurationString(hash.duration);
62 this.isLocal = hash.isLocal;
63 this.magnetUri = hash.magnetUri;
64 this.name = hash.name;
65 this.podHost = hash.podHost;
66 this.tags = hash.tags;
67 this.thumbnailPath = hash.thumbnailPath;
68 this.views = hash.views;
69 this.likes = hash.likes;
70 this.dislikes = hash.dislikes;
71 this.nsfw = hash.nsfw;
73 this.by = Video.createByString(hash.author, hash.podHost);
76 isRemovableBy(user: User) {
77 return this.isLocal === true && user && this.author === user.username;
80 isVideoNSFWForUser(user: User) {
81 // If the video is NSFW and the user is not logged in, or the user does not want to display NSFW videos...
82 return (this.nsfw && (!user || user.displayNSFW === false));