- return {
- id: this.id,
- uuid: this.uuid,
- name: this.name,
- category: this.category,
- categoryLabel: this.getCategoryLabel(),
- licence: this.licence,
- licenceLabel: this.getLicenceLabel(),
- language: this.language,
- languageLabel: this.getLanguageLabel(),
- nsfw: this.nsfw,
- description: this.getTruncatedDescription(),
- serverHost,
- isLocal: this.isOwned(),
- accountName: this.VideoChannel.Account.name,
- duration: this.duration,
- views: this.views,
- likes: this.likes,
- dislikes: this.dislikes,
- thumbnailPath: this.getThumbnailPath(),
- previewPath: this.getPreviewPath(),
- embedPath: this.getEmbedPath(),
- createdAt: this.createdAt,
- updatedAt: this.updatedAt
- } as Video
- }
-
- toFormattedDetailsJSON () {
- const formattedJson = this.toFormattedJSON()
-
- // Maybe our server is not up to date and there are new privacy settings since our version
- let privacyLabel = VIDEO_PRIVACIES[this.privacy]
- if (!privacyLabel) privacyLabel = 'Unknown'
-
- const detailsJson = {
- privacyLabel,
- privacy: this.privacy,
- descriptionPath: this.getDescriptionPath(),
- channel: this.VideoChannel.toFormattedJSON(),
- account: this.VideoChannel.Account.toFormattedJSON(),
- tags: map<TagModel, string>(this.Tags, 'name'),
- commentsEnabled: this.commentsEnabled,
- files: []
- }
-
- // Format and sort video files
- const { baseUrlHttp, baseUrlWs } = this.getBaseUrls()
- detailsJson.files = this.VideoFiles
- .map(videoFile => {
- let resolutionLabel = videoFile.resolution + 'p'
-
- return {
- resolution: videoFile.resolution,
- resolutionLabel,
- magnetUri: this.generateMagnetUri(videoFile, baseUrlHttp, baseUrlWs),
- size: videoFile.size,
- torrentUrl: this.getTorrentUrl(videoFile, baseUrlHttp),
- fileUrl: this.getVideoFileUrl(videoFile, baseUrlHttp)
- }
- })
- .sort((a, b) => {
- if (a.resolution < b.resolution) return 1
- if (a.resolution === b.resolution) return 0
- return -1
- })
-
- return Object.assign(formattedJson, detailsJson) as VideoDetails