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