diff options
Diffstat (limited to 'server/models/video/formatter')
-rw-r--r-- | server/models/video/formatter/video-format-utils.ts | 31 |
1 files changed, 16 insertions, 15 deletions
diff --git a/server/models/video/formatter/video-format-utils.ts b/server/models/video/formatter/video-format-utils.ts index 611edf0b9..6222107d7 100644 --- a/server/models/video/formatter/video-format-utils.ts +++ b/server/models/video/formatter/video-format-utils.ts | |||
@@ -1,11 +1,19 @@ | |||
1 | import { generateMagnetUri } from '@server/helpers/webtorrent' | 1 | import { generateMagnetUri } from '@server/helpers/webtorrent' |
2 | import { getActivityStreamDuration } from '@server/lib/activitypub/activity' | ||
2 | import { getLocalVideoFileMetadataUrl } from '@server/lib/video-urls' | 3 | import { getLocalVideoFileMetadataUrl } from '@server/lib/video-urls' |
3 | import { VideoViews } from '@server/lib/video-views' | 4 | import { VideoViewsManager } from '@server/lib/views/video-views-manager' |
4 | import { uuidToShort } from '@shared/extra-utils' | 5 | import { uuidToShort } from '@shared/extra-utils' |
5 | import { VideoFile, VideosCommonQueryAfterSanitize } from '@shared/models' | 6 | import { |
6 | import { ActivityTagObject, ActivityUrlObject, VideoObject } from '../../../../shared/models/activitypub/objects' | 7 | ActivityTagObject, |
7 | import { Video, VideoDetails, VideoInclude } from '../../../../shared/models/videos' | 8 | ActivityUrlObject, |
8 | import { VideoStreamingPlaylist } from '../../../../shared/models/videos/video-streaming-playlist.model' | 9 | Video, |
10 | VideoDetails, | ||
11 | VideoFile, | ||
12 | VideoInclude, | ||
13 | VideoObject, | ||
14 | VideosCommonQueryAfterSanitize, | ||
15 | VideoStreamingPlaylist | ||
16 | } from '@shared/models' | ||
9 | import { isArray } from '../../../helpers/custom-validators/misc' | 17 | import { isArray } from '../../../helpers/custom-validators/misc' |
10 | import { | 18 | import { |
11 | MIMETYPES, | 19 | MIMETYPES, |
@@ -97,7 +105,10 @@ function videoModelToFormattedJSON (video: MVideoFormattable, options: VideoForm | |||
97 | 105 | ||
98 | isLocal: video.isOwned(), | 106 | isLocal: video.isOwned(), |
99 | duration: video.duration, | 107 | duration: video.duration, |
108 | |||
100 | views: video.views, | 109 | views: video.views, |
110 | viewers: VideoViewsManager.Instance.getViewers(video), | ||
111 | |||
101 | likes: video.likes, | 112 | likes: video.likes, |
102 | dislikes: video.dislikes, | 113 | dislikes: video.dislikes, |
103 | thumbnailPath: video.getMiniatureStaticPath(), | 114 | thumbnailPath: video.getMiniatureStaticPath(), |
@@ -121,10 +132,6 @@ function videoModelToFormattedJSON (video: MVideoFormattable, options: VideoForm | |||
121 | pluginData: (video as any).pluginData | 132 | pluginData: (video as any).pluginData |
122 | } | 133 | } |
123 | 134 | ||
124 | if (video.isLive) { | ||
125 | videoObject.viewers = VideoViews.Instance.getViewers(video) | ||
126 | } | ||
127 | |||
128 | const add = options.additionalAttributes | 135 | const add = options.additionalAttributes |
129 | if (add?.state === true) { | 136 | if (add?.state === true) { |
130 | videoObject.state = { | 137 | videoObject.state = { |
@@ -459,11 +466,6 @@ function videoModelToActivityPubObject (video: MVideoAP): VideoObject { | |||
459 | } | 466 | } |
460 | } | 467 | } |
461 | 468 | ||
462 | function getActivityStreamDuration (duration: number) { | ||
463 | // https://www.w3.org/TR/activitystreams-vocabulary/#dfn-duration | ||
464 | return 'PT' + duration + 'S' | ||
465 | } | ||
466 | |||
467 | function getCategoryLabel (id: number) { | 469 | function getCategoryLabel (id: number) { |
468 | return VIDEO_CATEGORIES[id] || 'Misc' | 470 | return VIDEO_CATEGORIES[id] || 'Misc' |
469 | } | 471 | } |
@@ -489,7 +491,6 @@ export { | |||
489 | videoModelToFormattedDetailsJSON, | 491 | videoModelToFormattedDetailsJSON, |
490 | videoFilesModelToFormattedJSON, | 492 | videoFilesModelToFormattedJSON, |
491 | videoModelToActivityPubObject, | 493 | videoModelToActivityPubObject, |
492 | getActivityStreamDuration, | ||
493 | 494 | ||
494 | guessAdditionalAttributesFromQuery, | 495 | guessAdditionalAttributesFromQuery, |
495 | 496 | ||