+ getType (this: MVideoPlaylistElementFormattable, displayNSFW?: boolean, accountId?: number) {
+ const video = this.Video
+
+ if (!video) return VideoPlaylistElementType.DELETED
+
+ // Owned video, don't filter it
+ if (accountId && video.VideoChannel.Account.id === accountId) return VideoPlaylistElementType.REGULAR
+
+ // Internal video?
+ if (video.privacy === VideoPrivacy.INTERNAL && accountId) return VideoPlaylistElementType.REGULAR
+
+ if (video.privacy === VideoPrivacy.PRIVATE || video.privacy === VideoPrivacy.INTERNAL) return VideoPlaylistElementType.PRIVATE
+
+ if (video.isBlacklisted() || video.isBlocked()) return VideoPlaylistElementType.UNAVAILABLE
+ if (video.nsfw === true && displayNSFW === false) return VideoPlaylistElementType.UNAVAILABLE
+
+ return VideoPlaylistElementType.REGULAR
+ }
+
+ getVideoElement (this: MVideoPlaylistElementFormattable, displayNSFW?: boolean, accountId?: number) {
+ if (!this.Video) return null
+ if (this.getType(displayNSFW, accountId) !== VideoPlaylistElementType.REGULAR) return null
+
+ return this.Video.toFormattedJSON()
+ }
+
+ toFormattedJSON (
+ this: MVideoPlaylistElementFormattable,
+ options: { displayNSFW?: boolean, accountId?: number } = {}
+ ): VideoPlaylistElement {
+ return {
+ id: this.id,
+ position: this.position,
+ startTimestamp: this.startTimestamp,
+ stopTimestamp: this.stopTimestamp,
+
+ type: this.getType(options.displayNSFW, options.accountId),
+
+ video: this.getVideoElement(options.displayNSFW, options.accountId)
+ }
+ }
+
+ toActivityPubObject (this: MVideoPlaylistElementAP): PlaylistElementObject {