1
0
Fork 0
peertube/server/core/helpers/video.ts

29 lines
1006 B
TypeScript
Raw Normal View History

import { VideoPrivacy } from '@peertube/peertube-models'
import { CONFIG } from '@server/initializers/config.js'
import { isStreamingPlaylist, MStreamingPlaylistVideo, MVideo } from '@server/types/models/index.js'
import { Response } from 'express'
2018-09-19 09:16:23 +00:00
export function getVideoWithAttributes (res: Response) {
2021-06-11 12:09:33 +00:00
return res.locals.videoAPI || res.locals.videoAll || res.locals.onlyVideo
2019-08-20 11:52:49 +00:00
}
export function extractVideo (videoOrPlaylist: MVideo | MStreamingPlaylistVideo) {
2020-04-23 07:32:53 +00:00
return isStreamingPlaylist(videoOrPlaylist)
? videoOrPlaylist.Video
: videoOrPlaylist
}
export function getPrivaciesForFederation () {
return (CONFIG.FEDERATION.VIDEOS.FEDERATE_UNLISTED === true)
? [ { privacy: VideoPrivacy.PUBLIC }, { privacy: VideoPrivacy.UNLISTED } ]
: [ { privacy: VideoPrivacy.PUBLIC } ]
}
export function getExtFromMimetype (mimeTypes: { [id: string]: string | string[] }, mimeType: string) {
const value = mimeTypes[mimeType]
if (Array.isArray(value)) return value[0]
return value
}