import { Video, VideoDetails, VideoFile } from '../../../shared/models/videos'
import { VideoModel } from './video'
-import { VideoFileModel } from './video-file'
import {
ActivityPlaylistInfohashesObject,
ActivityPlaylistSegmentHashesObject,
} from '../../lib/activitypub'
import { isArray } from '../../helpers/custom-validators/misc'
import { VideoStreamingPlaylist } from '../../../shared/models/videos/video-streaming-playlist.model'
-import { VideoStreamingPlaylistModel } from './video-streaming-playlist'
+import { MVideo, MVideoAP, MVideoFormattable, MVideoFormattableDetails } from '../../typings/models'
+import { MStreamingPlaylistRedundancies } from '../../typings/models/video/video-streaming-playlist'
+import { MVideoFileRedundanciesOpt } from '../../typings/models/video/video-file'
export type VideoFormattingJSONOptions = {
completeDescription?: boolean
waitTranscoding?: boolean,
scheduledUpdate?: boolean,
blacklistInfo?: boolean
- playlistInfo?: boolean
}
}
-function videoModelToFormattedJSON (video: VideoModel, options?: VideoFormattingJSONOptions): Video {
+function videoModelToFormattedJSON (video: MVideoFormattable, options?: VideoFormattingJSONOptions): Video {
const userHistory = isArray(video.UserVideoHistories) ? video.UserVideoHistories[0] : undefined
const videoObject: Video = {
views: video.views,
likes: video.likes,
dislikes: video.dislikes,
- thumbnailPath: video.getThumbnailStaticPath(),
+ thumbnailPath: video.getMiniatureStaticPath(),
previewPath: video.getPreviewStaticPath(),
embedPath: video.getEmbedStaticPath(),
createdAt: video.createdAt,
videoObject.blacklisted = !!video.VideoBlacklist
videoObject.blacklistedReason = video.VideoBlacklist ? video.VideoBlacklist.reason : null
}
-
- if (options.additionalAttributes.playlistInfo === true) {
- // We filtered on a specific videoId/videoPlaylistId, that is unique
- const playlistElement = video.VideoPlaylistElements[0]
-
- videoObject.playlistElement = {
- position: playlistElement.position,
- startTimestamp: playlistElement.startTimestamp,
- stopTimestamp: playlistElement.stopTimestamp
- }
- }
}
return videoObject
}
-function videoModelToFormattedDetailsJSON (video: VideoModel): VideoDetails {
+function videoModelToFormattedDetailsJSON (video: MVideoFormattableDetails): VideoDetails {
const formattedJson = video.toFormattedJSON({
additionalAttributes: {
scheduledUpdate: true,
const tags = video.Tags ? video.Tags.map(t => t.name) : []
- const streamingPlaylists = streamingPlaylistsModelToFormattedJSON(video, video.VideoStreamingPlaylists)
+ const streamingPlaylists = streamingPlaylistsModelToFormattedJSON(video.VideoStreamingPlaylists)
const detailsJson = {
support: video.support,
return Object.assign(formattedJson, detailsJson)
}
-function streamingPlaylistsModelToFormattedJSON (video: VideoModel, playlists: VideoStreamingPlaylistModel[]): VideoStreamingPlaylist[] {
+function streamingPlaylistsModelToFormattedJSON (playlists: MStreamingPlaylistRedundancies[]): VideoStreamingPlaylist[] {
if (isArray(playlists) === false) return []
return playlists
})
}
-function videoFilesModelToFormattedJSON (video: VideoModel, videoFiles: VideoFileModel[]): VideoFile[] {
+function videoFilesModelToFormattedJSON (video: MVideo, videoFiles: MVideoFileRedundanciesOpt[]): VideoFile[] {
const { baseUrlHttp, baseUrlWs } = video.getBaseUrls()
return videoFiles
})
}
-function videoModelToActivityPubObject (video: VideoModel): VideoTorrentObject {
+function videoModelToActivityPubObject (video: MVideoAP): VideoTorrentObject {
const { baseUrlHttp, baseUrlWs } = video.getBaseUrls()
if (!video.Tags) video.Tags = []
})
}
+ const miniature = video.getMiniature()
+
return {
type: 'Video' as 'Video',
id: video.url,
subtitleLanguage,
icon: {
type: 'Image',
- url: video.getThumbnail().getUrl(),
+ url: miniature.getFileUrl(),
mediaType: 'image/jpeg',
- width: video.getThumbnail().width,
- height: video.getThumbnail().height
+ width: miniature.width,
+ height: miniature.height
},
url,
likes: getVideoLikesActivityPubUrl(video),