]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame_incremental - server/helpers/video.ts
Remove exif tags when processing images
[github/Chocobozzz/PeerTube.git] / server / helpers / video.ts
... / ...
CommitLineData
1import { Response } from 'express'
2import { CONFIG } from '@server/initializers/config'
3import { isStreamingPlaylist, MStreamingPlaylistVideo, MVideo } from '@server/types/models'
4import { VideoPrivacy, VideoState } from '@shared/models'
5
6function getVideoWithAttributes (res: Response) {
7 return res.locals.videoAPI || res.locals.videoAll || res.locals.onlyVideo
8}
9
10function extractVideo (videoOrPlaylist: MVideo | MStreamingPlaylistVideo) {
11 return isStreamingPlaylist(videoOrPlaylist)
12 ? videoOrPlaylist.Video
13 : videoOrPlaylist
14}
15
16function isPrivacyForFederation (privacy: VideoPrivacy) {
17 const castedPrivacy = parseInt(privacy + '', 10)
18
19 return castedPrivacy === VideoPrivacy.PUBLIC ||
20 (CONFIG.FEDERATION.VIDEOS.FEDERATE_UNLISTED === true && castedPrivacy === VideoPrivacy.UNLISTED)
21}
22
23function isStateForFederation (state: VideoState) {
24 const castedState = parseInt(state + '', 10)
25
26 return castedState === VideoState.PUBLISHED || castedState === VideoState.WAITING_FOR_LIVE || castedState === VideoState.LIVE_ENDED
27}
28
29function getPrivaciesForFederation () {
30 return (CONFIG.FEDERATION.VIDEOS.FEDERATE_UNLISTED === true)
31 ? [ { privacy: VideoPrivacy.PUBLIC }, { privacy: VideoPrivacy.UNLISTED } ]
32 : [ { privacy: VideoPrivacy.PUBLIC } ]
33}
34
35function getExtFromMimetype (mimeTypes: { [id: string]: string | string[] }, mimeType: string) {
36 const value = mimeTypes[mimeType]
37
38 if (Array.isArray(value)) return value[0]
39
40 return value
41}
42
43export {
44 getVideoWithAttributes,
45 extractVideo,
46 getExtFromMimetype,
47 isStateForFederation,
48 isPrivacyForFederation,
49 getPrivaciesForFederation
50}