aboutsummaryrefslogtreecommitdiffhomepage
path: root/server/helpers/video.ts
diff options
context:
space:
mode:
authorChocobozzz <me@florianbigard.com>2020-08-10 14:25:29 +0200
committerChocobozzz <chocobozzz@cpy.re>2020-08-11 07:57:20 +0200
commit30bc55c88b3b7416c2224925e88639694fd32746 (patch)
treeaebe3b1b8657198e432080f7d15a5694f19a8389 /server/helpers/video.ts
parent560605026bfadab711cf6d34e9c7ea865887816a (diff)
downloadPeerTube-30bc55c88b3b7416c2224925e88639694fd32746.tar.gz
PeerTube-30bc55c88b3b7416c2224925e88639694fd32746.tar.zst
PeerTube-30bc55c88b3b7416c2224925e88639694fd32746.zip
Refactor video extensions logic in server
Diffstat (limited to 'server/helpers/video.ts')
-rw-r--r--server/helpers/video.ts19
1 files changed, 14 insertions, 5 deletions
diff --git a/server/helpers/video.ts b/server/helpers/video.ts
index 89c85accb..488b4da17 100644
--- a/server/helpers/video.ts
+++ b/server/helpers/video.ts
@@ -1,5 +1,8 @@
1import { VideoModel } from '../models/video/video'
2import * as Bluebird from 'bluebird' 1import * as Bluebird from 'bluebird'
2import { Response } from 'express'
3import { CONFIG } from '@server/initializers/config'
4import { DEFAULT_AUDIO_RESOLUTION } from '@server/initializers/constants'
5import { JobQueue } from '@server/lib/job-queue'
3import { 6import {
4 isStreamingPlaylist, 7 isStreamingPlaylist,
5 MStreamingPlaylistVideo, 8 MStreamingPlaylistVideo,
@@ -12,11 +15,8 @@ import {
12 MVideoThumbnail, 15 MVideoThumbnail,
13 MVideoWithRights 16 MVideoWithRights
14} from '@server/types/models' 17} from '@server/types/models'
15import { Response } from 'express'
16import { DEFAULT_AUDIO_RESOLUTION } from '@server/initializers/constants'
17import { JobQueue } from '@server/lib/job-queue'
18import { VideoPrivacy, VideoTranscodingPayload } from '@shared/models' 18import { VideoPrivacy, VideoTranscodingPayload } from '@shared/models'
19import { CONFIG } from "@server/initializers/config" 19import { VideoModel } from '../models/video/video'
20 20
21type VideoFetchType = 'all' | 'only-video' | 'only-video-with-rights' | 'id' | 'none' | 'only-immutable-attributes' 21type VideoFetchType = 'all' | 'only-video' | 'only-video-with-rights' | 'id' | 'none' | 'only-immutable-attributes'
22 22
@@ -110,6 +110,14 @@ function getPrivaciesForFederation () {
110 : [ { privacy: VideoPrivacy.PUBLIC } ] 110 : [ { privacy: VideoPrivacy.PUBLIC } ]
111} 111}
112 112
113function getExtFromMimetype (mimeTypes: { [id: string]: string | string[] }, mimeType: string) {
114 const value = mimeTypes[mimeType]
115
116 if (Array.isArray(value)) return value[0]
117
118 return value
119}
120
113export { 121export {
114 VideoFetchType, 122 VideoFetchType,
115 VideoFetchByUrlType, 123 VideoFetchByUrlType,
@@ -118,6 +126,7 @@ export {
118 fetchVideoByUrl, 126 fetchVideoByUrl,
119 addOptimizeOrMergeAudioJob, 127 addOptimizeOrMergeAudioJob,
120 extractVideo, 128 extractVideo,
129 getExtFromMimetype,
121 isPrivacyForFederation, 130 isPrivacyForFederation,
122 getPrivaciesForFederation 131 getPrivaciesForFederation
123} 132}